blob: 821ba4c44d74fecd7d770845a533355df4af8a1c [file] [log] [blame]
Davide Pesavento4ad5c462021-11-06 02:58:02 -04001#!/usr/bin/env bash
Davide Pesavento27dd70c2022-08-19 16:24:28 -04002set -eo pipefail
Davide Pesavento4ad5c462021-11-06 02:58:02 -04003# It's intentional not to use `set -x`, because this script explicitly prints useful information
4# and should not run in trace mode.
Davide Pesavento4ad5c462021-11-06 02:58:02 -04005
6PROJ=ndn-nac
Davide Pesavento7e7bd892022-07-10 00:30:06 -04007PCFILE=libndn-nac
Davide Pesavento4ad5c462021-11-06 02:58:02 -04008
9if [[ -n $DISABLE_HEADERS_CHECK ]]; then
10 echo 'Skipping headers check.'
11 exit 0
12fi
13
Davide Pesavento27dd70c2022-08-19 16:24:28 -040014if [[ $ID_LIKE == *fedora* ]]; then
Davide Pesavento4ad5c462021-11-06 02:58:02 -040015 export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
16fi
17
18CXX=${CXX:-g++}
Davide Pesaventobde084f2022-04-17 00:21:35 -040019STD=-std=c++17
Davide Pesavento7e7bd892022-07-10 00:30:06 -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 Pesavento4ad5c462021-11-06 02:58:02 -040022
23echo "Using: $CXX $STD $CXXFLAGS"
24
25NCHECKED=0
26NERRORS=0
27while IFS= read -r -d '' H; do
28 echo "Checking header ${H#${INCLUDEDIR}/}"
Davide Pesavento27dd70c2022-08-19 16:24:28 -040029 "$CXX" -xc++ $STD $CXXFLAGS -c -o /dev/null "$H" || : $((NERRORS++))
30 : $((NCHECKED++))
Davide Pesavento4ad5c462021-11-06 02:58:02 -040031done < <(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