-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework post-build to support multiple executables #14953
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fcd57b2
CMake: Move post build functions out of root CMakeLists.txt
rwalton-arm 351680f
Rework post-build to support multiple executables
LDong-Arm 91b8186
Cypress: Improve `mbed_post_build_psoc6_merge_hex()`
LDong-Arm 23d659e
CMake: Add test for multiple-executable support
LDong-Arm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,72 +3,91 @@ | |
|
||
include(mbed_set_post_build) | ||
|
||
set(MBED_POST_BUILD_CYPRESS_DIR "${CMAKE_CURRENT_LIST_DIR}") | ||
|
||
# | ||
# Merge Cortex-M4 HEX and a Cortex-M0 HEX. | ||
# | ||
function(mbed_post_build_psoc6_merge_hex mbed_target_name) | ||
find_package(Python3) | ||
macro(mbed_post_build_psoc6_merge_hex) | ||
set(prefix "CYPRESS") | ||
set(options) | ||
set(oneValueArgs | ||
PSOC6_TARGET | ||
CORTEX_M0_HEX | ||
) | ||
set(multiValueArgs) | ||
cmake_parse_arguments( | ||
"${prefix}" | ||
"${options}" | ||
"${oneValueArgs}" | ||
"${multipleValueArgs}" | ||
${ARGN} | ||
) | ||
|
||
# Copy ${ARGN} to a variable first as it cannot be used directly with | ||
# the list() command | ||
set (extra_macro_args ${ARGN}) | ||
if("${CYPRESS_PSOC6_TARGET}" STREQUAL "${MBED_TARGET}") | ||
function(mbed_post_build_function target) | ||
find_package(Python3) | ||
set(post_build_command | ||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PSOC6.py | ||
merge | ||
--elf $<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_BASE_NAME:${target}>.elf | ||
--m4hex $<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_BASE_NAME:${target}>.hex | ||
) | ||
|
||
# Get the number of arguments past the last expected argument | ||
list(LENGTH extra_macro_args num_extra_args) | ||
if(NOT "${CYPRESS_CORTEX_M0_HEX}" STREQUAL "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks much better to me, the intent is now clear. |
||
list(APPEND post_build_command | ||
--m0hex ${CYPRESS_CORTEX_M0_HEX} | ||
) | ||
endif() | ||
|
||
if(${num_extra_args} GREATER 0) | ||
# Get extra argument as `cortex_m0_hex` | ||
list(GET extra_macro_args 0 cortex_m0_hex) | ||
set(post_build_command | ||
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_CYPRESS_DIR}/PSOC6.py | ||
merge | ||
--elf ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.elf | ||
--m4hex ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.hex | ||
--m0hex ${cortex_m0_hex} | ||
) | ||
else() | ||
set(post_build_command | ||
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_CYPRESS_DIR}/PSOC6.py | ||
merge | ||
--elf ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.elf | ||
--m4hex ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.hex | ||
) | ||
add_custom_command( | ||
TARGET | ||
${target} | ||
POST_BUILD | ||
COMMAND | ||
${post_build_command} | ||
) | ||
endfunction() | ||
endif() | ||
|
||
mbed_set_post_build_operation() | ||
endfunction() | ||
endmacro() | ||
|
||
|
||
# | ||
# Sign a Cortex-M4 HEX with Cortex-M0 HEX. | ||
# | ||
function(mbed_post_build_psoc6_sign_image | ||
macro(mbed_post_build_psoc6_sign_image | ||
m0hex_filename | ||
mbed_target_name | ||
cypress_psoc6_target | ||
policy_file_name | ||
boot_scheme | ||
cm0_img_id | ||
cm4_img_id | ||
cortex_m0_hex | ||
) | ||
find_package(Python3) | ||
if("${cypress_psoc6_target}" STREQUAL "${MBED_TARGET}") | ||
function(mbed_post_build_function target) | ||
find_package(Python3) | ||
|
||
set(post_build_command | ||
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_CYPRESS_DIR}/PSOC6.py | ||
sign | ||
--build-dir ${CMAKE_BINARY_DIR} | ||
--m0hex-filename ${m0hex_filename} | ||
--target-name ${mbed_target_name} | ||
--policy-file-name ${policy_file_name} | ||
--boot-scheme ${boot_scheme} | ||
--cm0-img-id ${cm0_img_id} | ||
--cm4-img-id ${cm4_img_id} | ||
--elf ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.elf | ||
--m4hex ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.hex | ||
--m0hex ${cortex_m0_hex} | ||
) | ||
set(post_build_command | ||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PSOC6.py | ||
sign | ||
--build-dir ${CMAKE_BINARY_DIR} | ||
--m0hex-filename ${m0hex_filename} | ||
--target-name ${cypress_psoc6_target} | ||
--policy-file-name ${policy_file_name} | ||
--boot-scheme ${boot_scheme} | ||
--cm0-img-id ${cm0_img_id} | ||
--cm4-img-id ${cm4_img_id} | ||
--elf $<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_BASE_NAME:${target}>.elf | ||
--m4hex $<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_BASE_NAME:${target}>.hex | ||
--m0hex ${cortex_m0_hex} | ||
) | ||
|
||
mbed_set_post_build_operation() | ||
endfunction() | ||
add_custom_command( | ||
TARGET | ||
${target} | ||
POST_BUILD | ||
COMMAND | ||
${post_build_command} | ||
) | ||
endfunction() | ||
endif() | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the commit message for commit "Rework post-build to support multiple executables", we say "guard it with a macro to checks if", that should be "guard it with a macro to check if"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I probably forgot to change it when rephrasing the sentence. 😅