Skip to content

Commit 4558ba7

Browse files
tejlmandcarlescufi
authored andcommitted
cmake: ensure shields can be placed in other BOARD_ROOTs
Fixes: zephyrproject-rtos#28462 This commit allows shields to be defined in other BOARD_ROOTs, either using `-DBOARD_ROOT=<path>` or a Zephyr module defined BOARD_ROOT. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
1 parent d29ae95 commit 4558ba7

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

Kconfig.zephyr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ endmenu
2020
# precedence over SoC defaults, so include them in that order.
2121
#
2222
# $ARCH and $BOARD_DIR will be glob patterns when building documentation.
23-
source "boards/shields/*/Kconfig.defconfig"
23+
source "$(KCONFIG_BINARY_DIR)/Kconfig.shield.defconfig"
2424
source "$(BOARD_DIR)/Kconfig.defconfig"
2525
source "$(KCONFIG_BINARY_DIR)/Kconfig.soc.defconfig"
2626

boards/Kconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endchoice
2525

2626
# Parse shields references
2727
# Don't do it as a menuconfig, as shield selection is a CMake feature.
28-
rsource "shields/*/Kconfig.shield"
28+
source "$(KCONFIG_BINARY_DIR)/Kconfig.shield"
2929

3030
menu "Board Options"
3131
config QEMU_ICOUNT

cmake/kconfig.cmake

+12
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ foreach(root ${SOC_ROOT})
2121
set(OPERATION APPEND)
2222
endforeach()
2323

24+
# Support multiple shields in BOARD_ROOT
25+
set(OPERATION WRITE)
26+
foreach(root ${BOARD_ROOT})
27+
file(${OPERATION} ${KCONFIG_BINARY_DIR}/Kconfig.shield.defconfig
28+
"osource \"${root}/boards/shields/*/Kconfig.defconfig\"\n"
29+
)
30+
file(${OPERATION} ${KCONFIG_BINARY_DIR}/Kconfig.shield
31+
"osource \"${root}/boards/shields/*/Kconfig.shield\"\n"
32+
)
33+
set(OPERATION APPEND)
34+
endforeach()
35+
2436
if(KCONFIG_ROOT)
2537
zephyr_file(APPLICATION_ROOT KCONFIG_ROOT)
2638
# KCONFIG_ROOT has either been specified as a CMake variable or is

scripts/ci/check_compliance.py

+8
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ def write_kconfig_soc(self):
265265
soc_defconfig_file = os.path.join(tempfile.gettempdir(), "Kconfig.soc.defconfig")
266266
soc_file = os.path.join(tempfile.gettempdir(), "Kconfig.soc")
267267
soc_arch_file = os.path.join(tempfile.gettempdir(), "Kconfig.soc.arch")
268+
shield_defconfig_file = os.path.join(tempfile.gettempdir(), "Kconfig.shield.defconfig")
269+
shield_file = os.path.join(tempfile.gettempdir(), "Kconfig.shield")
268270
try:
269271
with open(soc_defconfig_file, 'w', encoding="utf-8") as fp:
270272
fp.write(f'osource "{ZEPHYR_BASE}/soc/$(ARCH)/*/Kconfig.defconfig"\n')
@@ -275,6 +277,12 @@ def write_kconfig_soc(self):
275277
with open(soc_arch_file, 'w', encoding="utf-8") as fp:
276278
fp.write(f'osource "{ZEPHYR_BASE}/soc/$(ARCH)/Kconfig"\n\
277279
osource "{ZEPHYR_BASE}/soc/$(ARCH)/*/Kconfig"\n')
280+
281+
with open(shield_defconfig_file, 'w', encoding="utf-8") as fp:
282+
fp.write(f'osource "{ZEPHYR_BASE}/boards/shields/*/Kconfig.defconfig"\n')
283+
284+
with open(shield_file, 'w', encoding="utf-8") as fp:
285+
fp.write(f'osource "{ZEPHYR_BASE}/boards/shields/*/Kconfig.shield"\n')
278286
except IOError as ex:
279287
self.error(ex.output)
280288

0 commit comments

Comments
 (0)