Skip to content

Commit d41dfe9

Browse files
committed
[Post-install] Add a script to check that headers are valid.
Add a script that checks all installed headers for syntax errors. This tests if they can be included standalone.
1 parent 47126da commit d41dfe9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/PostInstall/check-headers.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Adapted from the XRootD project with friendly permission from G. Amadio.
4+
#
5+
# This script checks that each installed ROOT header can be included individually
6+
# without errors. The intention is to identify which headers may have missing
7+
# includes, missing forward declarations, or missing header dependencies, that is,
8+
# headers from ROOT which it includes, but were not installed by the install target.
9+
10+
# We need to split CXXFLAGS
11+
# shellcheck disable=SC2086
12+
13+
: "${CXX:=c++}"
14+
: "${CXXFLAGS:=-std=c++17 -Wall -Wextra -Wno-unused-parameter -Wno-unused-const-variable}"
15+
: "${INCLUDE_DIR:=${1}}"
16+
: "${NCPU:=$(sysctl -n hw.ncpu 2>/dev/null)}"
17+
: "${NCPU:=$(nproc --all 2>/dev/null)}"
18+
19+
if ! command -v "${CXX}" >/dev/null; then
20+
echo "Please set CXX to a valid compiler"
21+
exit 2
22+
fi
23+
if [ ! -d "${INCLUDE_DIR}" ]; then
24+
echo "Usage: ${0} <ROOT include directory>"
25+
echo "Alternatively, set INCLUDE_DIR in the environment"
26+
exit 2
27+
fi
28+
29+
30+
# Check all installed headers for include errors.
31+
HEADERS=$(find "${INCLUDE_DIR}" -type f -name '*.h*')
32+
33+
xargs -P ${NCPU:-1} -n 1 "${CXX}" -fsyntax-only -x c++ ${CXXFLAGS} -I"${INCLUDE_DIR}" <<< "${HEADERS}" || exit 1
34+

0 commit comments

Comments
 (0)