cmake: create domains.yaml

Support creation of domains.yaml to support
`west <build|flash|debug> --domain` when working with sysbuild multi
image.

Each Zephyr based image is added to list of domain that can be handled
by the Zephyr west extension commands.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2021-11-22 13:55:57 +01:00 committed by Carles Cufí
commit 598bea0899
3 changed files with 19 additions and 0 deletions

View file

@ -36,9 +36,13 @@ ExternalZephyrProject_Add(
SOURCE_DIR ${APP_DIR}
MAIN_APP
)
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)
include(${APP_DIR}/sysbuild.cmake OPTIONAL)
include(cmake/domains.cmake)

View file

@ -8,4 +8,7 @@ if(SB_CONFIG_BOOTLOADER_MCUBOOT)
APPLICATION mcuboot
SOURCE_DIR ${ZEPHYR_MCUBOOT_MODULE_DIR}/boot/zephyr/
)
# MCUBoot default configuration is to perform a full chip erase.
# Placing MCUBoot first in list to ensure it is flashed before other images.
set(IMAGES "mcuboot" ${IMAGES} PARENT_SCOPE)
endif()

View file

@ -0,0 +1,12 @@
# Copyright (c) 2021 Nordic Semiconductor
#
# SPDX-License-Identifier: Apache-2.0
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})
set(domains_yaml "${domains_yaml}\n - name: ${image}")
set(domains_yaml "${domains_yaml}\n build_dir: $<TARGET_PROPERTY:${image},_EP_BINARY_DIR>")
endforeach()
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/domains.yaml CONTENT "${domains_yaml}")