blob: cc092531b3ea99b0e6e230f0ccd8244c85e9f6f1 [file] [log] [blame]
Junxiao Shi316ea712015-01-08 20:46:47 -07001#!/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
8CXX=${CXX:-g++}
Davide Pesavento20639522017-06-08 19:34:14 -04009STD=-std=c++11
10CXXFLAGS="-O2 -Wall -Wno-unused-local-typedef $(pkg-config --cflags libndn-cxx)"
11INCLUDEDIR="$(pkg-config --variable=includedir libndn-cxx)"/ndn-cxx
Junxiao Shi316ea712015-01-08 20:46:47 -070012
Davide Pesavento20639522017-06-08 19:34:14 -040013echo "Using: $CXX $STD $CXXFLAGS"
Junxiao Shi316ea712015-01-08 20:46:47 -070014
Junxiao Shi316ea712015-01-08 20:46:47 -070015NCHECKED=0
16NERRORS=0
17while IFS= read -r -d '' H; do
Davide Pesavento20639522017-06-08 19:34:14 -040018 echo "Verifying standalone header compilation for ${H#${INCLUDEDIR}/}"
19 "$CXX" -xc++ $STD $CXXFLAGS -c -o /dev/null "$H"
Junxiao Shi316ea712015-01-08 20:46:47 -070020 [[ $? -eq 0 ]] || ((NERRORS++))
21 ((NCHECKED++))
Davide Pesavento20639522017-06-08 19:34:14 -040022done < <(find "$INCLUDEDIR" -name '*.hpp' -type f -print0 2>/dev/null)
Junxiao Shi316ea712015-01-08 20:46:47 -070023
24if [[ $NCHECKED -eq 0 ]]; then
25 echo 'No header found. Is ndn-cxx installed?'
26 exit 1
Davide Pesavento20639522017-06-08 19:34:14 -040027else
28 echo "$NCHECKED headers checked."
Junxiao Shi316ea712015-01-08 20:46:47 -070029fi
30
31if [[ $NERRORS -gt 0 ]]; then
Davide Pesavento20639522017-06-08 19:34:14 -040032 echo "$NERRORS headers could not be compiled."
Junxiao Shi316ea712015-01-08 20:46:47 -070033 exit 1
34fi