scripts: modules: Mark the build as tainted if blobs present

Whenever binary blobs are present in the filesystem (i.e. fetched,
regardless of whether they are up-to-date or not) we consider the Zephyr
build as tainted. In order to ensure that it is marked as so, add a
Kconfig `select` statement whenever this is the case.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
Carles Cufi 2022-08-24 16:56:01 +02:00 committed by Carles Cufí
parent b662bc9093
commit 035dffcfcf

View File

@ -257,27 +257,32 @@ def process_blobs(module, meta):
return blobs
def kconfig_snippet(meta, path, kconfig_file=None):
def kconfig_snippet(meta, path, kconfig_file=None, blobs=False):
name = meta['name']
name_sanitized = meta['name-sanitized']
snippet = (f'menu "{name} ({path.as_posix()})"',
snippet = [f'menu "{name} ({path.as_posix()})"',
f'osource "{kconfig_file.resolve().as_posix()}"' if kconfig_file
else f'osource "$(ZEPHYR_{name_sanitized.upper()}_KCONFIG)"',
f'config ZEPHYR_{name_sanitized.upper()}_MODULE',
' bool',
' default y',
'endmenu\n')
'endmenu\n']
if blobs:
snippet.insert(-1, ' select TAINT_BLOBS')
return '\n'.join(snippet)
def process_kconfig(module, meta):
blobs = process_blobs(module, meta)
taint_blobs = len(tuple(filter(lambda b: b['status'] != 'D', blobs))) != 0
section = meta.get('build', dict())
module_path = PurePath(module)
module_yml = module_path.joinpath('zephyr/module.yml')
kconfig_extern = section.get('kconfig-ext', False)
if kconfig_extern:
return kconfig_snippet(meta, module_path)
return kconfig_snippet(meta, module_path, blobs=taint_blobs)
kconfig_setting = section.get('kconfig', None)
if not validate_setting(kconfig_setting, module):
@ -287,7 +292,8 @@ 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))
return kconfig_snippet(meta, module_path, Path(kconfig_file),
blobs=taint_blobs)
else:
return ""