cmake consistency with build directory and and nuttx binary naming

This commit is contained in:
Daniel Agar
2018-06-11 14:30:39 -04:00
committed by Julian Oes
parent 0430520371
commit 4d3ad1b5c3
2 changed files with 11 additions and 7 deletions
+6 -5
View File
@@ -120,10 +120,11 @@ endif
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# describe how to build a cmake config # describe how to build a cmake config
define cmake-build define cmake-build
+@$(eval BUILD_DIR = $(SRC_DIR)/build/$@$(BUILD_DIR_SUFFIX)) +@$(eval PX4_CONFIG = $(1))
+@$(eval BUILD_DIR = $(SRC_DIR)/build/$(PX4_CONFIG)$(BUILD_DIR_SUFFIX))
+@if [ $(PX4_CMAKE_GENERATOR) = "Ninja" ] && [ -e $(BUILD_DIR)/Makefile ]; then rm -rf $(BUILD_DIR); fi +@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)" $(CMAKE_ARGS) -DCONFIG=$(1) || (rm -rf $(BUILD_DIR)); fi +@if [ ! -e $(BUILD_DIR)/CMakeCache.txt ]; then mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(SRC_DIR) -G"$(PX4_CMAKE_GENERATOR)" $(CMAKE_ARGS) -DCONFIG=$(PX4_CONFIG) || (rm -rf $(BUILD_DIR)); fi
+@(cd $(BUILD_DIR) && $(PX4_MAKE) $(PX4_MAKE_ARGS) $(ARGS)) +@$(PX4_MAKE) -C $(BUILD_DIR) $(PX4_MAKE_ARGS) $(ARGS)
endef endef
COLOR_BLUE = \033[0;94m COLOR_BLUE = \033[0;94m
@@ -144,13 +145,13 @@ NUTTX_CONFIG_TARGETS := $(patsubst nuttx_%,%,$(filter nuttx_%,$(ALL_CONFIG_TARGE
# All targets. # All targets.
$(ALL_CONFIG_TARGETS): $(ALL_CONFIG_TARGETS):
$(call cmake-build,$@,$(SRC_DIR)) $(call cmake-build,$@)
# Abbreviated config targets. # Abbreviated config targets.
# nuttx_ is left off by default; provide a rule to allow that. # nuttx_ is left off by default; provide a rule to allow that.
$(NUTTX_CONFIG_TARGETS): $(NUTTX_CONFIG_TARGETS):
$(call cmake-build,nuttx_$@,$(SRC_DIR)) $(call cmake-build,nuttx_$@)
all_nuttx_targets: $(NUTTX_CONFIG_TARGETS) all_nuttx_targets: $(NUTTX_CONFIG_TARGETS)
+5 -2
View File
@@ -115,9 +115,12 @@ if (config_romfs_root)
endif() endif()
# create px4 file (combined firmware and metadata) # create px4 file (combined firmware and metadata)
# for historical reasons we name the final output binary without nuttx_
set(fw_name_short)
string(REPLACE "nuttx_" "" fw_name_short ${FW_NAME})
set(fw_file ${PX4_BINARY_DIR}/${FW_NAME}) set(fw_file ${PX4_BINARY_DIR}/${FW_NAME})
string(REPLACE ".elf" ".px4" fw_file ${fw_file}) string(REPLACE ".elf" ".px4" fw_file ${fw_file})
string(REPLACE "nuttx_" "" fw_file ${fw_file})
add_custom_command(OUTPUT ${PX4_BINARY_DIR_REL}/${BOARD}.bin add_custom_command(OUTPUT ${PX4_BINARY_DIR_REL}/${BOARD}.bin
COMMAND ${OBJCOPY} -O binary ${PX4_BINARY_DIR_REL}/${FW_NAME} ${PX4_BINARY_DIR_REL}/${BOARD}.bin COMMAND ${OBJCOPY} -O binary ${PX4_BINARY_DIR_REL}/${FW_NAME} ${PX4_BINARY_DIR_REL}/${BOARD}.bin
@@ -135,7 +138,7 @@ if (TARGET parameters_xml AND TARGET airframes_xml)
--git_identity ${PX4_SOURCE_DIR} --git_identity ${PX4_SOURCE_DIR}
--parameter_xml ${PX4_BINARY_DIR}/parameters.xml --parameter_xml ${PX4_BINARY_DIR}/parameters.xml
--airframe_xml ${PX4_BINARY_DIR}/airframes.xml --airframe_xml ${PX4_BINARY_DIR}/airframes.xml
--image ${PX4_BINARY_DIR}/${BOARD}.bin > ${fw_file} --image ${PX4_BINARY_DIR}/${BOARD}.bin > ${fw_name_short}
DEPENDS ${PX4_BINARY_DIR}/${BOARD}.bin parameters_xml airframes_xml DEPENDS ${PX4_BINARY_DIR}/${BOARD}.bin parameters_xml airframes_xml
COMMENT "Creating ${fw_file}" COMMENT "Creating ${fw_file}"
) )