scripts: west commands to support --domain
This commit extends the west commands build, flash, and debug to support
--domain when having multiple domains (images) defined in a domains.yaml
build file.
The domains.yaml uses the following yaml format to specify the
build directory of each domain in the multi image build:
> default: <domain-n>
> domains:
> <domain-1>:
> build_dir: <build_dir-domain-1>
> <domain-2>:
> build_dir: <build_dir-domain-2>
> ...
`west <build|flash|debug>` has been extended to support
`--domain <domain>`.
`west build` calls CMake to create the build system, and if `--domain`
is given, then the build tool will be invoked afterwards for the
specified domain.
`west flash` will default flash all domains, but `--domain <domain>`
argument can be used to select a specific domain to flash, for example:
> west flash --domain mcuboot
`west debug` only a single domain can be debugged at any given time.
If `--domain` is not specified, then the default domain specified in the
domains.yml file will be used.
Users can still select a different domain, for example with:
> west debug --domain mcuboot
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
diff --git a/scripts/west_commands/build_helpers.py b/scripts/west_commands/build_helpers.py
index a54978f..eca5bde 100644
--- a/scripts/west_commands/build_helpers.py
+++ b/scripts/west_commands/build_helpers.py
@@ -16,6 +16,7 @@
from west import log
from west.configuration import config
from west.util import escapes_directory
+from domains import Domains
DEFAULT_BUILD_DIR = 'build'
'''Name of the default Zephyr build directory.'''
@@ -133,3 +134,19 @@
log.dbg(f'{path} is NOT a valid zephyr build directory',
level=log.VERBOSE_EXTREME)
return False
+
+
+def load_domains(path):
+ '''Load domains from a domains.yaml.
+
+ If domains.yaml is not found, then a single 'app' domain referring to the
+ top-level build folder is created and returned.
+ '''
+ domains_file = Path(path) / 'domains.yaml'
+
+ if not domains_file.is_file():
+ return Domains.from_data({'default': 'app',
+ 'build_dir': path,
+ 'domains': [{'name': 'app', 'build_dir': path}]})
+
+ return Domains.from_file(domains_file)