sysbuild: Support BUILD_ONLY images

Add a new parameter to `ExternalZephyrProject_Add()`, which determines
whether a given sysbuild image should only be built and not considered
for flashing and debugging. By adding the following arguments:

   BUILD_ONLY TRUE

the image will be marked as build-only and excluded from `domains.yaml`.

For cases where this setting should be controlled by users or individual
samples, Kconfig can be used:

   ExternalZephyrProject_Add(
     APPLICATION foo
     SOURCE_DIR /path/to/foo
     BUILD_ONLY ${CONFIG_FOO_IS_BUILD_ONLY}
   )

This would be particularly fitting for "general-purpose" images, defined
in-tree or via Zephyr modules (whose inclusion in the multi-image build
should also be Kconfigurable).

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
This commit is contained in:
Grzegorz Swiderski 2023-08-07 11:09:49 +02:00 committed by Fabio Baltieri
parent 76bb1d7453
commit 93b1fb2713
2 changed files with 12 additions and 1 deletions

View file

@ -6,6 +6,10 @@ set(domains_yaml "default: ${DEFAULT_IMAGE}")
set(domains_yaml "${domains_yaml}\nbuild_dir: ${CMAKE_BINARY_DIR}")
set(domains_yaml "${domains_yaml}\ndomains:")
foreach(image ${IMAGES})
get_target_property(image_is_build_only ${image} BUILD_ONLY)
if(image_is_build_only)
continue()
endif()
set(domains_yaml "${domains_yaml}\n - name: ${image}")
set(domains_yaml "${domains_yaml}\n build_dir: $<TARGET_PROPERTY:${image},_EP_BINARY_DIR>")
endforeach()

View file

@ -125,10 +125,13 @@ endfunction()
# For example, -DCONF_FILES=<files> will be passed on to the
# MAIN_APP unmodified.
# BOOTLOADER indicates this app is a bootloader
# BUILD_ONLY <bool>: Mark the application as build-only. If <bool> evaluates to
# true, then this application will be excluded from flashing
# and debugging.
#
function(ExternalZephyrProject_Add)
set(app_types MAIN BOOTLOADER)
cmake_parse_arguments(ZBUILD "" "APPLICATION;BOARD;BOARD_REVISION;SOURCE_DIR;APP_TYPE" "" ${ARGN})
cmake_parse_arguments(ZBUILD "" "APPLICATION;BOARD;BOARD_REVISION;SOURCE_DIR;APP_TYPE;BUILD_ONLY" "" ${ARGN})
if(ZBUILD_UNPARSED_ARGUMENTS)
message(FATAL_ERROR
@ -279,6 +282,10 @@ function(ExternalZephyrProject_Add)
" requires BOARD."
)
endif()
if(DEFINED ZBUILD_BUILD_ONLY)
set_target_properties(${ZBUILD_APPLICATION} PROPERTIES BUILD_ONLY ${ZBUILD_BUILD_ONLY})
endif()
endfunction()
# Usage: