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
sysbuild: Image ordering #57884
sysbuild: Image ordering #57884
Changes from all commits
3843444
dbaf74a
00bb3ad
d771524
6b1e4f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,68 +24,17 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS ${zephyr_modules | |
|
||
project(sysbuild LANGUAGES) | ||
|
||
# Global list of images enabled in this multi image build system. | ||
set(IMAGES) | ||
|
||
get_filename_component(APP_DIR ${APP_DIR} ABSOLUTE) | ||
get_filename_component(app_name ${APP_DIR} NAME) | ||
|
||
# Include zephyr modules generated sysbuild CMake file. | ||
foreach(SYSBUILD_CURRENT_MODULE_NAME ${SYSBUILD_MODULE_NAMES}) | ||
# Note the second, binary_dir parameter requires the added | ||
# subdirectory to have its own, local cmake target(s). If not then | ||
# this binary_dir is created but stays empty. Object files land in | ||
# the main binary dir instead. | ||
# https://cmake.org/pipermail/cmake/2019-June/069547.html | ||
zephyr_string(SANITIZE TOUPPER MODULE_NAME_UPPER ${SYSBUILD_CURRENT_MODULE_NAME}) | ||
if(NOT ${SYSBUILD_${MODULE_NAME_UPPER}_CMAKE_DIR} STREQUAL "") | ||
set(SYSBUILD_CURRENT_MODULE_DIR ${SYSBUILD_${MODULE_NAME_UPPER}_MODULE_DIR}) | ||
set(SYSBUILD_CURRENT_CMAKE_DIR ${SYSBUILD_${MODULE_NAME_UPPER}_CMAKE_DIR}) | ||
add_subdirectory(${SYSBUILD_CURRENT_CMAKE_DIR} ${CMAKE_BINARY_DIR}/modules/${SYSBUILD_CURRENT_MODULE_NAME}) | ||
endif() | ||
endforeach() | ||
# Done processing modules, clear SYSBUILD_CURRENT_MODULE_DIR and SYSBUILD_CURRENT_CMAKE_DIR. | ||
set(SYSBUILD_CURRENT_MODULE_DIR) | ||
set(SYSBUILD_CURRENT_CMAKE_DIR) | ||
|
||
# This adds the primary application to the build. | ||
ExternalZephyrProject_Add( | ||
APPLICATION ${app_name} | ||
SOURCE_DIR ${APP_DIR} | ||
APP_TYPE MAIN | ||
) | ||
list(APPEND IMAGES "${app_name}") | ||
set(DEFAULT_IMAGE "${app_name}") | ||
|
||
add_subdirectory(bootloader) | ||
|
||
# This allows for board and app specific images to be included. | ||
include(${BOARD_DIR}/sysbuild.cmake OPTIONAL) | ||
|
||
# This allows image specific sysbuild.cmake to be processed. | ||
list(LENGTH IMAGES images_length) | ||
while(NOT "${images_length}" EQUAL "${processed_length}") | ||
foreach(image ${IMAGES}) | ||
if(NOT image IN_LIST images_sysbuild_processed) | ||
ExternalProject_Get_property(${image} SOURCE_DIR) | ||
include(${SOURCE_DIR}/sysbuild.cmake OPTIONAL) | ||
list(APPEND images_sysbuild_processed ${image}) | ||
endif() | ||
endforeach() | ||
|
||
list(LENGTH IMAGES images_length) | ||
list(LENGTH images_sysbuild_processed processed_length_new) | ||
|
||
# Check for any duplicate entries in image names to prevent an infinite loop | ||
if("${processed_length_new}" EQUAL "${processed_length}") | ||
# Image length was different than processed length, but no new images are processed. | ||
message(FATAL_ERROR "A duplicate image name was provided, image names must be unique.") | ||
endif() | ||
set(processed_length ${processed_length_new}) | ||
endwhile() | ||
# This is where all Zephyr applications are added to the multi-image build. | ||
sysbuild_add_subdirectory(images) | ||
|
||
get_property(IMAGES GLOBAL PROPERTY sysbuild_images) | ||
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.
With the new approach of No need for changing in this PR, but worth considering when extending sysbuild, or if refactoring |
||
sysbuild_module_call(PRE_CMAKE MODULES ${SYSBUILD_MODULE_NAMES} IMAGES ${IMAGES}) | ||
foreach(image ${IMAGES}) | ||
sysbuild_images_order(IMAGES_CONFIGURATION_ORDER CONFIGURE IMAGES ${IMAGES}) | ||
foreach(image ${IMAGES_CONFIGURATION_ORDER}) | ||
ExternalZephyrProject_Cmake(APPLICATION ${image}) | ||
endforeach() | ||
sysbuild_module_call(POST_CMAKE MODULES ${SYSBUILD_MODULE_NAMES} IMAGES ${IMAGES}) | ||
|
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.
Is this line still needed?
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.
I guess so, if it's meant to control the order in which those images are built (not configured).