Commit graph

7 commits

Author SHA1 Message Date
Lukasz Mrugala 2fcf4e3499 scripts: pylib: build_helpers: flash_order fix
If flash_order were to be missing from the YAML, the Domains init
would crash instead of substituting an empty list.
This commit fixes that.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2023-10-10 15:55:58 +03:00
Grzegorz Swiderski 9bbf7e5a48 scripts: domains: Convert Domain to a dataclass
For conciseness.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2023-10-04 18:04:18 +02:00
Grzegorz Swiderski 652b0a8a98 scripts: domains: Support initialization only from YAML
By requiring a full-on YAML fragment, the Domains class can rely on
pykwalify to do the heavy lifting with validating types and structure.
Remove support for loading domains from a dictionary, so that we don't
ever have to replicate the same checks on the input, and we can instead
have a single entry point.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2023-10-04 18:04:18 +02:00
Grzegorz Swiderski f82e2ef043 scripts: domains: Tighten up initialization
Do extra checks to reject inconsistent `domains.yaml` contents early:

   default: app
   build_dir: /path/to/build
   domains:
     - name: image_1
       build_dir: /path/to/build/image_1
     - name: image_2
       build_dir: /path/to/build/image_2
   flash_order:
     - image_1
     - image_2
     - unknown

This example lists "image_1" and "image_2" as known domains, but an
entry for the default "app" is missing, which should never be allowed.
A valid `domains.yaml` file shall also not contain extra domains under
`flash_order`, such as "unknown", which doesn't appear under `domains`.
Either of these cases can now be caught while initializing an instance
of the Domains class.

It follows that a valid `domains.yaml` file must always contain a list
of domains with at least one entry - the default image. Since `default`
is a required key in the YAML schema, `domains` should be required too.
Thus, empty lists will be rejected by pykwalify, so the questionable
warning for "no domains defined; this probably won't work" can be axed.

Fixes #63166

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2023-10-04 18:04:18 +02:00
Grzegorz Swiderski 05d7769073 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>
2023-09-27 17:49:12 +02:00
Daniel DeGrasse c303c6fae7 scripts: pylib: remove west log dependency from domains.py
Convert domains.py to use basic python logging module implementation to
remove west logging dependency. This removes hard dependency on west from
twister.

Fixes #51731

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-11-14 10:12:31 +00:00
Daniel DeGrasse 6a5b88e523 scripts: west: move domains.py to a generic library folder
Since twister can make use of domains.py as well, refactor west's use
this file so that domains.py can be moved to a generic library folder.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-26 08:48:37 -04:00