From ef24df7ac09efa2103caf25861d10acbe822d5b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 13 Jun 2019 15:53:58 +0200 Subject: [PATCH 1/4] dist/tools/build_system_sanity_check: add script helper functions Add helper functions to better handle output and errors. --- dist/tools/buildsystem_sanity_check/check.sh | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/dist/tools/buildsystem_sanity_check/check.sh b/dist/tools/buildsystem_sanity_check/check.sh index 9d0a7bbaa8..4fc6ac9152 100755 --- a/dist/tools/buildsystem_sanity_check/check.sh +++ b/dist/tools/buildsystem_sanity_check/check.sh @@ -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` @@ -88,6 +106,10 @@ check_not_exporting_variables() { } +error_on_input() { + grep '' && return 1 +} + main() { local errors='' From 534ccaf5ee955310310b256dbdf40fa37b79917a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 13 Jun 2019 15:55:15 +0200 Subject: [PATCH 2/4] dist/tools/build_system_sanity_check: handle error by prepending Handle putting the final error message by prepending the output. This removes issue with errors being concatenated and gives an interractive output. The errors are now send to stderr. --- dist/tools/buildsystem_sanity_check/check.sh | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/dist/tools/buildsystem_sanity_check/check.sh b/dist/tools/buildsystem_sanity_check/check.sh index 4fc6ac9152..947846c76d 100755 --- a/dist/tools/buildsystem_sanity_check/check.sh +++ b/dist/tools/buildsystem_sanity_check/check.sh @@ -110,19 +110,14 @@ 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 $? } From f37a58618302302dcf10b8e9ea6ca96c2ceed160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 11 Jun 2019 11:57:41 +0200 Subject: [PATCH 3/4] dist/tools/build_system_sanity_check: add reasons for each error type Prepend the reason for the matched error pattern. It will only add the reason if there is an error. --- dist/tools/buildsystem_sanity_check/check.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dist/tools/buildsystem_sanity_check/check.sh b/dist/tools/buildsystem_sanity_check/check.sh index 947846c76d..551b131793 100755 --- a/dist/tools/buildsystem_sanity_check/check.sh +++ b/dist/tools/buildsystem_sanity_check/check.sh @@ -56,7 +56,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 @@ -87,7 +88,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 @@ -101,7 +103,8 @@ 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 } From c7b16bb4b465cda537199c25059c82e776c0b928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 11 Jun 2019 12:20:36 +0200 Subject: [PATCH 4/4] REMOVE ME TEST COMMIT --- dist/tools/buildsystem_sanity_check/check.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dist/tools/buildsystem_sanity_check/check.sh b/dist/tools/buildsystem_sanity_check/check.sh index 551b131793..63952705df 100755 --- a/dist/tools/buildsystem_sanity_check/check.sh +++ b/dist/tools/buildsystem_sanity_check/check.sh @@ -46,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+=('*') @@ -78,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=()