File: check-headers.sh

package info (click to toggle)
xrootd 5.9.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,956 kB
  • sloc: cpp: 244,425; sh: 2,691; python: 1,980; ansic: 1,027; perl: 814; makefile: 272
file content (39 lines) | stat: -rwxr-xr-x 1,258 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

# This script checks that each installed public and private XRootD header can
# be included individually without errors. The intention is to identify which
# headers may have missing includes, missing forward declarations, or missing
# header dependencies, that is, headers from XRootD which it includes, but were
# not installed by the install target.

# We need to split CXXFLAGS
# shellcheck disable=SC2086

: "${CXX:=c++}"
: "${CXXFLAGS:=-std=c++17 -Wall -Wextra -Wno-unused-parameter}"
: "${INCLUDE_DIR:=${1:-/usr/include/xrootd}}"

if ! command -v "${CXX}" >/dev/null; then
	exit 1
fi

STATUS=0

HEADERS=$(find "${INCLUDE_DIR}" -type f -name '*.hh')
PUBLIC_HEADERS=$(grep -E -v '(XrdPosix|private)' <<< "${HEADERS}")
PRIVATE_HEADERS=$(grep private <<< "${HEADERS}")

# Check public headers without adding private include directory.
# This ensures public headers do not depend on any private headers.

while IFS=$'\n' read -r HEADER; do
	"${CXX}" -fsyntax-only ${CXXFLAGS} -I"${INCLUDE_DIR}" "${HEADER}" || STATUS=1
done <<< "${PUBLIC_HEADERS}"

# Check private headers

while IFS=$'\n' read -r HEADER; do
	"${CXX}" -fsyntax-only ${CXXFLAGS} -I"${INCLUDE_DIR}"{,/private} "${HEADER}" || STATUS=1
done <<< "${PRIVATE_HEADERS}"

exit $STATUS