From 85f9710603016d0e85d0ffcc5a2d784ac8d84aa1 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Fri, 17 Nov 2023 14:00:32 +0100 Subject: [PATCH] rimage: add TOML preprocessing TOML configuration files for rimage are composed of multiple logical blocks, and those blocks are repeated between multiple configuration files. We use the C preprocessor to merge those blocks, to substitude any parameter values and to perform condition checking. Signed-off-by: Guennadi Liakhovetski --- scripts/west_commands/sign.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/west_commands/sign.py b/scripts/west_commands/sign.py index bdf9d353685e..ddc5e65eb941 100644 --- a/scripts/west_commands/sign.py +++ b/scripts/west_commands/sign.py @@ -481,7 +481,7 @@ def sign(self, command, build_dir, build_conf, formats): #### -c sof/rimage/config/signing_schema.toml #### - cmake_toml = target + '.toml' + cmake_toml = target + '.toml.h' if not args.quiet: log.inf('Signing with tool {}'.format(tool_path)) @@ -504,7 +504,18 @@ def sign(self, command, build_dir, build_conf, formats): else: conf_dir = sof_src_dir / 'tools' / 'rimage' / 'config' - conf_path_cmd = ['-c', str(conf_dir / cmake_toml)] if conf_dir else [] + if conf_dir: + pre_toml = target + '.toml' + output_toml = str(b / 'zephyr' / pre_toml) + compiler_path = cache.get("CMAKE_C_COMPILER", "") + preproc_cmd = [compiler_path] + ['-E', str(conf_dir / cmake_toml)] + ['-o', output_toml] + preproc_cmd += ['-I', str(sof_src_dir / 'src')] + preproc_cmd += ['-imacros', str(b / 'zephyr' / 'include' / 'generated' / 'autoconf.h')] + log.inf('Calling preprocessor\n' + quote_sh_list(preproc_cmd)) + subprocess.check_call(preproc_cmd) + conf_path_cmd = ['-c', output_toml] + else: + conf_path_cmd = [] log.inf('Signing for SOC target ' + target)