Skip to content

Commit 6fdfc91

Browse files
committed
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 <[email protected]>
1 parent 90f388e commit 6fdfc91

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

scripts/west_commands/build.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -270,30 +270,37 @@ def _parse_test_item(self, test_item):
270270
y = yaml.safe_load(stream)
271271
except yaml.YAMLError as exc:
272272
log.die(exc)
273+
common = y.get('common')
273274
tests = y.get('tests')
274275
if not tests:
275276
log.die(f"No tests found in {yf}")
276277
item = tests.get(test_item)
277278
if not item:
278279
log.die(f"Test item {test_item} not found in {yf}")
279280

280-
for data in ['extra_args', 'extra_configs']:
281-
extra = item.get(data)
282-
if not extra:
281+
sysbuild = False
282+
for section in [common, item]:
283+
if not section:
283284
continue
284-
if isinstance(extra, str):
285-
arg_list = extra.split(" ")
286-
else:
287-
arg_list = extra
288-
if data == 'extra_configs':
289-
args = ["-D{}".format(arg.replace('"', '\"')) for arg in arg_list]
290-
elif data == 'extra_args':
291-
args = ["-D{}".format(arg.replace('"', '')) for arg in arg_list]
292-
if self.args.cmake_opts:
293-
self.args.cmake_opts.extend(args)
294-
else:
295-
self.args.cmake_opts = args
296-
self.args.sysbuild = item.get('sysbuild')
285+
sysbuild = section.get('sysbuild', sysbuild)
286+
for data in ['extra_args', 'extra_configs']:
287+
extra = section.get(data)
288+
if not extra:
289+
continue
290+
if isinstance(extra, str):
291+
arg_list = extra.split(" ")
292+
else:
293+
arg_list = extra
294+
if data == 'extra_configs':
295+
args = ["-D{}".format(arg.replace('"', '\"')) for arg in arg_list]
296+
elif data == 'extra_args':
297+
args = ["-D{}".format(arg.replace('"', '')) for arg in arg_list]
298+
if self.args.cmake_opts:
299+
self.args.cmake_opts.extend(args)
300+
else:
301+
self.args.cmake_opts = args
302+
303+
self.args.sysbuild = sysbuild
297304
return found_test_metadata
298305

299306
def _sanity_precheck(self):

0 commit comments

Comments
 (0)