diff --git a/scripts/zephyr_module.py b/scripts/zephyr_module.py index 93928f65a1b..c6043154bdc 100755 --- a/scripts/zephyr_module.py +++ b/scripts/zephyr_module.py @@ -325,21 +325,37 @@ def process_blobs(module, meta): return blobs -def kconfig_snippet(meta, path, kconfig_file=None, blobs=False, sysbuild=False): +def kconfig_module_opts(name_sanitized, blobs, taint_blobs): + snippet = [f'config ZEPHYR_{name_sanitized.upper()}_MODULE', + ' bool', + ' default y'] + + if taint_blobs: + snippet += [' select TAINT_BLOBS'] + + if blobs: + snippet += [f'\nconfig ZEPHYR_{name_sanitized.upper()}_MODULE_BLOBS', + ' bool'] + if taint_blobs: + snippet += [' default y'] + + return snippet + + +def kconfig_snippet(meta, path, kconfig_file=None, blobs=False, taint_blobs=False, sysbuild=False): name = meta['name'] name_sanitized = meta['name-sanitized'] - snippet = [f'menu "{name} ({path.as_posix()})"', - f'osource "{kconfig_file.resolve().as_posix()}"' if kconfig_file - else f'osource "$(SYSBUILD_{name_sanitized.upper()}_KCONFIG)"' if sysbuild is True - else f'osource "$(ZEPHYR_{name_sanitized.upper()}_KCONFIG)"', - f'config ZEPHYR_{name_sanitized.upper()}_MODULE', - ' bool', - ' default y', - 'endmenu\n'] + snippet = [f'menu "{name} ({path.as_posix()})"'] + + snippet += [f'osource "{kconfig_file.resolve().as_posix()}"' if kconfig_file + else f'osource "$(SYSBUILD_{name_sanitized.upper()}_KCONFIG)"' if sysbuild is True + else f'osource "$(ZEPHYR_{name_sanitized.upper()}_KCONFIG)"'] + + snippet += kconfig_module_opts(name_sanitized, blobs, taint_blobs) + + snippet += ['endmenu\n'] - if blobs: - snippet.insert(-1, ' select TAINT_BLOBS') return '\n'.join(snippet) @@ -351,7 +367,7 @@ def process_kconfig(module, meta): module_yml = module_path.joinpath('zephyr/module.yml') kconfig_extern = section.get('kconfig-ext', False) if kconfig_extern: - return kconfig_snippet(meta, module_path, blobs=taint_blobs) + return kconfig_snippet(meta, module_path, blobs=blobs, taint_blobs=taint_blobs) kconfig_setting = section.get('kconfig', None) if not validate_setting(kconfig_setting, module): @@ -362,12 +378,11 @@ 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=taint_blobs) + blobs=blobs, taint_blobs=taint_blobs) else: name_sanitized = meta['name-sanitized'] - return (f'config ZEPHYR_{name_sanitized.upper()}_MODULE\n' - f' bool\n' - f' default y\n') + snippet = kconfig_module_opts(name_sanitized, blobs, taint_blobs) + return '\n'.join(snippet) + '\n' def process_sysbuildkconfig(module, meta):