scripts: zephyr_module: Add variable with module path

Adds a variable that has the path of the module directory, this
is supplied as an argument when running cmake normally but is
not supplied when running the check compliance script, this
addition allows checks to be ran that use such syntax in Kconfig
files. This is then removed from cmake as the python file handles
it instead

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit is contained in:
Jamie McCrae
2025-08-12 10:47:24 +01:00
committed by Benjamin Cabé
parent 86c72a19fc
commit ea9815ff34
2 changed files with 15 additions and 17 deletions

View File

@@ -99,15 +99,9 @@ zephyr_file(CONF_FILES ${BOARD_EXTENSION_DIRS} KCONF board_extension_conf_files
# separated list instead.
string(REPLACE ";" "?" DTS_ROOT_BINDINGS "${DTS_ROOT_BINDINGS}")
# Export each `ZEPHYR_<module>_MODULE_DIR` to Kconfig.
# This allows Kconfig files to refer relative from a modules root as:
# source "$(ZEPHYR_FOO_MODULE_DIR)/Kconfig"
# Export each `ZEPHYR_<module>_KCONFIG` to Kconfig.
foreach(module_name ${ZEPHYR_MODULE_NAMES})
zephyr_string(SANITIZE TOUPPER MODULE_NAME_UPPER ${module_name})
list(APPEND
ZEPHYR_KCONFIG_MODULES_DIR
"ZEPHYR_${MODULE_NAME_UPPER}_MODULE_DIR=${ZEPHYR_${MODULE_NAME_UPPER}_MODULE_DIR}"
)
if(ZEPHYR_${MODULE_NAME_UPPER}_KCONFIG)
list(APPEND

View File

@@ -393,8 +393,11 @@ def process_kconfig(module, meta):
module_path = PurePath(module)
module_yml = module_path.joinpath('zephyr/module.yml')
kconfig_extern = section.get('kconfig-ext', False)
name_sanitized = meta['name-sanitized']
snippet = f'ZEPHYR_{name_sanitized.upper()}_MODULE_DIR := {module_path.as_posix()}\n'
if kconfig_extern:
return kconfig_snippet(meta, module_path, blobs=blobs, taint_blobs=taint_blobs)
return snippet + kconfig_snippet(meta, module_path, blobs=blobs, taint_blobs=taint_blobs)
kconfig_setting = section.get('kconfig', None)
if not validate_setting(kconfig_setting, module):
@@ -404,12 +407,10 @@ def process_kconfig(module, meta):
kconfig_file = os.path.join(module, kconfig_setting or 'zephyr/Kconfig')
if os.path.isfile(kconfig_file):
return kconfig_snippet(meta, module_path, Path(kconfig_file),
blobs=blobs, taint_blobs=taint_blobs)
return snippet + kconfig_snippet(meta, module_path, Path(kconfig_file),
blobs=blobs, taint_blobs=taint_blobs)
else:
name_sanitized = meta['name-sanitized']
snippet = kconfig_module_opts(name_sanitized, blobs, taint_blobs)
return '\n'.join(snippet) + '\n'
return snippet + '\n'.join(kconfig_module_opts(name_sanitized, blobs, taint_blobs)) + '\n'
def process_sysbuildkconfig(module, meta):
@@ -417,8 +418,11 @@ def process_sysbuildkconfig(module, meta):
module_path = PurePath(module)
module_yml = module_path.joinpath('zephyr/module.yml')
kconfig_extern = section.get('sysbuild-kconfig-ext', False)
name_sanitized = meta['name-sanitized']
snippet = f'ZEPHYR_{name_sanitized.upper()}_MODULE_DIR := {module_path.as_posix()}\n'
if kconfig_extern:
return kconfig_snippet(meta, module_path, sysbuild=True)
return snippet + kconfig_snippet(meta, module_path, sysbuild=True)
kconfig_setting = section.get('sysbuild-kconfig', None)
if not validate_setting(kconfig_setting, module):
@@ -429,10 +433,10 @@ def process_sysbuildkconfig(module, meta):
if kconfig_setting is not None:
kconfig_file = os.path.join(module, kconfig_setting)
if os.path.isfile(kconfig_file):
return kconfig_snippet(meta, module_path, Path(kconfig_file))
return snippet + kconfig_snippet(meta, module_path, Path(kconfig_file))
name_sanitized = meta['name-sanitized']
return (f'config ZEPHYR_{name_sanitized.upper()}_MODULE\n'
return snippet + \
(f'config ZEPHYR_{name_sanitized.upper()}_MODULE\n'
f' bool\n'
f' default y\n')