|
1 | 1 | # Copyright (c) 2018 Open Source Foundries Limited.
|
2 | 2 | # Copyright (c) 2023 Nordic Semiconductor ASA
|
3 |
| -# Copyright (c) 2025 Aerlync Labs Inc. |
4 | 3 | #
|
5 | 4 | # SPDX-License-Identifier: Apache-2.0
|
6 | 5 |
|
@@ -182,34 +181,6 @@ def add_parser_common(command, parser_adder=None, parser=None):
|
182 | 181 |
|
183 | 182 | return parser
|
184 | 183 |
|
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 |
| - |
213 | 184 | def do_run_common(command, user_args, user_runner_args, domain_file=None):
|
214 | 185 | # This is the main routine for all the "west flash", "west debug",
|
215 | 186 | # etc. commands.
|
@@ -247,7 +218,18 @@ def do_run_common(command, user_args, user_runner_args, domain_file=None):
|
247 | 218 | if not user_args.skip_rebuild:
|
248 | 219 | rebuild(command, build_dir, user_args)
|
249 | 220 |
|
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) |
251 | 233 |
|
252 | 234 | if len(domains) > 1:
|
253 | 235 | if len(user_runner_args) > 0:
|
@@ -711,71 +693,40 @@ def dump_traceback():
|
711 | 693 |
|
712 | 694 | def dump_context(command, args, unknown_args):
|
713 | 695 | build_dir = get_build_dir(args, die_if_none=False)
|
714 |
| - get_all_domain = False |
715 |
| - |
716 | 696 | if build_dir is None:
|
717 | 697 | 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) |
723 | 704 |
|
724 | 705 | # Re-build unless asked not to, to make sure the output is up to date.
|
725 | 706 | if build_dir and not args.skip_rebuild:
|
726 | 707 | rebuild(command, build_dir, args)
|
727 | 708 |
|
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}') |
770 | 709 | if args.runner:
|
771 | 710 | try:
|
772 | 711 | cls = get_runner_cls(args.runner)
|
773 |
| - dump_runner_context(command, cls, runners_yaml) |
774 | 712 | 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())) |
777 | 716 | 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) |
779 | 730 |
|
780 | 731 | def dump_context_no_config(command, cls):
|
781 | 732 | if not cls:
|
|
0 commit comments