#!/bin/bash
#                              -*- Mode: SH -*-
#
# Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
#
# The contents of this file are covered under the licence agreement in the
# file "LICENCE" distributed with Cforall.
#
# clean_hdrs --
#
# Author           : Thierry Delisle
# Created On       : Tue Jul 11 16:26:46 2017
# Last Modified By :
# Last Modified On :
# Update Count     : 0
#

set -x
if [ -z "$IWYU_HOME" ]; then
    echo "Need to set IWYU_HOME"
    exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

cd src
rm -f result.log
make CXX="${IWYU_HOME}/build/include-what-you-use 2>&1" -ks 2> /dev/null | awk -f ${DIR}/clean_hdr.awk > result.log -v path=$@
python ${IWYU_HOME}/src/fix_includes.py --nosafe_headers --comments --blank_lines < result.log