scripts: zephyr_module: Add Kconfig symbol for blobs presence
For any module that defines blobs, add a new Kconfig symbol to indicate
whether the blobs have been fetched or not. Example output for the
hal_silabs module:
# (no blobs present)
$ scripts/zephyr_module.py --kconfig-out=/dev/stdout \
-m ../modules/hal/silabs
menu "hal_silabs (../modules/hal/silabs)"
osource "/Users/johedber/src/zephyr/modules/hal/silabs/zephyr/Kconfig"
config ZEPHYR_HAL_SILABS_MODULE
bool
default y
config ZEPHYR_HAL_SILABS_MODULE_BLOBS
bool
endmenu
$ west blobs fetch hal_silabs
# (blob fetching output)
$ scripts/zephyr_module.py --kconfig-out=/dev/stdout \
-m ../modules/hal/silabs
menu "hal_silabs (../modules/hal/silabs)"
osource "/Users/johedber/src/zephyr/modules/hal/silabs/zephyr/Kconfig"
config ZEPHYR_HAL_SILABS_MODULE
bool
default y
select TAINT_BLOBS
config ZEPHYR_HAL_SILABS_MODULE_BLOBS
bool
default y
endmenu
The generated output for modules which do not define blobs is not affected.
Having this additional symbol for blobs lets us specify Kconfig
dependencies for features which require the blobs to be present.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
diff --git a/scripts/zephyr_module.py b/scripts/zephyr_module.py
index 93928f6..c604315 100755
--- a/scripts/zephyr_module.py
+++ b/scripts/zephyr_module.py
@@ -325,21 +325,37 @@
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()})"']
- if blobs:
- snippet.insert(-1, ' select TAINT_BLOBS')
+ 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']
+
return '\n'.join(snippet)
@@ -351,7 +367,7 @@
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 @@
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):