Skip to content

Commit 88a4f9d

Browse files
committed
sysbuild: Add flag to customize variant app config
Add a flag to allow for customizing the variant application Kconfig values. Ref: NCSDK-30812 Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
1 parent bde6b19 commit 88a4f9d

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

cmake/modules/kconfig.cmake

+19-12
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,31 @@
77
include_guard(GLOBAL)
88

99
if(CONFIG_NCS_IS_VARIANT_IMAGE)
10-
# A variant build should reuse same .config and thus autoconf.h, therefore
11-
# copy files from original and bypass Kconfig invocation.
1210
set(AUTOCONF_H ${PROJECT_BINARY_DIR}/include/generated/zephyr/autoconf.h)
1311
set(DOTCONFIG ${PROJECT_BINARY_DIR}/.config)
1412

15-
set(preload_autoconf_h ${PRELOAD_BINARY_DIR}/zephyr/include/generated/zephyr/autoconf.h)
16-
set(preload_dotconfig ${PRELOAD_BINARY_DIR}/zephyr/.config)
17-
18-
file(COPY ${preload_dotconfig} DESTINATION ${PROJECT_BINARY_DIR})
19-
file(COPY ${preload_autoconf_h} DESTINATION ${PROJECT_BINARY_DIR}/include/generated/zephyr)
20-
file(APPEND ${AUTOCONF_H} "#define CONFIG_NCS_IS_VARIANT_IMAGE 1")
21-
2213
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${AUTOCONF_H})
2314
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${DOTCONFIG})
24-
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${preload_autoconf_h})
25-
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${preload_dotconfig})
2615

27-
import_kconfig("CONFIG" ${DOTCONFIG})
16+
if(CONFIG_NCS_VARIANT_MERGE_KCONFIG)
17+
# A variant build should reuse same .config and thus autoconf.h, therefore
18+
# copy files from original and bypass Kconfig invocation.
19+
set(preload_autoconf_h ${PRELOAD_BINARY_DIR}/zephyr/include/generated/zephyr/autoconf.h)
20+
set(preload_dotconfig ${PRELOAD_BINARY_DIR}/zephyr/.config)
21+
22+
file(COPY ${preload_dotconfig} DESTINATION ${PROJECT_BINARY_DIR})
23+
file(COPY ${preload_autoconf_h} DESTINATION ${PROJECT_BINARY_DIR}/include/generated/zephyr)
24+
25+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${preload_autoconf_h})
26+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${preload_dotconfig})
27+
28+
import_kconfig("CONFIG" ${DOTCONFIG})
29+
else()
30+
# First generate autoconf.h as well as .config files.
31+
include(${ZEPHYR_BASE}/cmake/modules/kconfig.cmake)
32+
endif()
33+
34+
file(APPEND ${AUTOCONF_H} "#define CONFIG_NCS_IS_VARIANT_IMAGE 1")
2835
else()
2936
include(${ZEPHYR_BASE}/cmake/modules/kconfig.cmake)
3037
endif()

cmake/sysbuild/modules/ncs_sysbuild_extensions.cmake

+10-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ include_guard(GLOBAL)
1616
# APPLICATION <name>: Name of the application which is used as the source for
1717
# the variant build.
1818
# VARIANT <name>: Name of the variant build.
19+
# SPLIT_KCONFIG: Flag indicating that the variant image should
20+
# not reuse the same .config files.
1921
function(ExternalNcsVariantProject_Add)
20-
cmake_parse_arguments(VBUILD "" "APPLICATION;VARIANT" "" ${ARGN})
22+
cmake_parse_arguments(VBUILD "SPLIT_KCONFIG" "APPLICATION;VARIANT" "" ${ARGN})
2123

2224
ExternalProject_Get_Property(${VBUILD_APPLICATION} SOURCE_DIR BINARY_DIR)
2325
set(${VBUILD_APPLICATION}_BINARY_DIR ${BINARY_DIR})
@@ -41,9 +43,15 @@ function(ExternalNcsVariantProject_Add)
4143
set_property(TARGET ${VBUILD_VARIANT} PROPERTY NCS_VARIANT_APPLICATION ${VBUILD_APPLICATION})
4244
set_property(TARGET ${VBUILD_VARIANT} APPEND PROPERTY _EP_CMAKE_ARGS
4345
-DCONFIG_NCS_IS_VARIANT_IMAGE=y
44-
-DPRELOAD_BINARY_DIR=${${VBUILD_APPLICATION}_BINARY_DIR}
4546
)
4647

48+
if(NOT VBUILD_SPLIT_KCONFIG)
49+
set_property(TARGET ${VBUILD_VARIANT} APPEND PROPERTY _EP_CMAKE_ARGS
50+
-DPRELOAD_BINARY_DIR=${${VBUILD_APPLICATION}_BINARY_DIR}
51+
-DCONFIG_NCS_VARIANT_MERGE_KCONFIG=y
52+
)
53+
endif()
54+
4755
# Configure variant image after application so that the configuration is present
4856
sysbuild_add_dependencies(CONFIGURE ${VBUILD_VARIANT} ${VBUILD_APPLICATION})
4957
endfunction()

0 commit comments

Comments
 (0)