diff --git a/.travis.yml b/.travis.yml index 1baa15aba..c38a0891e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,7 +42,7 @@ before_install: else COMMIT_RANGE="$TRAVIS_COMMIT_RANGE" fi - git diff --name-only $COMMIT_RANGE | grep -qvE '(\.md$)|(^(docs|support|unified_targets))/' || { + git diff --name-only $COMMIT_RANGE | grep -qvE '(\.md$)|(^(docs|support))/' || { echo "Only files not used in the build process were updated, aborting." exit } diff --git a/Makefile b/Makefile index ef918702a..1547cec74 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,9 @@ include $(ROOT)/make/system-id.mk # developer preferences, edit these at will, they'll be gitignored -include $(ROOT)/make/local.mk +# pre-build sanity checks +include $(ROOT)/make/checks.mk + # configure some directories that are relative to wherever ROOT_DIR is located ifndef TOOLS_DIR TOOLS_DIR := $(ROOT)/tools @@ -657,39 +660,6 @@ test_%: $(V0) cd src/test && $(MAKE) $@ -check-target-independence: - $(V1) for test_target in $(VALID_TARGETS); do \ - FOUND=$$(grep -rE "\W$${test_target}(\W.*)?$$" src/main | grep -vE "(//)|(/\*).*\W$${test_target}(\W.*)?$$" | grep -vE "^src/main/target"); \ - if [ "$${FOUND}" != "" ]; then \ - echo "Target dependencies for target '$${test_target}' found:"; \ - echo "$${FOUND}"; \ - exit 1; \ - fi; \ - done - -check-fastram-usage-correctness: - $(V1) NON_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM_ZERO_INIT\W.*=.*" src/main/ | grep -Ev "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \ - if [ "$${NON_TRIVIALLY_INITIALIZED}" != "" ]; then \ - echo "Non-trivially initialized FAST_RAM_ZERO_INIT variables found, use FAST_RAM instead:"; \ - echo "$${NON_TRIVIALLY_INITIALIZED}"; \ - exit 1; \ - fi; \ - TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM\W.*;" src/main/ | grep -v "="); \ - EXPLICITLY_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM\W.*;" src/main/ | grep -E "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \ - if [ "$${TRIVIALLY_INITIALIZED}$${EXPLICITLY_TRIVIALLY_INITIALIZED}" != "" ]; then \ - echo "Trivially initialized FAST_RAM variables found, use FAST_RAM_ZERO_INIT instead to save FLASH:"; \ - echo "$${TRIVIALLY_INITIALIZED}\n$${EXPLICITLY_TRIVIALLY_INITIALIZED}"; \ - exit 1; \ - fi - -check-platform-included: - $(V1) PLATFORM_NOT_INCLUDED=$$(find src/main -type d -name target -prune -o -type f -name \*.c -exec grep -L "^#include \"platform.h\"" {} \;); \ - if [ "$$(echo $${PLATFORM_NOT_INCLUDED} | grep -v -e '^$$' | wc -l)" -ne 0 ]; then \ - echo "The following compilation units do not include the required target specific configuration provided by 'platform.h':"; \ - echo "$${PLATFORM_NOT_INCLUDED}"; \ - exit 1; \ - fi - # rebuild everything when makefile changes $(TARGET_OBJS): Makefile $(TARGET_DIR)/target.mk $(wildcard make/*) diff --git a/make/checks.mk b/make/checks.mk new file mode 100644 index 000000000..5cedecc93 --- /dev/null +++ b/make/checks.mk @@ -0,0 +1,40 @@ +check-target-independence: + $(V1) for test_target in $(VALID_TARGETS); do \ + FOUND=$$(grep -rE "\W$${test_target}(\W.*)?$$" src/main | grep -vE "(//)|(/\*).*\W$${test_target}(\W.*)?$$" | grep -vE "^src/main/target"); \ + if [ "$${FOUND}" != "" ]; then \ + echo "Target dependencies for target '$${test_target}' found:"; \ + echo "$${FOUND}"; \ + exit 1; \ + fi; \ + done + +check-fastram-usage-correctness: + $(V1) NON_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM_ZERO_INIT\W.*=.*" src/main/ | grep -Ev "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \ + if [ "$${NON_TRIVIALLY_INITIALIZED}" != "" ]; then \ + echo "Non-trivially initialized FAST_RAM_ZERO_INIT variables found, use FAST_RAM instead:"; \ + echo "$${NON_TRIVIALLY_INITIALIZED}"; \ + exit 1; \ + fi; \ + TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM\W.*;" src/main/ | grep -v "="); \ + EXPLICITLY_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM\W.*;" src/main/ | grep -E "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \ + if [ "$${TRIVIALLY_INITIALIZED}$${EXPLICITLY_TRIVIALLY_INITIALIZED}" != "" ]; then \ + echo "Trivially initialized FAST_RAM variables found, use FAST_RAM_ZERO_INIT instead to save FLASH:"; \ + echo "$${TRIVIALLY_INITIALIZED}\n$${EXPLICITLY_TRIVIALLY_INITIALIZED}"; \ + exit 1; \ + fi + +check-platform-included: + $(V1) PLATFORM_NOT_INCLUDED=$$(find src/main -type d -name target -prune -o -type f -name \*.c -exec grep -L "^#include \"platform.h\"" {} \;); \ + if [ "$$(echo $${PLATFORM_NOT_INCLUDED} | grep -v -e '^$$' | wc -l)" -ne 0 ]; then \ + echo "The following compilation units do not include the required target specific configuration provided by 'platform.h':"; \ + echo "$${PLATFORM_NOT_INCLUDED}"; \ + exit 1; \ + fi + +check-unified-target-naming: + $(V1) for target_config in unified_targets/configs/*; do \ + if [ $$(sed -n 's/board_name \([A-Z]*\)/\1/p' $${target_config}).config != $$(basename $${target_config}) ]; then \ + echo "Invalid board name ($$(sed -n 's/board_name \([A-Z]*\)/\1/p' $${target_config})) in Unified Target configuration $${target_config}."; \ + exit 1; \ + fi; \ + done diff --git a/unified_targets/configs/ALIENFLIGHTNGF7_Dual.config b/unified_targets/configs/ALIENFLIGHTNGF7_DUAL.config similarity index 100% rename from unified_targets/configs/ALIENFLIGHTNGF7_Dual.config rename to unified_targets/configs/ALIENFLIGHTNGF7_DUAL.config diff --git a/unified_targets/configs/FF_RACEPIT_mini.config b/unified_targets/configs/FF_RACEPIT_MINI.config similarity index 98% rename from unified_targets/configs/FF_RACEPIT_mini.config rename to unified_targets/configs/FF_RACEPIT_MINI.config index 6b169b0e8..f6284b9b4 100644 --- a/unified_targets/configs/FF_RACEPIT_mini.config +++ b/unified_targets/configs/FF_RACEPIT_MINI.config @@ -1,6 +1,6 @@ # Betaflight / STM32F405 (S405) 4.0.0 Mar 2 2019 / 07:01:01 (29db27584) MSP API: 1.4 -board_name FF_RACEPIT +board_name FF_RACEPIT_MINI manufacturer_id FFPV defaults nosave diff --git a/unified_targets/configs/IFLIGHT_F411_PRO.config b/unified_targets/configs/IFF411_PRO.config similarity index 100% rename from unified_targets/configs/IFLIGHT_F411_PRO.config rename to unified_targets/configs/IFF411_PRO.config diff --git a/unified_targets/configs/IFLIGHT_F411_TWING.config b/unified_targets/configs/IFF411_TWING.config similarity index 100% rename from unified_targets/configs/IFLIGHT_F411_TWING.config rename to unified_targets/configs/IFF411_TWING.config diff --git a/unified_targets/configs/IFLIGHTF4_TWIN_G.config b/unified_targets/configs/IFF4_TWIN_G.config similarity index 100% rename from unified_targets/configs/IFLIGHTF4_TWIN_G.config rename to unified_targets/configs/IFF4_TWIN_G.config diff --git a/unified_targets/configs/IFLIGHTF7_TWIN_G.config b/unified_targets/configs/IFF7_TWIN_G.config similarity index 100% rename from unified_targets/configs/IFLIGHTF7_TWIN_G.config rename to unified_targets/configs/IFF7_TWIN_G.config