blob: 8ee3339219a5d8642a70e7b8053424d077204e71 [file] [log] [blame]
Junxiao Shi316ea712015-01-08 20:46:47 -07001#!/usr/bin/env bash
Davide Pesavento73e946e2022-08-06 16:44:54 -04002set -eo pipefail
Junxiao Shi316ea712015-01-08 20:46:47 -07003# It's intentional not to use `set -x`, because this script explicitly prints useful information
4# and should not run in trace mode.
Junxiao Shi316ea712015-01-08 20:46:47 -07005
Davide Pesavento67000442021-12-10 20:01:51 -05006PROJ=ndn-cxx
7PCFILE=libndn-cxx
8
Davide Pesavento97242f72020-02-29 14:28:15 -05009if [[ -n $DISABLE_HEADERS_CHECK ]]; then
10 echo 'Skipping headers check.'
11 exit 0
12fi
13
Davide Pesavento73e946e2022-08-06 16:44:54 -040014if [[ $ID_LIKE == *fedora* ]]; then
Davide Pesavento2349e282020-03-24 14:28:03 -040015 export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
16fi
17
Junxiao Shi316ea712015-01-08 20:46:47 -070018CXX=${CXX:-g++}
Davide Pesavento1fd00242018-05-20 00:11:01 -040019STD=-std=c++14
Davide Pesavento67000442021-12-10 20:01:51 -050020CXXFLAGS="-O2 -Wall -Wno-unneeded-internal-declaration -Wno-unused-const-variable $(pkg-config --cflags libndn-cxx $PCFILE)"
21INCLUDEDIR="$(pkg-config --variable=includedir $PCFILE)"/$PROJ
Junxiao Shi316ea712015-01-08 20:46:47 -070022
Davide Pesavento20639522017-06-08 19:34:14 -040023echo "Using: $CXX $STD $CXXFLAGS"
Junxiao Shi316ea712015-01-08 20:46:47 -070024
Junxiao Shi316ea712015-01-08 20:46:47 -070025NCHECKED=0
26NERRORS=0
27while IFS= read -r -d '' H; do
Davide Pesavento97242f72020-02-29 14:28:15 -050028 echo "Checking header ${H#${INCLUDEDIR}/}"
Davide Pesavento73e946e2022-08-06 16:44:54 -040029 "$CXX" -xc++ $STD $CXXFLAGS -c -o /dev/null "$H" || : $((NERRORS++))
30 : $((NCHECKED++))
Davide Pesavento20639522017-06-08 19:34:14 -040031done < <(find "$INCLUDEDIR" -name '*.hpp' -type f -print0 2>/dev/null)
Junxiao Shi316ea712015-01-08 20:46:47 -070032
33if [[ $NCHECKED -eq 0 ]]; then
Davide Pesavento67000442021-12-10 20:01:51 -050034 echo "No headers found. Is $PROJ installed?"
Junxiao Shi316ea712015-01-08 20:46:47 -070035 exit 1
Davide Pesavento20639522017-06-08 19:34:14 -040036else
37 echo "$NCHECKED headers checked."
Junxiao Shi316ea712015-01-08 20:46:47 -070038fi
39
40if [[ $NERRORS -gt 0 ]]; then
Davide Pesavento20639522017-06-08 19:34:14 -040041 echo "$NERRORS headers could not be compiled."
Junxiao Shi316ea712015-01-08 20:46:47 -070042 exit 1
43fi