From af23628e43178e528e886fe75f4d8a50336d5095 Mon Sep 17 00:00:00 2001 From: Grzegorz Swiderski Date: Thu, 4 May 2023 13:21:13 +0200 Subject: [PATCH] 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 --- cmake/modules/configuration_files.cmake | 3 +++ cmake/modules/kconfig.cmake | 1 - share/sysbuild/cmake/modules/sysbuild_kconfig.cmake | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmake/modules/configuration_files.cmake b/cmake/modules/configuration_files.cmake index e5db53fd088..e539e48f09c 100644 --- a/cmake/modules/configuration_files.cmake +++ b/cmake/modules/configuration_files.cmake @@ -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) diff --git a/cmake/modules/kconfig.cmake b/cmake/modules/kconfig.cmake index 3bcd23d51d7..1b064eedffb 100644 --- a/cmake/modules/kconfig.cmake +++ b/cmake/modules/kconfig.cmake @@ -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}") diff --git a/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake b/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake index 5dbf82728a5..f8390877939 100644 --- a/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake +++ b/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake @@ -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")