sysbuild: Do not exclude images from domains.yaml
The recent support for BUILD_ONLY images was implemented by excluding them from `domains.yaml`, in order to crudely prevent them from being picked up by `west flash`. Arguably, this is incorrect or unexpected, because the sysbuild documentation defines a "domain" as: Every Zephyr CMake build system managed by sysbuild. Another consequence is that, given a build-only `<image>`, this makes it impossible to pass `--domain <image>` to `west flash`, `west debug`, and ironically `west build`. To fix that, `domains.yaml` should again represent all domains, and the build-only ones should be indicated in another way. Enter `flash_order`: a new top-level key in the domains YAML schema. It contains the default sequence of images used by `west flash`, where the build-only images are excluded, and the order is influenced by `sysbuild_add_dependencies()`. Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
This commit is contained in:
parent
14348c53d4
commit
05d7769073
|
@ -38,6 +38,11 @@ mapping:
|
|||
build_dir:
|
||||
required: true
|
||||
type: str
|
||||
flash_order:
|
||||
required: false
|
||||
type: seq
|
||||
sequence:
|
||||
- type: str
|
||||
'''
|
||||
|
||||
schema = yaml.safe_load(DOMAINS_SCHEMA)
|
||||
|
@ -52,21 +57,19 @@ logger.addHandler(handler)
|
|||
class Domains:
|
||||
|
||||
def __init__(self, data):
|
||||
self._domains = []
|
||||
self._domain_names = []
|
||||
self._domain_default = []
|
||||
|
||||
self._build_dir = data.get('build_dir')
|
||||
domain_list = data.get('domains')
|
||||
domain_list = data.get('domains') or []
|
||||
if not domain_list:
|
||||
logger.warning("no domains defined; this probably won't work")
|
||||
|
||||
for d in domain_list:
|
||||
domain = Domain(d['name'], d['build_dir'])
|
||||
self._domains.append(domain)
|
||||
self._domain_names.append(domain.name)
|
||||
if domain.name == data['default']:
|
||||
self._default_domain = domain
|
||||
self._domains = {
|
||||
d['name']: Domain(d['name'], d['build_dir'])
|
||||
for d in domain_list
|
||||
}
|
||||
self._default_domain = self._domains.get(data['default'])
|
||||
|
||||
domains_flash_order = data.get('flash_order') or []
|
||||
self._flash_order = list(map(self._domains.get, domains_flash_order))
|
||||
|
||||
@staticmethod
|
||||
def from_file(domains_file):
|
||||
|
@ -97,25 +100,21 @@ class Domains:
|
|||
'''
|
||||
return Domains(domains_data)
|
||||
|
||||
def get_domains(self, names=None):
|
||||
def get_domains(self, names=None, default_flash_order=False):
|
||||
ret = []
|
||||
|
||||
if not names:
|
||||
return self._domains
|
||||
if default_flash_order:
|
||||
return self._flash_order
|
||||
return list(self._domains.values())
|
||||
|
||||
for n in names:
|
||||
found = False
|
||||
for d in self._domains:
|
||||
if n == d.name:
|
||||
ret.append(d)
|
||||
found = True
|
||||
break
|
||||
# Getting here means the domain was not found.
|
||||
# Todo: throw an error.
|
||||
found = self._domains.get(n)
|
||||
if not found:
|
||||
logger.critical(f'domain {n} not found, '
|
||||
f'valid domains are:', *self._domain_names)
|
||||
f'valid domains are: {", ".join(self._domains)}')
|
||||
exit(1)
|
||||
ret.append(found)
|
||||
return ret
|
||||
|
||||
def get_default_domain(self):
|
||||
|
|
|
@ -153,6 +153,7 @@ def load_domains(path):
|
|||
if not domains_file.is_file():
|
||||
return Domains.from_data({'default': 'app',
|
||||
'build_dir': path,
|
||||
'domains': [{'name': 'app', 'build_dir': path}]})
|
||||
'domains': [{'name': 'app', 'build_dir': path}],
|
||||
'flash_order': ['app']})
|
||||
|
||||
return Domains.from_file(domains_file)
|
||||
|
|
|
@ -28,5 +28,6 @@ class Flash(WestCommand):
|
|||
|
||||
def do_run(self, my_args, runner_args):
|
||||
build_dir = get_build_dir(my_args)
|
||||
domains = load_domains(build_dir).get_domains(my_args.domain)
|
||||
domains = load_domains(build_dir).get_domains(my_args.domain,
|
||||
default_flash_order=True)
|
||||
do_run_common(self, my_args, runner_args, domains=domains)
|
||||
|
|
|
@ -7,12 +7,13 @@ sysbuild_images_order(IMAGES_FLASHING_ORDER FLASH IMAGES ${IMAGES})
|
|||
set(domains_yaml "default: ${DEFAULT_IMAGE}")
|
||||
set(domains_yaml "${domains_yaml}\nbuild_dir: ${CMAKE_BINARY_DIR}")
|
||||
set(domains_yaml "${domains_yaml}\ndomains:")
|
||||
foreach(image ${IMAGES_FLASHING_ORDER})
|
||||
get_target_property(image_is_build_only ${image} BUILD_ONLY)
|
||||
if(image_is_build_only)
|
||||
continue()
|
||||
endif()
|
||||
foreach(image ${IMAGES})
|
||||
set(domains_yaml "${domains_yaml}\n - name: ${image}")
|
||||
set(domains_yaml "${domains_yaml}\n build_dir: $<TARGET_PROPERTY:${image},_EP_BINARY_DIR>")
|
||||
endforeach()
|
||||
set(domains_yaml "${domains_yaml}\nflash_order:")
|
||||
foreach(image ${IMAGES_FLASHING_ORDER})
|
||||
set(flash_cond "$<NOT:$<BOOL:$<TARGET_PROPERTY:${image},BUILD_ONLY>>>")
|
||||
set(domains_yaml "${domains_yaml}$<${flash_cond}:\n - ${image}>")
|
||||
endforeach()
|
||||
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/domains.yaml CONTENT "${domains_yaml}")
|
||||
|
|
Loading…
Reference in a new issue