header_check.sh: allow exclusion of common headers

Continuing to address #6305
This commit is contained in:
Scott Kostyshak 2013-05-03 01:41:43 -04:00
parent 8e23cfdbdc
commit 33b0cff2f3

View File

@ -28,6 +28,10 @@ LOG_FILE="$(basename $0).log"
# For all headers: # For all headers:
# PATTERN='^#include' # PATTERN='^#include'
# Exclude common headers with regex
# (e.g. 'debug.h' will exclude 'support/debug.h')
EXCLUDE='\(debug.h\|cstdio\)'
function BUILD_FN () function BUILD_FN ()
{ {
# This is not a clean make. # This is not a clean make.
@ -48,10 +52,12 @@ do
grep "${PATTERN}" "${FILE_}" | \ grep "${PATTERN}" "${FILE_}" | \
while read INCLUDE while read INCLUDE
do do
cp "${FILE_COPY}" "${FILE_}" \ if echo "${INCLUDE}" | grep -q -v "${EXCLUDE}"; then
|| { echo "ERROR: restore copy failed" >&2; exit 1; } cp "${FILE_COPY}" "${FILE_}" \
sed -i "s@${INCLUDE}@@" "${FILE_}" || { echo "ERROR: restore copy failed" >&2; exit 1; }
( BUILD_FN ) &>/dev/null && echo "${FILE_}::${INCLUDE}" >> "${LOG_FILE}" sed -i "s@${INCLUDE}@@" "${FILE_}"
( BUILD_FN ) &>/dev/null && echo "${FILE_}::${INCLUDE}" >> "${LOG_FILE}"
fi
done done
cp "${FILE_COPY}" "${FILE_}" cp "${FILE_COPY}" "${FILE_}"
done done