blob: da13efa12d3e3a1973d90958a48a1ed4f53da774 [file] [log] [blame]
Davide Pesaventobb55add2021-02-09 15:12:35 -05001#!/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
8PROJ=PSync
Davide Pesaventof2784382022-07-09 19:58:53 -04009PCFILE=PSync
Davide Pesaventobb55add2021-02-09 15:12:35 -050010
11if [[ -n $DISABLE_HEADERS_CHECK ]]; then
12 echo 'Skipping headers check.'
13 exit 0
14fi
15
Davide Pesaventof2784382022-07-09 19:58:53 -040016if has CentOS $NODE_LABELS; then
Davide Pesaventobb55add2021-02-09 15:12:35 -050017 export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
18fi
19
20CXX=${CXX:-g++}
21STD=-std=c++14
Davide Pesaventof2784382022-07-09 19:58:53 -040022CXXFLAGS="-O2 -Wall -Wno-unneeded-internal-declaration -Wno-unused-const-variable $(pkg-config --cflags libndn-cxx $PCFILE)"
23INCLUDEDIR="$(pkg-config --variable=includedir $PCFILE)"/$PROJ
Davide Pesaventobb55add2021-02-09 15:12:35 -050024
25echo "Using: $CXX $STD $CXXFLAGS"
26
27NCHECKED=0
28NERRORS=0
29while IFS= read -r -d '' H; do
30 echo "Checking header ${H#${INCLUDEDIR}/}"
31 "$CXX" -xc++ $STD $CXXFLAGS -c -o /dev/null "$H"
32 [[ $? -eq 0 ]] || ((NERRORS++))
33 ((NCHECKED++))
34done < <(find "$INCLUDEDIR" -name '*.hpp' -type f -print0 2>/dev/null)
35
36if [[ $NCHECKED -eq 0 ]]; then
37 echo "No headers found. Is $PROJ installed?"
38 exit 1
39else
40 echo "$NCHECKED headers checked."
41fi
42
43if [[ $NERRORS -gt 0 ]]; then
44 echo "$NERRORS headers could not be compiled."
45 exit 1
46fi