-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buildsys: test in CI that we use config.h correctly
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
# | ||
# This script verifies that we are not accidentally using config.h from one of | ||
# our header files. | ||
set -e | ||
|
||
# First scan config.h to obtain a list of all symbols it might define. From | ||
# this is subtracts a list of "known OK" symbols. The symbols and there reason | ||
# for being on this list are: | ||
# - `HAVE_FUNC_ATTRIBUTE_`*: these are only used for optimizations; also, our | ||
# headers try hard to define them on the fly (at least in GCC and clang) | ||
# - `HAVE___BUILTIN_MUL_OVERFLOW`: same as above | ||
# - `SIZEOF_VOID_P`: provided for backwards compatibility in a few packages, | ||
# and actually (re-)defined in `common.h` | ||
# - `SPARC`: only appears in a comment | ||
PATTERN=$(egrep '(#define|#undef)' build/config.h | sed -E -e 's;(#define|/\* #undef) ([^ ]+) .*$;\2;' | egrep -v 'HAVE_FUNC_ATTRIBUTE_|HAVE___BUILTIN_MUL_OVERFLOW|SIZEOF_VOID_P|SPARC' | tr '\n' '|') | ||
PATTERN=${PATTERN%?} # remove trailing "|" | ||
|
||
# Next use `git grep` to search all kernel header files for occurrences of any | ||
# of the symbols in the pattern we just created. We negate the exit code: grep | ||
# exits with exit code 0 if there were hits, and with exit code 1 if there | ||
# were no hits. For our purposes, we want the reverse: no hits is "good". | ||
! git grep -n -P ${PATTERN} :src/*.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters