diff --git a/cmake/modules/kconfig.cmake b/cmake/modules/kconfig.cmake index def17f16ae6..ac5f1b83e4c 100644 --- a/cmake/modules/kconfig.cmake +++ b/cmake/modules/kconfig.cmake @@ -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_DIR` to Kconfig. -# This allows Kconfig files to refer relative from a modules root as: -# source "$(ZEPHYR_FOO_MODULE_DIR)/Kconfig" +# Export each `ZEPHYR__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 diff --git a/scripts/zephyr_module.py b/scripts/zephyr_module.py index 8aabe676784..aeda845639e 100755 --- a/scripts/zephyr_module.py +++ b/scripts/zephyr_module.py @@ -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')