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