blob: 861d8c93e55df80fb184e00c87a569917d4744a5 [file] [log] [blame]
Junxiao Shi316ea712015-01-08 20:46:47 -07001#!/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
Davide Pesavento67000442021-12-10 20:01:51 -05008PROJ=ndn-cxx
9PCFILE=libndn-cxx
10
Davide Pesavento97242f72020-02-29 14:28:15 -050011if [[ -n $DISABLE_HEADERS_CHECK ]]; then
12 echo 'Skipping headers check.'
13 exit 0
14fi
15
Davide Pesavento2349e282020-03-24 14:28:03 -040016if has CentOS-8 $NODE_LABELS; then
17 export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
18fi
19
Junxiao Shi316ea712015-01-08 20:46:47 -070020CXX=${CXX:-g++}
Davide Pesavento1fd00242018-05-20 00:11:01 -040021STD=-std=c++14
Davide Pesavento67000442021-12-10 20:01:51 -050022CXXFLAGS="-O2 -Wall -Wno-unneeded-internal-declaration -Wno-unused-const-variable $(pkg-config --cflags libndn-cxx $PCFILE)"
23INCLUDEDIR="$(pkg-config --variable=includedir $PCFILE)"/$PROJ
Junxiao Shi316ea712015-01-08 20:46:47 -070024
Davide Pesavento20639522017-06-08 19:34:14 -040025echo "Using: $CXX $STD $CXXFLAGS"
Junxiao Shi316ea712015-01-08 20:46:47 -070026
Junxiao Shi316ea712015-01-08 20:46:47 -070027NCHECKED=0
28NERRORS=0
29while IFS= read -r -d '' H; do
Davide Pesavento97242f72020-02-29 14:28:15 -050030 echo "Checking header ${H#${INCLUDEDIR}/}"
Davide Pesavento20639522017-06-08 19:34:14 -040031 "$CXX" -xc++ $STD $CXXFLAGS -c -o /dev/null "$H"
Junxiao Shi316ea712015-01-08 20:46:47 -070032 [[ $? -eq 0 ]] || ((NERRORS++))
33 ((NCHECKED++))
Davide Pesavento20639522017-06-08 19:34:14 -040034done < <(find "$INCLUDEDIR" -name '*.hpp' -type f -print0 2>/dev/null)
Junxiao Shi316ea712015-01-08 20:46:47 -070035
36if [[ $NCHECKED -eq 0 ]]; then
Davide Pesavento67000442021-12-10 20:01:51 -050037 echo "No headers found. Is $PROJ installed?"
Junxiao Shi316ea712015-01-08 20:46:47 -070038 exit 1
Davide Pesavento20639522017-06-08 19:34:14 -040039else
40 echo "$NCHECKED headers checked."
Junxiao Shi316ea712015-01-08 20:46:47 -070041fi
42
43if [[ $NERRORS -gt 0 ]]; then
Davide Pesavento20639522017-06-08 19:34:14 -040044 echo "$NERRORS headers could not be compiled."
Junxiao Shi316ea712015-01-08 20:46:47 -070045 exit 1
46fi