2018-06-24 16:41:58 +02:00
|
|
|
#!/usr/bin/env bash
|
2018-04-02 00:30:17 +02:00
|
|
|
#
|
|
|
|
# Copyright (c) 2018 The Bitcoin Core developers
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#
|
|
|
|
# Check include guards.
|
|
|
|
|
2018-06-18 13:12:07 +02:00
|
|
|
export LC_ALL=C
|
2018-04-02 00:30:17 +02:00
|
|
|
HEADER_ID_PREFIX="BITCOIN_"
|
|
|
|
HEADER_ID_SUFFIX="_H"
|
|
|
|
|
2021-07-12 05:25:27 +02:00
|
|
|
REGEXP_EXCLUDE_FILES_WITH_PREFIX="src/(crypto/ctaes/|leveldb/|secp256k1/|tinyformat.h|bench/nanobench.h|univalue/|ctpl_stl.h|bls/|crypto/sph)"
|
2018-04-02 00:30:17 +02:00
|
|
|
|
|
|
|
EXIT_CODE=0
|
|
|
|
for HEADER_FILE in $(git ls-files -- "*.h" | grep -vE "^${REGEXP_EXCLUDE_FILES_WITH_PREFIX}")
|
|
|
|
do
|
2020-07-19 07:39:57 +02:00
|
|
|
HEADER_ID_BASE=$(cut -f2- -d/ <<< "${HEADER_FILE}" | sed "s/\.h$//g" | tr / _ | tr "[:lower:]" "[:upper:]" | tr - _)
|
2018-04-02 00:30:17 +02:00
|
|
|
HEADER_ID="${HEADER_ID_PREFIX}${HEADER_ID_BASE}${HEADER_ID_SUFFIX}"
|
|
|
|
if [[ $(grep -cE "^#(ifndef|define) ${HEADER_ID}" "${HEADER_FILE}") != 2 ]]; then
|
|
|
|
echo "${HEADER_FILE} seems to be missing the expected include guard:"
|
|
|
|
echo " #ifndef ${HEADER_ID}"
|
|
|
|
echo " #define ${HEADER_ID}"
|
|
|
|
echo " ..."
|
|
|
|
echo " #endif // ${HEADER_ID}"
|
|
|
|
echo
|
|
|
|
EXIT_CODE=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
exit ${EXIT_CODE}
|