Skip to content

Commit 6568e3b

Browse files
committed
[DNM] kconfig: squash of board and soc scheme v2 support.
Do not review this commit. Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent b10c526 commit 6568e3b

File tree

12 files changed

+143
-42
lines changed

12 files changed

+143
-42
lines changed

.github/workflows/compliance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
# debug
7070
ls -la
7171
git log --pretty=oneline | head -n 10
72-
./scripts/ci/check_compliance.py -m Devicetree -m Gitlint -m Identity -m Nits -m pylint -m checkpatch -m Kconfig -c origin/${BASE_REF}..
72+
./scripts/ci/check_compliance.py -m Devicetree -m Gitlint -m Identity -m Nits -m pylint -m checkpatch -m Kconfig -m KconfigBoardV2 -c origin/${BASE_REF}..
7373
7474
- name: upload-results
7575
uses: actions/upload-artifact@v3

arch/Kconfig

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -904,27 +904,6 @@ config ARCH
904904
help
905905
System architecture string.
906906

907-
config SOC
908-
string
909-
help
910-
SoC name which can be found under soc/<arch>/<soc name>.
911-
This option holds the directory name used by the build system to locate
912-
the correct linker and header files for the SoC.
913-
914-
config SOC_SERIES
915-
string
916-
help
917-
SoC series name which can be found under soc/<arch>/<family>/<series>.
918-
This option holds the directory name used by the build system to locate
919-
the correct linker and header files.
920-
921-
config SOC_FAMILY
922-
string
923-
help
924-
SoC family name which can be found under soc/<arch>/<family>.
925-
This option holds the directory name used by the build system to locate
926-
the correct linker and header files.
927-
928907
config TOOLCHAIN_HAS_BUILTIN_FFS
929908
bool
930909
default y if !(64BIT && RISCV)

boards/Kconfig

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
config BOARD
44
string
5+
# When using Board scheme v2, then the board is inherited from CMake.
6+
default "$(BOARD)" if "$(BOARD_SCHEME)" = "v2"
57
help
68
This option holds the name of the board and is used to locate the files
79
related to the board in the source tree (under boards/).
@@ -38,14 +40,7 @@ config NET_DRIVERS
3840
When building for a qemu target then NET_DRIVERS will be default
3941
enabled to allow for easy use of SLIP or PPP
4042

41-
# Note: $BOARD_DIR might be a glob pattern
42-
43-
choice
44-
prompt "Board Selection"
45-
46-
source "$(BOARD_DIR)/Kconfig.board"
47-
48-
endchoice
43+
rsource "Kconfig.$(BOARD_SCHEME)"
4944

5045
# Parse shields references
5146
# Don't do it as a menuconfig, as shield selection is a CMake feature.

boards/Kconfig.v1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2022 Nordic Semiconductor ASA
2+
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
choice
6+
prompt "Board Selection"
7+
8+
source "$(BOARD_DIR)/Kconfig.board"
9+
10+
endchoice

boards/Kconfig.v2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2022 Nordic Semiconductor ASA
2+
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
osource "$(BOARD_DIR)/Kconfig.v2.$(BOARD)"

cmake/modules/kconfig.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ string(REPLACE ";" "\\\;" SHIELD_AS_LIST_ESCAPED "${SHIELD_AS_LIST}")
111111
# cmake commands are escaped differently
112112
string(REPLACE ";" "\\;" SHIELD_AS_LIST_ESCAPED_COMMAND "${SHIELD_AS_LIST}")
113113

