Skip to content

Commit c32488f

Browse files
cfriedtkartben
authored andcommitted
cmake: kconfig: auto-generate boolean board revision option
Automatically generate a boolean CONFIG_BOARD_REVISION_FOO=y Kconfig option based on e.g. CONFIG_BOARD_REVISION="foo". Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
1 parent ffe52da commit c32488f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cmake/modules/kconfig.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ if(DEFINED BOARD_REVISION)
6666
message(DEPRECATION "Use of '${board_rev_file}.conf' is deprecated, please switch to '${board_rev_file}_defconfig'")
6767
set_ifndef(BOARD_REVISION_CONFIG ${BOARD_DIR}/${board_rev_file}.conf)
6868
endif()
69+
70+
# Generate boolean board revision kconfig option
71+
zephyr_string(SANITIZE TOUPPER BOARD_REVISION_GEN_CONFIG_VAR "BOARD_REVISION_${BOARD_REVISION}")
72+
73+
file(APPEND ${KCONFIG_BOARD_DIR}/Kconfig
74+
"config ${BOARD_REVISION_GEN_CONFIG_VAR}\n"
75+
"\tdef_bool y\n"
76+
)
6977
endif()
7078

7179
set(DOTCONFIG ${PROJECT_BINARY_DIR}/.config)

scripts/ci/check_compliance.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,8 @@ def check_no_undef_outside_kconfig(self, kconf):
971971
sym_name = sym_name[len(self.CONFIG_):] # Strip CONFIG_
972972
if sym_name not in defined_syms and \
973973
sym_name not in self.UNDEF_KCONFIG_ALLOWLIST and \
974-
not (sym_name.endswith("_MODULE") and sym_name[:-7] in defined_syms):
974+
not (sym_name.endswith("_MODULE") and sym_name[:-7] in defined_syms) \
975+
and not sym_name.startswith("BOARD_REVISION_"):
975976

976977
undef_to_locs[sym_name].append(f"{path}:{lineno}")
977978

0 commit comments

Comments
 (0)