You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ju...@apache.org on 2024/03/22 16:19:10 UTC
(buildstream) branch juerg/junction-aliases created (now 1cb4c9fb9)
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a change to branch juerg/junction-aliases
in repository https://gitbox.apache.org/repos/asf/buildstream.git
at 1cb4c9fb9 Support mapping subproject aliases to aliases of the parent project
This branch includes the following new commits:
new 1cb4c9fb9 Support mapping subproject aliases to aliases of the parent project
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(buildstream) 01/01: Support mapping subproject aliases to aliases of the parent project
Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a commit to branch juerg/junction-aliases
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 1cb4c9fb99e5491d68d6ae3e2c57b30d82109931
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Fri Mar 22 15:17:06 2024 +0100
Support mapping subproject aliases to aliases of the parent project
---
src/buildstream/_project.py | 38 +++++++++++++++++++++++++++-
src/buildstream/plugins/elements/junction.py | 8 +++++-
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index 1a1054898..6ae488731 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -102,6 +102,7 @@ class Project:
self.ref_storage: Optional[ProjectRefStorage] = None # Where to store source refs
self.refs: Optional[ProjectRefs] = None
self.junction_refs: Optional[ProjectRefs] = None
+ self.allow_subproject_uris: bool = True
self.config: ProjectConfig = ProjectConfig()
self.first_pass_config: ProjectConfig = ProjectConfig()
@@ -220,6 +221,17 @@ class Project:
url_alias, url_body = url.split(utils._ALIAS_SEPARATOR, 1)
alias_url = config._aliases.get_str(url_alias, default=None)
if alias_url:
+ if self.junction:
+ parent_project = self.junction._get_project()
+ parent_alias = self.junction.aliases.get_str(url_alias, default=None)
+ if parent_alias:
+ # Delegate translation to parent project
+ return parent_project.translate_url(
+ parent_alias + utils._ALIAS_SEPARATOR + url_body, first_pass=first_pass
+ )
+ elif not parent_project.allow_subproject_uris:
+ return url
+
url = alias_url + url_body
return url
@@ -377,6 +389,14 @@ class Project:
else:
config = self.config
+ if self.junction:
+ parent_project = self.junction._get_project()
+ parent_alias = self.junction.aliases.get_str(alias, default=None)
+ if parent_alias:
+ return parent_project.alias_exists(parent_alias, first_pass=first_pass)
+ elif not parent_project.allow_subproject_uris:
+ return False
+
return config._aliases.get_str(alias, default=None) is not None
# get_alias_uris()
@@ -396,6 +416,15 @@ class Project:
if not alias or alias not in config._aliases: # pylint: disable=unsupported-membership-test
return [None]
+ if self.junction:
+ parent_project = self.junction._get_project()
+ parent_alias = self.junction.aliases.get_str(alias, default=None)
+ if parent_alias:
+ # Delegate translation to parent project
+ return parent_project.get_alias_uris(parent_alias, first_pass=first_pass, tracking=tracking)
+ elif not parent_project.allow_subproject_uris:
+ return [None]
+
uri_list = []
policy = self._context.track_source if tracking else self._context.fetch_source
@@ -786,7 +815,14 @@ class Project:
# Junction configuration
junctions_node = pre_config_node.get_mapping("junctions", default={})
- junctions_node.validate_keys(["duplicates", "internal"])
+ junctions_node.validate_keys(["duplicates", "internal", "allow-subproject-uris"])
+
+ if self.junction and not self.junction._get_project().allow_subproject_uris:
+ # If the parent project doesn't allow subproject URIs, this must
+ # be enforced for nested subprojects as well.
+ self.allow_subproject_uris = False
+ else:
+ self.allow_subproject_uris = junctions_node.get_bool("allow-subproject-uris", default=True)
# Parse duplicates
junction_duplicates = junctions_node.get_mapping("duplicates", default={})
diff --git a/src/buildstream/plugins/elements/junction.py b/src/buildstream/plugins/elements/junction.py
index d35ed6317..7ce3a07f6 100644
--- a/src/buildstream/plugins/elements/junction.py
+++ b/src/buildstream/plugins/elements/junction.py
@@ -50,6 +50,9 @@ Overview
overrides:
subproject-junction.bst: local-junction.bst
+ aliases:
+ subproject-alias: local-alias
+
With a junction element in place, local elements can depend on elements in
the other BuildStream project using :ref:`element paths <format_element_names>`.
For example, if you have a ``toolchain.bst`` junction element referring to
@@ -338,7 +341,7 @@ class JunctionElement(Element):
def configure(self, node):
- node.validate_keys(["path", "options", "overrides"])
+ node.validate_keys(["path", "options", "overrides", "aliases"])
self.path = node.get_str("path", default="")
self.options = node.get_mapping("options", default={})
@@ -361,6 +364,9 @@ class JunctionElement(Element):
)
self.overrides[key] = junction_name
+ # Map from subproject alias to local alias
+ self.aliases = node.get_mapping("aliases", default={})
+
def preflight(self):
pass