Skip to content
Snippets Groups Projects
Commit b3ecbb1e authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Merge branch 'fix-includes' into 'master'

[tools] Add script to fix the includes with IWYU

Closes #8

See merge request i4/manycore/emper!70
parents 12bd27b6 484adf89
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,10 @@ PHONY: iwyu
iwyu: all
$(NINJA) -C build $@
PHONY: fix-includes
fix-includes: all
./tools/fix-includes
stresstest: test
./stresstest/stresstest.sh build/tests/simplest_fib_test
......
#!/usr/bin/env bash
set -euo pipefail
# Pretty fancy method to get reliable the absolute path of a shell
# script, *even if it is sourced*. Credits go to GreenFox on
# stackoverflow: http://stackoverflow.com/a/12197518/194894
pushd . > /dev/null
SCRIPTDIR="${BASH_SOURCE[0]}";
while([ -h "${SCRIPTDIR}" ]); do
cd "`dirname "${SCRIPTDIR}"`"
SCRIPTDIR="$(readlink "`basename "${SCRIPTDIR}"`")";
done
cd "`dirname "${SCRIPTDIR}"`" > /dev/null
SCRIPTDIR="`pwd`";
popd > /dev/null
echoerr() { echo "$@" 1>&2; }
DEBUG=false
while getopts d OPT; do
case $OPT in
d)
set -x
DEBUG=true
;;
*)
echo "usage: ${0##*/} [-dq} [--] ARGS..."
exit 2
esac
done
shift $(( OPTIND - 1 ))
OPTIND=1
ROOTDIR=$(readlink -f "${SCRIPTDIR}/..")
BUILDDIR="${ROOTDIR}/build"
if [[ ! -L "${BUILDDIR}" ]]; then
echoerr "ERROR: ${BUILDDIR} does not exist (or is not a symlink)"
exit 1
fi
cleanup() {
if $DEBUG; then
echo "Debug activated, preserving temporary files"
echo "TMPFILE=${TMPFILE}"
return
fi
rm "${TMPFILE}"
}
TMPFILE="$(mktemp)"
trap cleanup exit
cd "${BUILDDIR}"
echo "Running IWYU"
ninja iwyu > "${TMPFILE}"
echo "Running fix_includes.py"
fix_includes.py < "${TMPFILE}"
cd "${ROOTDIR}"
# Run Clang format afterwards.
make format
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment