Skip to content

Commit

Permalink
west: build: also parse common section in yaml file
Browse files Browse the repository at this point in the history
Parse common section and append to cmake args if available when using
--test-item option of west build.

Signed-off-by: Anas Nashif <[email protected]>
  • Loading branch information
nashif committed Jul 24, 2023
1 parent 90f388e commit 6fdfc91
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions scripts/west_commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,30 +270,37 @@ 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}")
item = tests.get(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):
Expand Down

0 comments on commit 6fdfc91

Please sign in to comment.