Junxiao Shi | 316ea71 | 2015-01-08 20:46:47 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # It's intentional not to use `set -x`, because this script explicitly prints useful information |
| 4 | # and should not run in trace mode. |
| 5 | # It's intentional not to use `set -e`, because this script wants to check all headers |
| 6 | # (similar to running all test cases), instead of failing at the first error. |
| 7 | |
| 8 | CXX=${CXX:-g++} |
Davide Pesavento | 1fd0024 | 2018-05-20 00:11:01 -0400 | [diff] [blame^] | 9 | STD=-std=c++14 |
Davide Pesavento | 2063952 | 2017-06-08 19:34:14 -0400 | [diff] [blame] | 10 | CXXFLAGS="-O2 -Wall -Wno-unused-local-typedef $(pkg-config --cflags libndn-cxx)" |
| 11 | INCLUDEDIR="$(pkg-config --variable=includedir libndn-cxx)"/ndn-cxx |
Junxiao Shi | 316ea71 | 2015-01-08 20:46:47 -0700 | [diff] [blame] | 12 | |
Davide Pesavento | 2063952 | 2017-06-08 19:34:14 -0400 | [diff] [blame] | 13 | echo "Using: $CXX $STD $CXXFLAGS" |
Junxiao Shi | 316ea71 | 2015-01-08 20:46:47 -0700 | [diff] [blame] | 14 | |
Junxiao Shi | 316ea71 | 2015-01-08 20:46:47 -0700 | [diff] [blame] | 15 | NCHECKED=0 |
| 16 | NERRORS=0 |
| 17 | while IFS= read -r -d '' H; do |
Davide Pesavento | 2063952 | 2017-06-08 19:34:14 -0400 | [diff] [blame] | 18 | echo "Verifying standalone header compilation for ${H#${INCLUDEDIR}/}" |
| 19 | "$CXX" -xc++ $STD $CXXFLAGS -c -o /dev/null "$H" |
Junxiao Shi | 316ea71 | 2015-01-08 20:46:47 -0700 | [diff] [blame] | 20 | [[ $? -eq 0 ]] || ((NERRORS++)) |
| 21 | ((NCHECKED++)) |
Davide Pesavento | 2063952 | 2017-06-08 19:34:14 -0400 | [diff] [blame] | 22 | done < <(find "$INCLUDEDIR" -name '*.hpp' -type f -print0 2>/dev/null) |
Junxiao Shi | 316ea71 | 2015-01-08 20:46:47 -0700 | [diff] [blame] | 23 | |
| 24 | if [[ $NCHECKED -eq 0 ]]; then |
| 25 | echo 'No header found. Is ndn-cxx installed?' |
| 26 | exit 1 |
Davide Pesavento | 2063952 | 2017-06-08 19:34:14 -0400 | [diff] [blame] | 27 | else |
| 28 | echo "$NCHECKED headers checked." |
Junxiao Shi | 316ea71 | 2015-01-08 20:46:47 -0700 | [diff] [blame] | 29 | fi |
| 30 | |
| 31 | if [[ $NERRORS -gt 0 ]]; then |
Davide Pesavento | 2063952 | 2017-06-08 19:34:14 -0400 | [diff] [blame] | 32 | echo "$NERRORS headers could not be compiled." |
Junxiao Shi | 316ea71 | 2015-01-08 20:46:47 -0700 | [diff] [blame] | 33 | exit 1 |
| 34 | fi |