Fixed Unified Target configuration names, added check for correctness.

This commit is contained in:
mikeller 2019-08-13 21:42:08 +12:00
parent 52173c7981
commit c964eba295
9 changed files with 45 additions and 35 deletions

View File

@ -42,7 +42,7 @@ before_install:
else else
COMMIT_RANGE="$TRAVIS_COMMIT_RANGE" COMMIT_RANGE="$TRAVIS_COMMIT_RANGE"
fi 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." echo "Only files not used in the build process were updated, aborting."
exit exit
} }

View File

@ -79,6 +79,9 @@ include $(ROOT)/make/system-id.mk
# developer preferences, edit these at will, they'll be gitignored # developer preferences, edit these at will, they'll be gitignored
-include $(ROOT)/make/local.mk -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 # configure some directories that are relative to wherever ROOT_DIR is located
ifndef TOOLS_DIR ifndef TOOLS_DIR
TOOLS_DIR := $(ROOT)/tools TOOLS_DIR := $(ROOT)/tools
@ -657,39 +660,6 @@ test_%:
$(V0) cd src/test && $(MAKE) $@ $(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 # rebuild everything when makefile changes
$(TARGET_OBJS): Makefile $(TARGET_DIR)/target.mk $(wildcard make/*) $(TARGET_OBJS): Makefile $(TARGET_DIR)/target.mk $(wildcard make/*)

40
make/checks.mk Normal file
View File

@ -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

View File

@ -1,6 +1,6 @@
# Betaflight / STM32F405 (S405) 4.0.0 Mar 2 2019 / 07:01:01 (29db27584) MSP API: 1.4 # 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 manufacturer_id FFPV
defaults nosave defaults nosave