Skip to content

Commit 80849dd

Browse files
committed
[nrf fromlist] 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 Upstream PR #: 94388 Signed-off-by: Jamie McCrae <[email protected]>
1 parent 6997770 commit 80849dd

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

cmake/modules/kconfig.cmake

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,9 @@ zephyr_file(CONF_FILES ${BOARD_EXTENSION_DIRS} KCONF board_extension_conf_files
9999
# separated list instead.
100100
string(REPLACE ";" "?" DTS_ROOT_BINDINGS "${DTS_ROOT_BINDINGS}")
101101

102-
# Export each `ZEPHYR_<module>_MODULE_DIR` to Kconfig.
103-
# This allows Kconfig files to refer relative from a modules root as:
104-
# source "$(ZEPHYR_FOO_MODULE_DIR)/Kconfig"
102+
# Export each `ZEPHYR_<module>_KCONFIG` to Kconfig.
105103
foreach(module_name ${ZEPHYR_MODULE_NAMES})
106104
zephyr_string(SANITIZE TOUPPER MODULE_NAME_UPPER ${module_name})
107-
list(APPEND
108-
ZEPHYR_KCONFIG_MODULES_DIR
109-
"ZEPHYR_${MODULE_NAME_UPPER}_MODULE_DIR=${ZEPHYR_${MODULE_NAME_UPPER}_MODULE_DIR}"
110-
)
111105

112106
if(ZEPHYR_${MODULE_NAME_UPPER}_KCONFIG)
113107
list(APPEND

scripts/zephyr_module.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,11 @@ def process_kconfig(module, meta):
393393
module_path = PurePath(module)
394394
module_yml = module_path.joinpath('zephyr/module.yml')
395395
kconfig_extern = section.get('kconfig-ext', False)
396+
name_sanitized = meta['name-sanitized']
397+
snippet = f'ZEPHYR_{name_sanitized.upper()}_MODULE_DIR := {module_path.as_posix()}\n'
398+
396399
if kconfig_extern:
397-
return kconfig_snippet(meta, module_path, blobs=blobs, taint_blobs=taint_blobs)
400+
return snippet + kconfig_snippet(meta, module_path, blobs=blobs, taint_blobs=taint_blobs)
398401

399402
kconfig_setting = section.get('kconfig', None)
400403
if not validate_setting(kconfig_setting, module):
@@ -404,21 +407,22 @@ def process_kconfig(module, meta):
404407

405408
kconfig_file = os.path.join(module, kconfig_setting or 'zephyr/Kconfig')
406409
if os.path.isfile(kconfig_file):
407-
return kconfig_snippet(meta, module_path, Path(kconfig_file),
408-
blobs=blobs, taint_blobs=taint_blobs)
410+
return snippet + kconfig_snippet(meta, module_path, Path(kconfig_file),
411+
blobs=blobs, taint_blobs=taint_blobs)
409412
else:
410-
name_sanitized = meta['name-sanitized']
411-
snippet = kconfig_module_opts(name_sanitized, blobs, taint_blobs)
412-
return '\n'.join(snippet) + '\n'
413+
return snippet + '\n'.join(kconfig_module_opts(name_sanitized, blobs, taint_blobs)) + '\n'
413414

414415

415416
def process_sysbuildkconfig(module, meta):
416417
section = meta.get('build', dict())
417418
module_path = PurePath(module)
418419
module_yml = module_path.joinpath('zephyr/module.yml')
419420
kconfig_extern = section.get('sysbuild-kconfig-ext', False)
421+
name_sanitized = meta['name-sanitized']
422+
snippet = f'ZEPHYR_{name_sanitized.upper()}_MODULE_DIR := {module_path.as_posix()}\n'
423+
420424
if kconfig_extern:
421-
return kconfig_snippet(meta, module_path, sysbuild=True)
425+
return snippet + kconfig_snippet(meta, module_path, sysbuild=True)
422426

423427
kconfig_setting = section.get('sysbuild-kconfig', None)
424428
if not validate_setting(kconfig_setting, module):
@@ -429,10 +433,10 @@ def process_sysbuildkconfig(module, meta):
429433
if kconfig_setting is not None:
430434
kconfig_file = os.path.join(module, kconfig_setting)
431435
if os.path.isfile(kconfig_file):
432-
return kconfig_snippet(meta, module_path, Path(kconfig_file))
436+
return snippet + kconfig_snippet(meta, module_path, Path(kconfig_file))
433437

434-
name_sanitized = meta['name-sanitized']
435-
return (f'config ZEPHYR_{name_sanitized.upper()}_MODULE\n'
438+
return snippet + \
439+
(f'config ZEPHYR_{name_sanitized.upper()}_MODULE\n'
436440
f' bool\n'
437441
f' default y\n')
438442

0 commit comments

Comments
 (0)