sysbuild: Add SB_OVERLAY_CONFIG

This fixes a minor issue in sysbuild, where `-DOVERLAY_CONFIG=...` would
be applied not only to the main application, but also sysbuild itself.
This was incorrect, because sysbuild imports a different Kconfig tree
than normal Zephyr builds, so the same Kconfig fragment file would not
necessarily be valid for both.

This adds a new variable SB_OVERLAY_CONFIG to resolve this ambiguity.
It functions along the lines of SB_CONF_FILE, with both being sysbuild-
specific versions of existing variables.

To ensure that OVERLAY_CONFIG is still passed on to the main application
verbatim, its value is now loaded in `configuration_files.cmake`, rather
than `kconfig.cmake`. This is because the former file is not imported by
sysbuild, and it is where the related variables, such as CONF_FILE and
DTC_OVERLAY_FILE, are loaded as well.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
This commit is contained in:
Grzegorz Swiderski 2023-05-04 13:21:13 +02:00 committed by Carles Cufí
commit af23628e43
3 changed files with 9 additions and 2 deletions

View file

@ -11,6 +11,7 @@
# The following variables will be defined when this CMake module completes:
#
# - CONF_FILE: List of Kconfig fragments
# - OVERLAY_CONFIG: List of additional Kconfig fragments
# - DTC_OVERLAY_FILE: List of devicetree overlay files
# - APPLICATION_CONFIG_DIR: Root folder for application configuration
#
@ -114,3 +115,5 @@ DTC_OVERLAY_FILE=\"dts1.overlay dts2.overlay\"")
# The DTC_OVERLAY_FILE variable is now set to its final value.
zephyr_boilerplate_watch(DTC_OVERLAY_FILE)
zephyr_get(OVERLAY_CONFIG SYSBUILD LOCAL)

View file

@ -76,7 +76,6 @@ if(CONF_FILE)
string(REPLACE " " ";" CONF_FILE_AS_LIST "${CONF_FILE_EXPANDED}")
endif()
zephyr_get(OVERLAY_CONFIG SYSBUILD LOCAL)
if(OVERLAY_CONFIG)
string(CONFIGURE "${OVERLAY_CONFIG}" OVERLAY_CONFIG_EXPANDED)
string(REPLACE " " ";" OVERLAY_CONFIG_AS_LIST "${OVERLAY_CONFIG_EXPANDED}")

View file

@ -25,7 +25,11 @@ else()
endif()
if(DEFINED SB_CONF_FILE AND NOT IS_ABSOLUTE SB_CONF_FILE)
cmake_path(ABSOLUTE_PATH SB_CONF_FILE BASE_DIRECTORY ${APP_DIR} OUTPUT_VARIABLE SB_CONF_FILE)
cmake_path(ABSOLUTE_PATH SB_CONF_FILE BASE_DIRECTORY ${APP_DIR})
endif()
if(DEFINED SB_OVERLAY_CONFIG AND NOT IS_ABSOLUTE SB_OVERLAY_CONFIG)
cmake_path(ABSOLUTE_PATH SB_OVERLAY_CONFIG BASE_DIRECTORY ${APP_DIR})
endif()
if(DEFINED SB_CONF_FILE AND NOT DEFINED CACHE{SB_CONF_FILE})
@ -48,6 +52,7 @@ file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/empty.conf)
set(APPLICATION_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(AUTOCONF_H ${CMAKE_CURRENT_BINARY_DIR}/autoconf.h)
set(CONF_FILE ${SB_CONF_FILE})
set(OVERLAY_CONFIG "${SB_OVERLAY_CONFIG}")
set(BOARD_DEFCONFIG "${CMAKE_CURRENT_BINARY_DIR}/empty.conf")
if(DEFINED BOARD_REVISION)
set(BOARD_REVISION_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/empty.conf")