|
|
|
@ -108,8 +108,6 @@ else
@@ -108,8 +108,6 @@ else
|
|
|
|
|
endif |
|
|
|
|
|
|
|
|
|
# additional config parameters passed to cmake
|
|
|
|
|
CMAKE_ARGS += -Wno-deprecated
|
|
|
|
|
|
|
|
|
|
ifdef EXTERNAL_MODULES_LOCATION |
|
|
|
|
CMAKE_ARGS += -DEXTERNAL_MODULES_LOCATION:STRING=$(EXTERNAL_MODULES_LOCATION)
|
|
|
|
|
endif |
|
|
|
@ -124,7 +122,7 @@ endif
@@ -124,7 +122,7 @@ endif
|
|
|
|
|
define cmake-build |
|
|
|
|
+@$(eval BUILD_DIR = $(SRC_DIR)/build/$@$(BUILD_DIR_SUFFIX)) |
|
|
|
|
+@if [ $(PX4_CMAKE_GENERATOR) = "Ninja" ] && [ -e $(BUILD_DIR)/Makefile ]; then rm -rf $(BUILD_DIR); fi
|
|
|
|
|
+@if [ ! -e $(BUILD_DIR)/CMakeCache.txt ]; then mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(2) -G"$(PX4_CMAKE_GENERATOR)" -DCONFIG=$(1) $(CMAKE_ARGS) || (rm -rf $(BUILD_DIR)); fi
|
|
|
|
|
+@if [ ! -e $(BUILD_DIR)/CMakeCache.txt ]; then mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(2) -G"$(PX4_CMAKE_GENERATOR)" $(CMAKE_ARGS) -DCONFIG=$(1) || (rm -rf $(BUILD_DIR)); fi
|
|
|
|
|
+@(cd $(BUILD_DIR) && $(PX4_MAKE) $(PX4_MAKE_ARGS) $(ARGS)) |
|
|
|
|
endef |
|
|
|
|
|
|
|
|
@ -135,8 +133,8 @@ define colorecho
@@ -135,8 +133,8 @@ define colorecho
|
|
|
|
|
+@echo "${COLOR_BLUE}${1} ${NO_COLOR}" |
|
|
|
|
endef |
|
|
|
|
|
|
|
|
|
# Get a list of all config targets.
|
|
|
|
|
ALL_CONFIG_TARGETS := $(basename $(shell find "$(SRC_DIR)/cmake/configs" ! -name '*_common*' ! -name '*_sdflight_*' -name '*.cmake' -print | sed -e 's:^.*/::' | sort))
|
|
|
|
|
# Get a list of all config targets cmake/configs/*.cmake
|
|
|
|
|
ALL_CONFIG_TARGETS := $(basename $(shell find "$(SRC_DIR)/cmake/configs" -maxdepth 1 ! -name '*_common*' ! -name '*_sdflight_*' -name '*.cmake' -print | sed -e 's:^.*/::' | sort))
|
|
|
|
|
# Strip off leading nuttx_
|
|
|
|
|
NUTTX_CONFIG_TARGETS := $(patsubst nuttx_%,%,$(filter nuttx_%,$(ALL_CONFIG_TARGETS)))
|
|
|
|
|
|
|
|
|
@ -176,11 +174,10 @@ excelsior_legacy_default: posix_excelsior_legacy qurt_excelsior_legacy
@@ -176,11 +174,10 @@ excelsior_legacy_default: posix_excelsior_legacy qurt_excelsior_legacy
|
|
|
|
|
# Other targets
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
.PHONY: qgc_firmware px4fmu_firmware misc_qgc_extra_firmware alt_firmware |
|
|
|
|
.PHONY: sizes check quick_check check_rtps |
|
|
|
|
.PHONY: qgc_firmware px4fmu_firmware misc_qgc_extra_firmware alt_firmware check_rtps |
|
|
|
|
|
|
|
|
|
# QGroundControl flashable NuttX firmware
|
|
|
|
|
qgc_firmware: px4fmu_firmware misc_qgc_extra_firmware sizes |
|
|
|
|
qgc_firmware: px4fmu_firmware misc_qgc_extra_firmware |
|
|
|
|
|
|
|
|
|
# px4fmu NuttX firmware
|
|
|
|
|
px4fmu_firmware: \
|
|
|
|
@ -221,6 +218,8 @@ check_rtps: \
@@ -221,6 +218,8 @@ check_rtps: \
|
|
|
|
|
check_posix_sitl_rtps \
|
|
|
|
|
sizes
|
|
|
|
|
|
|
|
|
|
.PHONY: sizes check quick_check check_rtps |
|
|
|
|
|
|
|
|
|
sizes: |
|
|
|
|
@-find build -name *.elf -type f | xargs size 2> /dev/null || :
|
|
|
|
|
|
|
|
|
@ -228,7 +227,7 @@ sizes:
@@ -228,7 +227,7 @@ sizes:
|
|
|
|
|
check: check_posix_sitl_default px4fmu_firmware misc_qgc_extra_firmware alt_firmware tests check_format |
|
|
|
|
|
|
|
|
|
# quick_check builds a single nuttx and posix target, runs testing, and checks the style
|
|
|
|
|
quick_check: check_posix_sitl_default check_px4fmu-v3_default tests check_format |
|
|
|
|
quick_check: check_posix_sitl_default check_px4fmu-v4pro_default tests check_format |
|
|
|
|
|
|
|
|
|
check_%: |
|
|
|
|
@echo
|
|
|
|
@ -240,8 +239,9 @@ check_%:
@@ -240,8 +239,9 @@ check_%:
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
.PHONY: parameters_metadata airframe_metadata module_documentation px4_metadata |
|
|
|
|
|
|
|
|
|
parameters_metadata: posix_sitl_default |
|
|
|
|
@python $(SRC_DIR)/Tools/px_process_params.py -s $(SRC_DIR)/src --markdown
|
|
|
|
|
parameters_metadata: |
|
|
|
|
@python $(SRC_DIR)/Tools/px_process_params.py -s `find $(SRC_DIR)/src -maxdepth 3 -type d` --inject-xml $(SRC_DIR)/Tools/parameters_injected.xml --markdown
|
|
|
|
|
@python $(SRC_DIR)/Tools/px_process_params.py -s `find $(SRC_DIR)/src -maxdepth 3 -type d` --inject-xml $(SRC_DIR)/Tools/parameters_injected.xml --xml
|
|
|
|
|
|
|
|
|
|
airframe_metadata: |
|
|
|
|
@python $(SRC_DIR)/Tools/px_process_airframes.py -v -a $(SRC_DIR)/ROMFS/px4fmu_common/init.d --markdown
|
|
|
|
@ -260,13 +260,6 @@ px4_metadata: parameters_metadata airframe_metadata module_documentation
@@ -260,13 +260,6 @@ px4_metadata: parameters_metadata airframe_metadata module_documentation
|
|
|
|
|
# AWS_S3_BUCKET
|
|
|
|
|
.PHONY: s3put_firmware s3put_qgc_firmware s3put_px4fmu_firmware s3put_misc_qgc_extra_firmware s3put_metadata s3put_scan-build s3put_cppcheck s3put_coverage |
|
|
|
|
|
|
|
|
|
Firmware.zip: |
|
|
|
|
@rm -rf Firmware.zip
|
|
|
|
|
@zip --junk-paths Firmware.zip `find . -name \*.px4`
|
|
|
|
|
|
|
|
|
|
s3put_firmware: Firmware.zip |
|
|
|
|
$(SRC_DIR)/Tools/s3put.sh Firmware.zip
|
|
|
|
|
|
|
|
|
|
s3put_qgc_firmware: s3put_px4fmu_firmware s3put_misc_qgc_extra_firmware |
|
|
|
|
|
|
|
|
|
s3put_px4fmu_firmware: px4fmu_firmware |
|
|
|
@ -278,17 +271,17 @@ s3put_misc_qgc_extra_firmware: misc_qgc_extra_firmware
@@ -278,17 +271,17 @@ s3put_misc_qgc_extra_firmware: misc_qgc_extra_firmware
|
|
|
|
|
s3put_metadata: px4_metadata |
|
|
|
|
@$(SRC_DIR)/Tools/s3put.sh airframes.md
|
|
|
|
|
@$(SRC_DIR)/Tools/s3put.sh airframes.xml
|
|
|
|
|
@$(SRC_DIR)/Tools/s3put.sh build/posix_sitl_default/parameters.xml
|
|
|
|
|
@$(SRC_DIR)/Tools/s3put.sh parameters.xml
|
|
|
|
|
@$(SRC_DIR)/Tools/s3put.sh parameters.md
|
|
|
|
|
|
|
|
|
|
s3put_scan-build: scan-build |
|
|
|
|
@cd $(SRC_DIR) && ./Tools/s3put.sh `find build/scan-build -mindepth 1 -maxdepth 1 -type d`/
|
|
|
|
|
@$(SRC_DIR)/Tools/s3put.sh `find $(SRC_DIR)/build/scan-build -mindepth 1 -maxdepth 1 -type d`/
|
|
|
|
|
|
|
|
|
|
s3put_cppcheck: cppcheck |
|
|
|
|
@cd $(SRC_DIR) && ./Tools/s3put.sh cppcheck/
|
|
|
|
|
@$(SRC_DIR)/Tools/s3put.sh $(SRC_DIR)/build/cppcheck/
|
|
|
|
|
|
|
|
|
|
s3put_coverage: tests_coverage |
|
|
|
|
@cd $(SRC_DIR) && ./Tools/s3put.sh build/posix_sitl_default/coverage-html/
|
|
|
|
|
@$(SRC_DIR)/Tools/s3put.sh $(SRC_DIR)/build/posix_sitl_default/coverage-html/
|
|
|
|
|
|
|
|
|
|
# Astyle
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
@ -297,7 +290,7 @@ s3put_coverage: tests_coverage
@@ -297,7 +290,7 @@ s3put_coverage: tests_coverage
|
|
|
|
|
check_format: |
|
|
|
|
$(call colorecho,"Checking formatting with astyle")
|
|
|
|
|
@$(SRC_DIR)/Tools/astyle/check_code_style_all.sh
|
|
|
|
|
@git diff --check
|
|
|
|
|
@cd $(SRC_DIR) && git diff --check
|
|
|
|
|
|
|
|
|
|
format: |
|
|
|
|
$(call colorecho,"Formatting with astyle")
|
|
|
|
@ -308,19 +301,17 @@ format:
@@ -308,19 +301,17 @@ format:
|
|
|
|
|
.PHONY: tests tests_coverage |
|
|
|
|
|
|
|
|
|
tests: |
|
|
|
|
$(MAKE) --no-print-directory posix_sitl_default test_results ASAN_OPTIONS="color=always"
|
|
|
|
|
@$(MAKE) --no-print-directory posix_sitl_default test_results \
|
|
|
|
|
ASAN_OPTIONS="color=always:check_initialization_order=1:detect_stack_use_after_return=1" \
|
|
|
|
|
UBSAN_OPTIONS="color=always"
|
|
|
|
|
|
|
|
|
|
tests_coverage: |
|
|
|
|
@$(MAKE) --no-print-directory posix_sitl_default test_coverage_genhtml PX4_CMAKE_BUILD_TYPE=Coverage
|
|
|
|
|
@echo "Open $(SRC_DIR)/build/posix_sitl_default/coverage-html/index.html to see coverage"
|
|
|
|
|
|
|
|
|
|
# static analyzers (scan-build, clang-tidy, cppcheck)
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
.PHONY: posix_sitl_default-clang scan-build clang-tidy clang-tidy-fix clang-tidy-quiet cppcheck check_stack |
|
|
|
|
|
|
|
|
|
posix_sitl_default-clang: |
|
|
|
|
@mkdir -p $(SRC_DIR)/build/posix_sitl_default-clang
|
|
|
|
|
@cd $(SRC_DIR)/build/posix_sitl_default-clang && cmake $(SRC_DIR) -GNinja -DCONFIG=posix_sitl_default -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
|
|
|
|
|
@cd $(SRC_DIR)/build/posix_sitl_default-clang && ninja
|
|
|
|
|
.PHONY: scan-build posix_sitl_default-clang clang-tidy clang-tidy-fix clang-tidy-quiet cppcheck check_stack |
|
|
|
|
|
|
|
|
|
scan-build: |
|
|
|
|
@export CCC_CC=clang
|
|
|
|
@ -329,32 +320,38 @@ scan-build:
@@ -329,32 +320,38 @@ scan-build:
|
|
|
|
|
@cd $(SRC_DIR)/build/posix_sitl_default-scan-build && scan-build cmake $(SRC_DIR) -GNinja -DCONFIG=posix_sitl_default
|
|
|
|
|
@scan-build -o $(SRC_DIR)/build/scan-build cmake --build $(SRC_DIR)/build/posix_sitl_default-scan-build
|
|
|
|
|
|
|
|
|
|
posix_sitl_default-clang: |
|
|
|
|
@mkdir -p $(SRC_DIR)/build/posix_sitl_default-clang
|
|
|
|
|
@cd $(SRC_DIR)/build/posix_sitl_default-clang && cmake $(SRC_DIR) $(CMAKE_ARGS) -G"$(PX4_CMAKE_GENERATOR)" -DCONFIG=posix_sitl_default -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
|
|
|
|
|
@$(PX4_MAKE) -C $(SRC_DIR)/build/posix_sitl_default-clang
|
|
|
|
|
|
|
|
|
|
clang-tidy: posix_sitl_default-clang |
|
|
|
|
@cd build/posix_sitl_default-clang && run-clang-tidy-4.0.py -header-filter=".*\.hpp" -j$(j) -p .
|
|
|
|
|
@cd $(SRC_DIR)/build/posix_sitl_default-clang && run-clang-tidy-4.0.py -header-filter=".*\.hpp" -j$(j) -p .
|
|
|
|
|
|
|
|
|
|
# to automatically fix a single check at a time, eg modernize-redundant-void-arg
|
|
|
|
|
# % run-clang-tidy-4.0.py -fix -j4 -checks=-\*,modernize-redundant-void-arg -p .
|
|
|
|
|
clang-tidy-fix: posix_sitl_default-clang |
|
|
|
|
@cd build/posix_sitl_default-clang && run-clang-tidy-4.0.py -header-filter=".*\.hpp" -j$(j) -fix -p .
|
|
|
|
|
@cd $(SRC_DIR)/build/posix_sitl_default-clang && run-clang-tidy-4.0.py -header-filter=".*\.hpp" -j$(j) -fix -p .
|
|
|
|
|
|
|
|
|
|
# modified version of run-clang-tidy.py to return error codes and only output relevant results
|
|
|
|
|
clang-tidy-quiet: posix_sitl_default-clang |
|
|
|
|
@cd build/posix_sitl_default-clang && $(SRC_DIR)/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j) -p .
|
|
|
|
|
@cd $(SRC_DIR)/build/posix_sitl_default-clang && $(SRC_DIR)/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j) -p .
|
|
|
|
|
|
|
|
|
|
# TODO: Fix cppcheck errors then try --enable=warning,performance,portability,style,unusedFunction or --enable=all
|
|
|
|
|
cppcheck: posix_sitl_default |
|
|
|
|
@cppcheck -i$(SRC_DIR)/src/examples --std=c++11 --std=c99 --std=posix --project=build/posix_sitl_default/compile_commands.json --xml-version=2 2> cppcheck-result.xml
|
|
|
|
|
@cppcheck-htmlreport --source-encoding=ascii --file=cppcheck-result.xml --report-dir=cppcheck --source-dir=$(SRC_DIR)/src/
|
|
|
|
|
@mkdir -p $(SRC_DIR)/build/cppcheck
|
|
|
|
|
@cppcheck -i$(SRC_DIR)/src/examples --enable=performance --std=c++11 --std=c99 --std=posix --project=$(SRC_DIR)/build/posix_sitl_default/compile_commands.json --xml-version=2 2> $(SRC_DIR)/build/cppcheck/cppcheck-result.xml > /dev/null
|
|
|
|
|
@cppcheck-htmlreport --source-encoding=ascii --file=$(SRC_DIR)/build/cppcheck/cppcheck-result.xml --report-dir=$(SRC_DIR)/build/cppcheck --source-dir=$(SRC_DIR)/src/
|
|
|
|
|
|
|
|
|
|
check_stack: px4fmu-v3_default |
|
|
|
|
check_stack: px4fmu-v4pro_default |
|
|
|
|
@echo "Checking worst case stack usage with checkstack.pl ..."
|
|
|
|
|
@echo " "
|
|
|
|
|
@echo "Top 10:"
|
|
|
|
|
@cd build/px4fmu-v3_default/ && mkdir -p stack_usage && arm-none-eabi-objdump -d nuttx_px4fmu-v3_default.elf | $(SRC_DIR)/Tools/stack_usage/checkstack.pl arm 0 > stack_usage/checkstack_output.txt 2> stack_usage/checkstack_errors.txt
|
|
|
|
|
@head -n 10 build/px4fmu-v3_default/stack_usage/checkstack_output.txt | c++filt
|
|
|
|
|
@cd $(SRC_DIR)/build/px4fmu-v4pro_default && mkdir -p stack_usage && arm-none-eabi-objdump -d nuttx_px4fmu-v4pro_default.elf | $(SRC_DIR)/Tools/stack_usage/checkstack.pl arm 0 > stack_usage/checkstack_output.txt 2> stack_usage/checkstack_errors.txt
|
|
|
|
|
@head -n 10 $(SRC_DIR)/build/px4fmu-v4pro_default/stack_usage/checkstack_output.txt | c++filt
|
|
|
|
|
@echo " "
|
|
|
|
|
@echo "Symbols with 'main', 'thread' or 'task':"
|
|
|
|
|
@cat build/px4fmu-v3_default/stack_usage/checkstack_output.txt | c++filt | grep -E 'thread|main|task'
|
|
|
|
|
@cat $(SRC_DIR)/build/px4fmu-v4pro_default/stack_usage/checkstack_output.txt | c++filt | grep -E 'thread|main|task'
|
|
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
@ -387,8 +384,6 @@ distclean: submodulesclean gazeboclean
@@ -387,8 +384,6 @@ distclean: submodulesclean gazeboclean
|
|
|
|
|
$(if $(filter $(FIRST_ARG),$@), \
|
|
|
|
|
$(error "$@ cannot be the first argument. Use '$(MAKE) help|list_config_targets' to get a list of all possible [configuration] targets."),@#)
|
|
|
|
|
|
|
|
|
|
CONFIGS:=$(shell ls cmake/configs | sed -e "s~.*/~~" | sed -e "s~\..*~~")
|
|
|
|
|
|
|
|
|
|
#help:
|
|
|
|
|
# @echo
|
|
|
|
|
# @echo "Type 'make ' and hit the tab key twice to see a list of the available"
|
|
|
|
|