mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
dist/tools/buildsystem_sanity_check: add an export variable check
Check that some variables are not exported in the build system. This should track variables that managed to not be exported anymore so that they do not reappear in a BSP. It is not a whitelist but just a way to keep things cleaned in the future.
This commit is contained in:
parent
9fc9ff2523
commit
42b3cd5903
27
dist/tools/buildsystem_sanity_check/check.sh
vendored
27
dist/tools/buildsystem_sanity_check/check.sh
vendored
@ -41,11 +41,38 @@ check_not_parsing_features() {
|
||||
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}"
|
||||
}
|
||||
|
||||
# Some variables do not need to be exported and even cause issues when being
|
||||
# exported because they are evaluated even when not needed.
|
||||
#
|
||||
# Currently this blacklists exported variables instead of whitelisting or
|
||||
# providing a mechanism for handling it.
|
||||
# It just keep things not exported anymore in the future.
|
||||
UNEXPORTED_VARIABLES=()
|
||||
UNEXPORTED_VARIABLES+=('FLASHFILE')
|
||||
UNEXPORTED_VARIABLES+=('TERMPROG' 'TERMFLAGS')
|
||||
check_not_exporting_variables() {
|
||||
local patterns=()
|
||||
local pathspec=()
|
||||
|
||||
for variable in "${UNEXPORTED_VARIABLES[@]}"; do
|
||||
patterns+=(-e "export[[:blank:]]\+${variable}")
|
||||
done
|
||||
|
||||
pathspec+=('*')
|
||||
|
||||
# Ignore `makefiles/vars.inc.mk` as it currently is the only place that
|
||||
# should export common variables.
|
||||
pathspec+=(':!makefiles/vars.inc.mk')
|
||||
|
||||
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}"
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
local errors=''
|
||||
|
||||
errors+="$(check_not_parsing_features)"
|
||||
errors+="$(check_not_exporting_variables)"
|
||||
|
||||
if [ -n "${errors}" ]
|
||||
then
|
||||
|
Loading…
Reference in New Issue
Block a user