Skip to content

Commit 84f8d1b

Browse files
committed
selfcheck.sh: also run with system includes made available
1 parent 435a74c commit 84f8d1b

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test: testrunner simplecpp
1616
python3 -m pytest integration_test.py -vv
1717

1818
selfcheck: simplecpp
19-
./selfcheck.sh
19+
CXX=$(CXX) ./selfcheck.sh
2020

2121
simplecpp: main.o simplecpp.o
2222
$(CXX) $(LDFLAGS) main.o simplecpp.o -o simplecpp

selfcheck.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,34 @@ output=$(./simplecpp simplecpp.cpp -e -f 2>&1)
44
ec=$?
55
errors=$(echo "$output" | grep -v 'Header not found: <')
66
if [ $ec -ne 0 ]; then
7-
# only fail if got errors which do not refer to missing system includes
7+
# only fail if we got errors which do not refer to missing system includes
88
if [ ! -z "$errors" ]; then
99
exit $ec
1010
fi
11-
fi
11+
fi
12+
13+
if [ -z "$CXX" ]; then
14+
exit 0
15+
fi
16+
17+
# on macOS gcc is an alias for clang
18+
cxx_type=$($CXX --version | head -1 | cut -d' ' -f1)
19+
if [ "$cxx_type" = "g++" ]; then
20+
gcc_ver=$($CXX -dumpversion)
21+
./simplecpp simplecpp.cpp -e -f -std=gnu++11 -D__GNUC__ -D__STDC__ -D__STDC_HOSTED__ -D__CHAR_BIT__=8 -I"/usr/include" -I"/usr/include/linux" -I"/usr/include/c++/$gcc_ver" -I"/usr/include/c++/$gcc_ver/x86_64-pc-linux-gnu" -I"/usr/lib64/gcc/x86_64-pc-linux-gnu/$gcc_ver/include"
22+
ec=$?
23+
if [ $ec -ne 0 ]; then
24+
exit $ec
25+
fi
26+
elif [ "$cxx_type" = "clang" ]; then
27+
#clang_ver=$(clang -dumpversion)
28+
#clang_ver=${clang_ver%%.*}
29+
./simplecpp simplecpp.cpp -e -f -std=gnu++11 -D__BYTE_ORDER__ -I"/usr/include/c++/v1"
30+
ec=$?
31+
if [ $ec -ne 0 ]; then
32+
exit $ec
33+
fi
34+
else
35+
echo "unknown compiler '$cxx_type'"
36+
exit 1
37+
fi

0 commit comments

Comments
 (0)