25 lines
1,005 B
Bash
Executable file
25 lines
1,005 B
Bash
Executable file
#!/bin/bash
|
|
|
|
# This is a small tool which checks that all headers are sufficiently standalone
|
|
# and include anything they need.
|
|
# In future we might extend this to find out bogus includes by predefining (-D)
|
|
# headerguards they include, effectively disableing this include for a test.
|
|
|
|
find src -name '*.h' | while read header; do
|
|
echo -e "testing $header"
|
|
awk 'BEGIN {print "#include \""ARGV[1]"\"\nint main(){"}
|
|
/^(struct|enum|class).*[^;]$/{print "\t" $0 " test_" NR "; (void) test_"NR";" }
|
|
END {print "\treturn 0;\n}"}' $header >,headertest.c
|
|
gcc -D_GNU_SOURCE -DEBUG_ALPHA -std=gnu99 -Werror -Wall -I src -c ,headertest.c
|
|
echo
|
|
done
|
|
|
|
find src -name '*.hpp' | while read header; do
|
|
echo -e "testing $header"
|
|
awk 'BEGIN {print "#include \""ARGV[1]"\"\nint main(){"}
|
|
/^(struct|enum|class).*[^;]$/{print "\t" $0 " test_" NR "; (void) test_"NR";" }
|
|
END {print "\treturn 0;\n}"}' $header >,headertest.cpp
|
|
g++ -D_GNU_SOURCE -DEBUG_ALPHA -Werror -Wall -I src -c ,headertest.cpp
|
|
echo
|
|
done
|
|
|