Skip to content

Commit 088c8f4

Browse files
nordicjmkartben
authored andcommitted
Revert "west: fix for context with sysbuild"
This reverts commit 8972146. Signed-off-by: Jamie McCrae <[email protected]>
1 parent 018963e commit 088c8f4

File tree

1 file changed

+34
-83
lines changed

1 file changed

+34
-83
lines changed

scripts/west_commands/run_common.py

Lines changed: 34 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Copyright (c) 2018 Open Source Foundries Limited.
22
# Copyright (c) 2023 Nordic Semiconductor ASA
3-
# Copyright (c) 2025 Aerlync Labs Inc.
43
#
54
# SPDX-License-Identifier: Apache-2.0
65

@@ -182,34 +181,6 @@ def add_parser_common(command, parser_adder=None, parser=None):
182181

183182
return parser
184183

185-
def is_sysbuild(build_dir):
186-
# Check if the build directory is part of a sysbuild (multi-image build).
187-
domains_yaml_path = path.join(build_dir, "domains.yaml")
188-
return path.exists(domains_yaml_path)
189-
190-
def get_domains_to_process(build_dir, args, domain_file=None, get_all_domain=False):
191-
try:
192-
domains = load_domains(build_dir)
193-
except Exception as e:
194-
log.die(f"Failed to load domains: {e}")
195-
196-
if domain_file is None:
197-
if getattr(args, "domain", None) is None and get_all_domain:
198-
# This option for getting all available domains in the case of --context
199-
# So default domain will be used.
200-
return domains.get_domains()
201-
if getattr(args, "domain", None) is None:
202-
# No domains are passed down and no domains specified by the user.
203-
# So default domain will be used.
204-
return [domains.get_default_domain()]
205-
else:
206-
# No domains are passed down, but user has specified domains to use.
207-
# Get the user specified domains.
208-
return domains.get_domains(args.domain)
209-
else:
210-
# Use domains from domain file with flash order
211-
return domains.get_domains(args.domain, default_flash_order=True)
212-
213184
def do_run_common(command, user_args, user_runner_args, domain_file=None):
214185
# This is the main routine for all the "west flash", "west debug",
215186
# etc. commands.
@@ -247,7 +218,18 @@ def do_run_common(command, user_args, user_runner_args, domain_file=None):
247218
if not user_args.skip_rebuild:
248219
rebuild(command, build_dir, user_args)
249220

250-
domains = get_domains_to_process(build_dir, user_args)
221+
if domain_file is None:
222+
if user_args.domain is None:
223+
# No domains are passed down and no domains specified by the user.
224+
# So default domain will be used.
225+
domains = [load_domains(build_dir).get_default_domain()]
226+
else:
227+
# No domains are passed down, but user has specified domains to use.
228+
# Get the user specified domains.
229+
domains = load_domains(build_dir).get_domains(user_args.domain)
230+
else:
231+
domains = load_domains(build_dir).get_domains(user_args.domain,
232+
default_flash_order=True)
251233

252234
if len(domains) > 1:
253235
if len(user_runner_args) > 0:
@@ -711,71 +693,40 @@ def dump_traceback():
711693

712694
def dump_context(command, args, unknown_args):
713695
build_dir = get_build_dir(args, die_if_none=False)
714-
get_all_domain = False
715-
716696
if build_dir is None:
717697
log.wrn('no --build-dir given or found; output will be limited')
718-
dump_context_no_config(command, None)
719-
return
720-
721-
if is_sysbuild(build_dir):
722-
get_all_domain = True
698+
runners_yaml = None
699+
else:
700+
build_conf = BuildConfiguration(build_dir)
701+
board = build_conf.get('CONFIG_BOARD_TARGET')
702+
yaml_path = runners_yaml_path(build_dir, board)
703+
runners_yaml = load_runners_yaml(yaml_path)
723704

724705
# Re-build unless asked not to, to make sure the output is up to date.
725706
if build_dir and not args.skip_rebuild:
726707
rebuild(command, build_dir, args)
727708

728-
domains = get_domains_to_process(build_dir, args, None, get_all_domain)
729-
730-
if len(domains) > 1 and not getattr(args, "domain", None):
731-
log.inf("Multiple domains available:")
732-
for i, domain in enumerate(domains, 1):
733-
log.inf(f"{INDENT}{i}. {domain.name} (build_dir: {domain.build_dir})")
734-
735-
while True:
736-
try:
737-
choice = input(f"Select domain (1-{len(domains)}): ")
738-
choice = int(choice)
739-
if 1 <= choice <= len(domains):
740-
domains = [domains[choice-1]]
741-
break
742-
log.wrn(f"Please enter a number between 1 and {len(domains)}")
743-
except ValueError:
744-
log.wrn("Please enter a valid number")
745-
except EOFError:
746-
log.die("Input cancelled, exiting")
747-
748-
selected_build_dir = domains[0].build_dir
749-
750-
if not path.exists(selected_build_dir):
751-
log.die(f"Build directory does not exist: {selected_build_dir}")
752-
753-
build_conf = BuildConfiguration(selected_build_dir)
754-
755-
board = build_conf.get('CONFIG_BOARD_TARGET')
756-
if not board:
757-
log.die("CONFIG_BOARD_TARGET not found in build configuration.")
758-
759-
yaml_path = runners_yaml_path(selected_build_dir, board)
760-
if not path.exists(yaml_path):
761-
log.die(f"runners.yaml not found in: {yaml_path}")
762-
763-
runners_yaml = load_runners_yaml(yaml_path)
764-
765-
# Dump runner info
766-
log.inf(f'build configuration:', colorize=True)
767-
log.inf(f'{INDENT}build directory: {build_dir}')
768-
log.inf(f'{INDENT}board: {board}')
769-
log.inf(f'{INDENT}runners.yaml: {yaml_path}')
770709
if args.runner:
771710
try:
772711
cls = get_runner_cls(args.runner)
773-
dump_runner_context(command, cls, runners_yaml)
774712
except ValueError:
775-
available_runners = ", ".join(cls.name() for cls in ZephyrBinaryRunner.get_runners())
776-
log.die(f"Invalid runner name {args.runner}; choices: {available_runners}")
713+
log.die(f'invalid runner name {args.runner}; choices: ' +
714+
', '.join(cls.name() for cls in
715+
ZephyrBinaryRunner.get_runners()))
777716
else:
778-
dump_all_runner_context(command, runners_yaml, board, selected_build_dir)
717+
cls = None
718+
719+
if runners_yaml is None:
720+
dump_context_no_config(command, cls)
721+
else:
722+
log.inf(f'build configuration:', colorize=True)
723+
log.inf(f'{INDENT}build directory: {build_dir}')
724+
log.inf(f'{INDENT}board: {board}')
725+
log.inf(f'{INDENT}runners.yaml: {yaml_path}')
726+
if cls:
727+
dump_runner_context(command, cls, runners_yaml)
728+
else:
729+
dump_all_runner_context(command, runners_yaml, board, build_dir)
779730

780731
def dump_context_no_config(command, cls):
781732
if not cls:

0 commit comments

Comments
 (0)