Skip to content

Commit 9d61a68

Browse files
committed
[nrf fromtree] sysbuild: add support for APPLICATION_CONFIG_DIR in sysbuild
APPLICATION_CONFIG_DIR is supported in Zephyr and allows to adjust the location from which prj.conf and friends are picked up. This also works for images when using sysbuild, however sysbuild itself ignores the value of APPLICATION_CONFIG_DIR, meaning that sysbuild only accepts sysbuild.conf located directly in the sample folder. Extend sysbuild to support APPLICATION_CONFIG_DIR so sysbuild follows regular Zephyr CMake behavior. Introduce SB_APPLICATION_CONFIG_DIR to allow changing the location for sysbuild only, without propagating the value to images. Signed-off-by: Torsten Rasmussen <[email protected]> (cherry picked from commit 2b427f1)
1 parent caf1dac commit 9d61a68

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

share/sysbuild/cmake/modules/sysbuild_kconfig.cmake

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,37 @@ set(EXTRA_KCONFIG_TARGET_COMMAND_FOR_sysbuild_guiconfig
1313
set(KCONFIG_TARGETS sysbuild_menuconfig sysbuild_guiconfig)
1414
list(TRANSFORM EXTRA_KCONFIG_TARGETS PREPEND "sysbuild_")
1515

16+
if(DEFINED APPLICATION_CONFIG_DIR AND NOT DEFINED CACHE{APPLICATION_CONFIG_DIR})
17+
set(APPLICATION_CONFIG_DIR "${APPLICATION_CONFIG_DIR}" CACHE INTERNAL "Application config dir")
18+
elseif(DEFINED CACHE{APPLICATION_CONFIG_DIR} AND
19+
NOT (APPLICATION_CONFIG_DIR STREQUAL "$CACHE{APPLICATION_CONFIG_DIR}"))
20+
message(WARNING
21+
"Sysbuild scoped APPLICATION_CONFIG_DIR and cached APPLICATION_CONFIG_DIR differs.\n"
22+
"Setting value used internally by Sysbuild (sysbuild scoped):\n"
23+
" - ${APPLICATION_CONFIG_DIR}\n"
24+
"Setting value used by images (cached):\n"
25+
" - $CACHE{APPLICATION_CONFIG_DIR}\n"
26+
)
27+
endif()
28+
29+
# If there is a dedicated SB_APPLICATION_CONFIG_DIR, then create a local
30+
# scoped APPLICATION_CONFIG_DIR hiding any cache variant.
31+
# The cache setting is the setting passed to sysbuild image cache files
32+
if(DEFINED SB_APPLICATION_CONFIG_DIR)
33+
set(APPLICATION_CONFIG_DIR ${SB_APPLICATION_CONFIG_DIR})
34+
elseif(NOT DEFINED APPLICATION_CONFIG_DIR)
35+
get_filename_component(APP_DIR ${APP_DIR} ABSOLUTE)
36+
set(APPLICATION_CONFIG_DIR ${APP_DIR})
37+
endif()
38+
string(CONFIGURE ${APPLICATION_CONFIG_DIR} APPLICATION_CONFIG_DIR)
39+
1640
if(DEFINED SB_CONF_FILE)
1741
# SB_CONF_FILE already set so nothing to do.
1842
elseif(DEFINED ENV{SB_CONF_FILE})
1943
set(SB_CONF_FILE $ENV{SB_CONF_FILE})
2044
else()
2145
# sysbuild.conf is an optional file, because sysbuild is an opt-in feature.
22-
zephyr_file(CONF_FILES ${APP_DIR} KCONF SB_CONF_FILE NAMES "sysbuild.conf" SUFFIX ${FILE_SUFFIX})
46+
zephyr_file(CONF_FILES ${APPLICATION_CONFIG_DIR} KCONF SB_CONF_FILE NAMES "sysbuild.conf" SUFFIX ${FILE_SUFFIX})
2347
endif()
2448

2549
if(NOT DEFINED SB_EXTRA_CONF_FILE AND DEFINED SB_OVERLAY_CONFIG)

0 commit comments

Comments
 (0)