Skip to content

Commit af23628

Browse files
57300carlescufi
authored andcommitted
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>
1 parent b10817b commit af23628

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

cmake/modules/configuration_files.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# The following variables will be defined when this CMake module completes:
1212
#
1313
# - CONF_FILE: List of Kconfig fragments
14+
# - OVERLAY_CONFIG: List of additional Kconfig fragments
1415
# - DTC_OVERLAY_FILE: List of devicetree overlay files
1516
# - APPLICATION_CONFIG_DIR: Root folder for application configuration
1617
#
@@ -114,3 +115,5 @@ DTC_OVERLAY_FILE=\"dts1.overlay dts2.overlay\"")
114115

115116
# The DTC_OVERLAY_FILE variable is now set to its final value.
116117
zephyr_boilerplate_watch(DTC_OVERLAY_FILE)
118+
119+
zephyr_get(OVERLAY_CONFIG SYSBUILD LOCAL)

cmake/modules/kconfig.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ if(CONF_FILE)
7676
string(REPLACE " " ";" CONF_FILE_AS_LIST "${CONF_FILE_EXPANDED}")
7777
endif()
7878

79-
zephyr_get(OVERLAY_CONFIG SYSBUILD LOCAL)
8079
if(OVERLAY_CONFIG)
8180
string(CONFIGURE "${OVERLAY_CONFIG}" OVERLAY_CONFIG_EXPANDED)
8281
string(REPLACE " " ";" OVERLAY_CONFIG_AS_LIST "${OVERLAY_CONFIG_EXPANDED}")

share/sysbuild/cmake/modules/sysbuild_kconfig.cmake

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ else()
2525
endif()
2626

2727
if(DEFINED SB_CONF_FILE AND NOT IS_ABSOLUTE SB_CONF_FILE)
28-
cmake_path(ABSOLUTE_PATH SB_CONF_FILE BASE_DIRECTORY ${APP_DIR} OUTPUT_VARIABLE SB_CONF_FILE)
28+
cmake_path(ABSOLUTE_PATH SB_CONF_FILE BASE_DIRECTORY ${APP_DIR})
29+
endif()
30+
31+
if(DEFINED SB_OVERLAY_CONFIG AND NOT IS_ABSOLUTE SB_OVERLAY_CONFIG)
32+
cmake_path(ABSOLUTE_PATH SB_OVERLAY_CONFIG BASE_DIRECTORY ${APP_DIR})
2933
endif()
3034

3135
if(DEFINED SB_CONF_FILE AND NOT DEFINED CACHE{SB_CONF_FILE})
@@ -48,6 +52,7 @@ file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/empty.conf)
4852
set(APPLICATION_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
4953
set(AUTOCONF_H ${CMAKE_CURRENT_BINARY_DIR}/autoconf.h)
5054
set(CONF_FILE ${SB_CONF_FILE})
55+
set(OVERLAY_CONFIG "${SB_OVERLAY_CONFIG}")
5156
set(BOARD_DEFCONFIG "${CMAKE_CURRENT_BINARY_DIR}/empty.conf")
5257
if(DEFINED BOARD_REVISION)
5358
set(BOARD_REVISION_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/empty.conf")

0 commit comments

Comments
 (0)