1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-27 07:21:18 +01:00

Merge pull request #11672 from cladmi/pr/buildsystem_sanity_check/add_reasons_in_errors_output

dist/tools/build_system_sanity_check: add reasons for each error type
This commit is contained in:
Juan I Carrano 2019-06-13 17:49:47 +02:00 committed by GitHub
commit 5db31af7a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,24 @@
SCRIPT_PATH=dist/tools/buildsystem_sanity_check/check.sh
tab_indent() {
# Ident using 'bashism' to to the tab compatible with 'bsd-sed'
sed 's/^/\'$'\t/'
}
prepend() {
# 'i' needs 'i\{newline}' and a newline after for 'bsd-sed'
sed '1i\
'"$1"'
'
}
error_with_message() {
tab_indent | prepend "${1}"
}
# Modules should not check the content of FEATURES_PROVIDED/_REQUIRED/OPTIONAL
# Handling specific behaviors/dependencies should by checking the content of:
# * `USEMODULE`
@ -28,6 +46,7 @@ check_not_parsing_features() {
patterns+=(-e 'if.*filter.*FEATURES_PROVIDED')
patterns+=(-e 'if.*filter.*FEATURES_REQUIRED')
patterns+=(-e 'if.*filter.*FEATURES_OPTIONAL')
patterns+=(-e 'if.*filter.*FEATURES_USED') # Not a real one, it is just to show the error
# Pathspec with exclude should start by an inclusive pathspec in git 2.7.4
pathspec+=('*')
@ -38,7 +57,8 @@ check_not_parsing_features() {
# These two files contain sanity checks using FEATURES_ so are allowed
pathspec+=(':!Makefile.include' ':!makefiles/info-global.inc.mk')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}"
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Modules should not check the content of FEATURES_PROVIDED/_REQUIRED/OPTIONAL'
}
# Some variables do not need to be exported and even cause issues when being
@ -59,8 +79,11 @@ UNEXPORTED_VARIABLES+=('DEBUG_ADAPTER' 'DEBUG_ADAPTER_ID')
UNEXPORTED_VARIABLES+=('PROGRAMMER_SERIAL')
UNEXPORTED_VARIABLES+=('STLINK_VERSION')
UNEXPORTED_VARIABLES+=('PORT_LINUX' 'PORT_DARWIN')
UNEXPORTED_VARIABLES+=('APPDEPS')
EXPORTED_VARIABLES_ONLY_IN_VARS=()
EXPORTED_VARIABLES_ONLY_IN_VARS+=('CC')
check_not_exporting_variables() {
local patterns=()
local pathspec=()
@ -69,7 +92,8 @@ check_not_exporting_variables() {
patterns+=(-e "export[[:blank:]]\+${variable}")
done
git -C "${RIOTBASE}" grep "${patterns[@]}"
git -C "${RIOTBASE}" grep "${patterns[@]}" \
| error_with_message 'Variables must not be exported:'
# Some variables may still be exported in 'makefiles/vars.inc.mk' as the
# only place that should export commont variables
@ -83,24 +107,24 @@ check_not_exporting_variables() {
# Only run if there are patterns, otherwise it matches everything
if [ ${#patterns[@]} -ne 0 ]; then
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}"
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Variables must only be exported in `makefiles/vars.inc.mk`:'
fi
}
error_on_input() {
grep '' && return 1
}
all_checks() {
check_not_parsing_features
check_not_exporting_variables
}
main() {
local errors=''
errors+="$(check_not_parsing_features)"
errors+="$(check_not_exporting_variables)"
if [ -n "${errors}" ]
then
printf 'Invalid build system patterns found by %s:\n' "${0}"
printf '%s\n' "${errors}"
exit 1
fi
exit 0
all_checks | prepend 'Invalid build system patterns found by '"${0}:" || error_on_input >&2
exit $?
}