Updated and Validated
[betaflight.git] / make / checks.mk
blob9ec1bd696d6aff71c1e07d9f09febbf28b7b0370
1 checks: check-target-independence \
2 check-fastdata-usage-correctness \
3 check-platform-included \
4 check-unified-target-naming
6 check-target-independence:
7 $(V1) for test_target in $(VALID_TARGETS); do \
8 FOUND=$$(grep -rE "\W$${test_target}(\W.*)?$$" src/main | grep -vE "(//)|(/\*).*\W$${test_target}(\W.*)?$$" | grep -vE "^src/main/target"); \
9 if [ "$${FOUND}" != "" ]; then \
10 echo "Target dependencies for target '$${test_target}' found:"; \
11 echo "$${FOUND}"; \
12 exit 1; \
13 fi; \
14 done
16 check-fastdata-usage-correctness:
17 $(V1) NON_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_DATA_ZERO_INIT\W.*=.*" src/main/ | grep -Ev "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
18 if [ "$${NON_TRIVIALLY_INITIALIZED}" != "" ]; then \
19 echo "Non-trivially initialized FAST_DATA_ZERO_INIT variables found, use FAST_DATA instead:"; \
20 echo "$${NON_TRIVIALLY_INITIALIZED}"; \
21 exit 1; \
22 fi; \
23 TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_DATA\W.*;" src/main/ | grep -v "="); \
24 EXPLICITLY_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_DATA\W.*;" src/main/ | grep -E "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
25 if [ "$${TRIVIALLY_INITIALIZED}$${EXPLICITLY_TRIVIALLY_INITIALIZED}" != "" ]; then \
26 echo "Trivially initialized FAST_DATA variables found, use FAST_DATA_ZERO_INIT instead to save FLASH:"; \
27 echo "$${TRIVIALLY_INITIALIZED}\n$${EXPLICITLY_TRIVIALLY_INITIALIZED}"; \
28 exit 1; \
31 check-platform-included:
32 $(V1) PLATFORM_NOT_INCLUDED=$$(find src/main -type d -name target -prune -o -type f -name \*.c -exec grep -L "^#include \"platform.h\"" {} \;); \
33 if [ "$$(echo $${PLATFORM_NOT_INCLUDED} | grep -v -e '^$$' | wc -l)" -ne 0 ]; then \
34 echo "The following compilation units do not include the required target specific configuration provided by 'platform.h':"; \
35 echo "$${PLATFORM_NOT_INCLUDED}"; \
36 exit 1; \
39 check-unified-target-naming:
40 $(V1) for target_config in unified_targets/configs/*; do \
41 if [ -f $${target_config} ] && [ $$(sed -n 's/board_name \([A-Z]*\)/\1/p' $${target_config}).config != $$(basename $${target_config}) ]; then \
42 echo "Invalid board name ($$(sed -n 's/board_name \([A-Z]*\)/\1/p' $${target_config})) in Unified Target configuration $${target_config}."; \
43 exit 1; \
44 fi; \
45 done