mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #15297 from byq77/cli2-cmake-artifact-name-property-support
cli2 artifact name property support for cmake targetspull/15306/head
commit
bc6be806df
|
@ -6,32 +6,39 @@
|
|||
#
|
||||
function(mbed_generate_bin_hex target)
|
||||
get_property(elf_to_bin GLOBAL PROPERTY ELF2BIN)
|
||||
get_target_property(artifact_name ${target} ARTIFACT_NAME)
|
||||
|
||||
# set to the target name if the property is unset
|
||||
if(artifact_name STREQUAL "artifact_name-NOTFOUND" OR artifact_name STREQUAL "")
|
||||
set(artifact_name ${target})
|
||||
endif()
|
||||
|
||||
if (MBED_TOOLCHAIN STREQUAL "GCC_ARM")
|
||||
# The first condition is quoted in case MBED_OUTPUT_EXT is unset
|
||||
if ("${MBED_OUTPUT_EXT}" STREQUAL "" OR MBED_OUTPUT_EXT STREQUAL "bin")
|
||||
list(APPEND CMAKE_POST_BUILD_COMMAND
|
||||
COMMAND ${elf_to_bin} -O binary $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${target}.bin
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${target}.bin"
|
||||
COMMAND ${elf_to_bin} -O binary $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${artifact_name}.bin
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${artifact_name}.bin"
|
||||
)
|
||||
endif()
|
||||
if ("${MBED_OUTPUT_EXT}" STREQUAL "" OR MBED_OUTPUT_EXT STREQUAL "hex")
|
||||
list(APPEND CMAKE_POST_BUILD_COMMAND
|
||||
COMMAND ${elf_to_bin} -O ihex $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${target}.hex
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${target}.hex"
|
||||
COMMAND ${elf_to_bin} -O ihex $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${artifact_name}.hex
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${artifact_name}.hex"
|
||||
)
|
||||
endif()
|
||||
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
|
||||
get_property(mbed_studio_arm_compiler GLOBAL PROPERTY MBED_STUDIO_ARM_COMPILER)
|
||||
if ("${MBED_OUTPUT_EXT}" STREQUAL "" OR MBED_OUTPUT_EXT STREQUAL "bin")
|
||||
list(APPEND CMAKE_POST_BUILD_COMMAND
|
||||
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --bin -o ${CMAKE_CURRENT_BINARY_DIR}/${target}.bin $<TARGET_FILE:${target}>
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${target}.bin"
|
||||
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --bin -o ${CMAKE_CURRENT_BINARY_DIR}/${artifact_name}.bin $<TARGET_FILE:${target}>
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${artifact_name}.bin"
|
||||
)
|
||||
endif()
|
||||
if ("${MBED_OUTPUT_EXT}" STREQUAL "" OR MBED_OUTPUT_EXT STREQUAL "hex")
|
||||
list(APPEND CMAKE_POST_BUILD_COMMAND
|
||||
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --i32combined -o ${CMAKE_CURRENT_BINARY_DIR}/${target}.hex $<TARGET_FILE:${target}>
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${target}.hex"
|
||||
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --i32combined -o ${CMAKE_CURRENT_BINARY_DIR}/${artifact_name}.hex $<TARGET_FILE:${target}>
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${artifact_name}.hex"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue