summaryrefslogtreecommitdiff
path: root/zephyr/zmake/zmake/project.py
diff options
context:
space:
mode:
authorTristan Honscheid <honscheid@google.com>2023-04-04 13:33:49 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-06 22:55:35 +0000
commit171aa03229bff92769583d78252fb13fc8d32247 (patch)
treec13ac4247f1731408a7931099800990d7070c241 /zephyr/zmake/zmake/project.py
parent67d4a05823bcf880117611942bcd0025274c1ed5 (diff)
downloadchrome-ec-171aa03229bff92769583d78252fb13fc8d32247.tar.gz
zmake: Track project inheritance in ProjectConfig
Add an `inherited_from` list field to the ProjectConfig dataclass that tracks what project(s) the current project inherited from. When using the `.variant()` project resgistration method, `inherited_from` is automatically appended with the base project's name. When the following `BUILD.py` file is processed... ``` baseboard = register_raw_project(project_name="base") variant1 = baseboard.variant(project_name="variant1") variant2 = variant1.variant(project_name="variant2") ``` ... variant1's `config.inherited_from` field will be `['base']` and variant2's will be `['base','variant1']. It is also possible to manually specify `inherited_from` when registering a project (either as a string or list of strings): ``` register_raw_project( project_name="myboard", inherited_from=["root","baseboard1"], ) ``` This method is how the EC's `BUILD.py` files are configured. In either case, the project's full name can be accessed by reading the ProjectConfig object's `full_name` property to join the names of the parent boards plus the current project name. In the case of the above example, the property would read `"root.baseboard1.myboard"`. The full name is not consumed anywhere within zmake; it is intended to be used for external reporting tools and does not affect the builds. BRANCH=None BUG=b:276947804 TEST=zephyr/zmake/run_tests.sh Change-Id: I7d7413175c9c670a64e7ade01a41e46a2fb8d743 Signed-off-by: Tristan Honscheid <honscheid@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4400532 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/zmake/zmake/project.py')
-rw-r--r--zephyr/zmake/zmake/project.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/zephyr/zmake/zmake/project.py b/zephyr/zmake/zmake/project.py
index 3c18520b55..2c91e27ba7 100644
--- a/zephyr/zmake/zmake/project.py
+++ b/zephyr/zmake/zmake/project.py
@@ -52,6 +52,20 @@ class ProjectConfig:
default_factory=list
)
project_dir: pathlib.Path = dataclasses.field(default_factory=pathlib.Path)
+ inherited_from: typing.Iterable[str] = dataclasses.field(
+ default_factory=list
+ )
+
+ @property
+ def full_name(self) -> str:
+ """Get the full project name, e.g. baseboard.variant"""
+ inherited_from = (
+ [self.inherited_from]
+ if isinstance(self.inherited_from, str)
+ else self.inherited_from
+ )
+
+ return ".".join([*inherited_from, self.project_name])
class Project:
@@ -198,12 +212,16 @@ class ProjectRegistrationHandler:
Another ProjectRegistrationHandler.
"""
new_config = dataclasses.asdict(self.base_config)
+ new_config["inherited_from"] = [
+ *self.base_config.inherited_from,
+ self.base_config.project_name,
+ ]
+
for key, value in kwargs.items():
if isinstance(value, list):
new_config[key] = [*new_config[key], *value]
else:
new_config[key] = value
-
return self.register_func(**new_config)