blob: 958559ec9fc958f94ae8abfccc7b4cb95d76a391 [file] [log] [blame]
Davide Pesaventobb55add2021-02-09 15:12:35 -05001#!/usr/bin/env bash
Davide Pesaventoda1a4d32022-08-19 19:03:24 -04002set -eo pipefail
Davide Pesaventobb55add2021-02-09 15:12:35 -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 Pesaventobb55add2021-02-09 15:12:35 -05005
6PROJ=PSync
Davide Pesaventof2784382022-07-09 19:58:53 -04007PCFILE=PSync
Davide Pesaventobb55add2021-02-09 15:12:35 -05008
9if [[ -n $DISABLE_HEADERS_CHECK ]]; then
10 echo 'Skipping headers check.'
11 exit 0
12fi
13
Davide Pesavento8d6192a2024-02-09 21:23:50 -050014if [[ $ID_LIKE == *linux* && -d /usr/local/lib64/pkgconfig ]]; then
Davide Pesaventobb55add2021-02-09 15:12:35 -050015 export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
16fi
17
18CXX=${CXX:-g++}
Davide Pesaventoc407dee2022-07-21 23:56:05 -040019STD=-std=c++17
Davide Pesaventoac63e322024-01-19 00:30:21 -050020CXXFLAGS="-O2 -Wall -Wno-unknown-warning-option -Wno-enum-constexpr-conversion -Wno-unused-const-variable $(pkg-config --cflags libndn-cxx $PCFILE)"
Davide Pesaventof2784382022-07-09 19:58:53 -040021INCLUDEDIR="$(pkg-config --variable=includedir $PCFILE)"/$PROJ
Davide Pesaventobb55add2021-02-09 15:12:35 -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 Pesaventoda1a4d32022-08-19 19:03:24 -040029 "$CXX" -xc++ $STD $CXXFLAGS -c -o /dev/null "$H" || : $((NERRORS++))
30 : $((NCHECKED++))
Davide Pesaventobb55add2021-02-09 15:12:35 -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