blob: 88c0003ab1b2b553ae602992fa0436cfceef1afb [file] [log] [blame]
Davide Pesavento780e6462021-02-08 20:58:12 -05001#!/usr/bin/env bash
Davide Pesavento15a74422022-08-19 15:48:45 -04002set -eo pipefail
Davide Pesavento780e6462021-02-08 20:58:12 -05003# It's intentional not to use `set -x`, because this script explicitly prints useful information
4# and should not run in trace mode.
Davide Pesavento780e6462021-02-08 20:58:12 -05005
6PROJ=ChronoSync
Davide Pesavento9c4bd6d2022-07-26 15:28:08 -04007PCFILE=ChronoSync
Davide Pesavento780e6462021-02-08 20:58:12 -05008
9if [[ -n $DISABLE_HEADERS_CHECK ]]; then
10 echo 'Skipping headers check.'
11 exit 0
12fi
13
Davide Pesavento15a74422022-08-19 15:48:45 -040014if [[ $ID_LIKE == *fedora* ]]; then
Davide Pesavento780e6462021-02-08 20:58:12 -050015 export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
16fi
17
18CXX=${CXX:-g++}
Davide Pesavento8663ed12022-07-23 03:04:27 -040019STD=-std=c++17
Davide Pesavento9c4bd6d2022-07-26 15:28:08 -040020CXXFLAGS="-O2 -Wall -Wno-unneeded-internal-declaration -Wno-unused-const-variable $(pkg-config --cflags libndn-cxx $PCFILE)"
21INCLUDEDIR="$(pkg-config --variable=includedir $PCFILE)"/$PROJ
Davide Pesavento780e6462021-02-08 20:58:12 -050022
23echo "Using: $CXX $STD $CXXFLAGS"
24
25NCHECKED=0
26NERRORS=0
27while IFS= read -r -d '' H; do
28 echo "Checking header ${H#${INCLUDEDIR}/}"
Davide Pesavento15a74422022-08-19 15:48:45 -040029 "$CXX" -xc++ $STD $CXXFLAGS -c -o /dev/null "$H" || : $((NERRORS++))
30 : $((NCHECKED++))
Davide Pesavento780e6462021-02-08 20:58:12 -050031done < <(find "$INCLUDEDIR" -name '*.hpp' -type f -print0 2>/dev/null)
32
33if [[ $NCHECKED -eq 0 ]]; then
34 echo "No headers found. Is $PROJ installed?"
35 exit 1
36else
37 echo "$NCHECKED headers checked."
38fi
39
40if [[ $NERRORS -gt 0 ]]; then
41 echo "$NERRORS headers could not be compiled."
42 exit 1
43fi