From 6fdfc91a6c111c7210b30840e526f6604fcbc610 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Wed, 19 Jul 2023 02:01:52 +0000 Subject: [PATCH] west: build: also parse common section in yaml file Parse common section and append to cmake args if available when using --test-item option of west build. Signed-off-by: Anas Nashif --- scripts/west_commands/build.py | 39 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/scripts/west_commands/build.py b/scripts/west_commands/build.py index a9a156125ce089..4f600bd881e77d 100644 --- a/scripts/west_commands/build.py +++ b/scripts/west_commands/build.py @@ -270,6 +270,7 @@ def _parse_test_item(self, test_item): y = yaml.safe_load(stream) except yaml.YAMLError as exc: log.die(exc) + common = y.get('common') tests = y.get('tests') if not tests: log.die(f"No tests found in {yf}") @@ -277,23 +278,29 @@ def _parse_test_item(self, test_item): if not item: log.die(f"Test item {test_item} not found in {yf}") - for data in ['extra_args', 'extra_configs']: - extra = item.get(data) - if not extra: + sysbuild = False + for section in [common, item]: + if not section: continue - if isinstance(extra, str): - arg_list = extra.split(" ") - else: - arg_list = extra - if data == 'extra_configs': - args = ["-D{}".format(arg.replace('"', '\"')) for arg in arg_list] - elif data == 'extra_args': - args = ["-D{}".format(arg.replace('"', '')) for arg in arg_list] - if self.args.cmake_opts: - self.args.cmake_opts.extend(args) - else: - self.args.cmake_opts = args - self.args.sysbuild = item.get('sysbuild') + sysbuild = section.get('sysbuild', sysbuild) + for data in ['extra_args', 'extra_configs']: + extra = section.get(data) + if not extra: + continue + if isinstance(extra, str): + arg_list = extra.split(" ") + else: + arg_list = extra + if data == 'extra_configs': + args = ["-D{}".format(arg.replace('"', '\"')) for arg in arg_list] + elif data == 'extra_args': + args = ["-D{}".format(arg.replace('"', '')) for arg in arg_list] + if self.args.cmake_opts: + self.args.cmake_opts.extend(args) + else: + self.args.cmake_opts = args + + self.args.sysbuild = sysbuild return found_test_metadata def _sanity_precheck(self):