114+
# A Kconfig.board indicates legacy style board definition, whereas
115+
# Kconfig.${BOARD} indicates new and improved style.
116+
if(EXISTS ${BOARD_DIR}/Kconfig.board AND NOT EXISTS ${BOARD_DIR}/Kconfig.${BOARD})
117+
set(BOARD_SCHEME v1)
118+
elseif(NOT EXISTS ${BOARD_DIR}/Kconfig.board AND EXISTS ${BOARD_DIR}/Kconfig.${BOARD})
119+
set(BOARD_SCHEME v2)
120+
elseif(EXISTS ${BOARD_DIR}/Kconfig.board AND EXISTS ${BOARD_DIR}/Kconfig.${BOARD})
121+
message(WARNING "Mixed board scheme (v1 + v2) not allowed, using board scheme v2.")
122+
set(BOARD_SCHEME v2)
123+
endif()
124+
114125
set(COMMON_KCONFIG_ENV_SETTINGS
115126
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
116127
srctree=${ZEPHYR_BASE}
@@ -122,7 +133,9 @@ set(COMMON_KCONFIG_ENV_SETTINGS
122133
ARCH=${ARCH}
123134
ARCH_DIR=${ARCH_DIR}
124135
BOARD_DIR=${BOARD_DIR}
136+
BOARD=${BOARD}
125137
BOARD_REVISION=${BOARD_REVISION}
138+
BOARD_SCHEME=${BOARD_SCHEME}
126139
KCONFIG_BINARY_DIR=${KCONFIG_BINARY_DIR}
127140
ZEPHYR_TOOLCHAIN_VARIANT=${ZEPHYR_TOOLCHAIN_VARIANT}
128141
TOOLCHAIN_KCONFIG_DIR=${TOOLCHAIN_KCONFIG_DIR}

doc/_extensions/zephyr/kconfig/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def kconfig_load(app: Sphinx) -> Tuple[kconfiglib.Kconfig, Dict[str, str]]:
9797
os.environ["ARCH_DIR"] = "arch"
9898
os.environ["ARCH"] = "*"
9999
os.environ["BOARD_DIR"] = "boards/*/*"
100+
os.environ["BOARD_SCHEME"] = "v*"
100101

101102
# insert external Kconfigs to the environment
102103
module_paths = dict()

scripts/ci/Kconfig.board.v2

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Kconfig top-level ci for compliance testing Kconfig tree for boards / SoC v2 scheme.
2+
#
3+
# Copyright (c) 2022 Nordic Semiconductor ASA
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
mainmenu "Zephyr board / SoC v2 Configuration"
8+
9+
SOC_SCHEME = $(BOARD_SCHEME)
10+
source "boards/Kconfig.$(BOARD_SCHEME)"
11+
source "soc/Kconfig.$(SOC_SCHEME)"

scripts/ci/check_compliance.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ class KconfigCheck(ComplianceTest):
229229
doc = "See https://docs.zephyrproject.org/latest/guides/kconfig/index.html for more details."
230230
path_hint = ZEPHYR_BASE
231231

232-
def run(self, full=True):
233-
kconf = self.parse_kconfig()
232+
def run(self, full=True, board_scheme="v*", filename="Kconfig"):
233+
kconf = self.parse_kconfig(board_scheme=board_scheme, filename=filename)
234234

235235
self.check_top_menu_not_too_long(kconf)
236236
self.check_no_pointless_menuconfigs(kconf)
@@ -294,7 +294,7 @@ def get_kconfig_dts(self, kconfig_dts_file):
294294
self.error(ex.output)
295295

296296

297-
def parse_kconfig(self):
297+
def parse_kconfig(self, board_scheme="v*", filename="Kconfig"):
298298
"""
299299
Returns a kconfiglib.Kconfig object for the Kconfig files. We reuse
300300
this object for all tests to avoid having to reparse for each test.
@@ -321,6 +321,8 @@ def parse_kconfig(self):
321321
os.environ["SOC_DIR"] = "soc/"
322322
os.environ["ARCH_DIR"] = "arch/"
323323
os.environ["BOARD_DIR"] = "boards/*/*"
324+
os.environ["BOARD_SCHEME"] = board_scheme
325+
os.environ["BOARD"] = "*"
324326
os.environ["ARCH"] = "*"
325327
os.environ["KCONFIG_BINARY_DIR"] = tempfile.gettempdir()
326328
os.environ['DEVICETREE_CONF'] = "dummy"
@@ -345,7 +347,7 @@ def parse_kconfig(self):
345347
# them: so some warnings might get printed
346348
# twice. "warn_to_stderr=False" could unfortunately cause
347349
# some (other) warnings to never be printed.
348-
return kconfiglib.Kconfig()
350+
return kconfiglib.Kconfig(filename=filename)
349351
except kconfiglib.KconfigError as e:
350352
self.add_failure(str(e))
351353
raise EndTest
@@ -632,6 +634,24 @@ def run(self):
632634
super().run(full=False)
633635

634636

637+
class KconfigBoardV2Check(KconfigCheck, ComplianceTest):
638+
"""
639+
This runs the Kconfig test for board and SoC v2 scheme.
640+
This check ensures that all symbols inside the v2 scheme is also defined
641+
within the same tree.
642+
This ensures the board and SoC trees are fully self-contained and reusable.
643+
"""
644+
name = "KconfigBoardV2"
645+
doc = "See https://docs.zephyrproject.org/latest/guides/kconfig/index.html for more details."
646+
path_hint = ZEPHYR_BASE
647+
648+
def run(self):
649+
# Use dedicated Kconfig board / soc v2 scheme file.
650+
# This file sources only v2 scheme tree.
651+
kconfig_file = os.path.join(os.path.dirname(__file__), "Kconfig.board.v2")
652+
super().run(full=False, board_scheme="v2", filename=kconfig_file)
653+
654+
635655
class Codeowners(ComplianceTest):
636656
"""
637657
Check if added files have an owner.

soc/Kconfig

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
choice
4-
prompt "SoC/CPU/Configuration Selection"
3+
# SoC scheme follows the board scheme versioning.
4+
SOC_SCHEME = $(BOARD_SCHEME)
55

6-
# This loads custom SoC root Kconfig (only available if custom SoC root are defined)
7-
osource "$(KCONFIG_BINARY_DIR)/Kconfig.soc"
8-
# This loads Zephyr base SoC root Kconfig
9-
osource "soc/$(ARCH)/*/Kconfig.soc"
10-
11-
endchoice
6+
# This loads any SoC scheme specific content.
7+
rsource "Kconfig.$(SOC_SCHEME)"
128

139
menu "Hardware Configuration"
1410
# This loads custom SoC root Kconfig (only available if custom SoC root are defined)

0 commit comments

Comments
 (0)