You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ak...@apache.org on 2024/03/28 13:31:02 UTC
(buildstream) branch abderrahim/junction-aliases updated (50c50227b -> f3578aa88)
This is an automated email from the ASF dual-hosted git repository.
akitouni pushed a change to branch abderrahim/junction-aliases
in repository https://gitbox.apache.org/repos/asf/buildstream.git
discard 50c50227b Support mapping subproject aliases to aliases of the parent project
add 3712e6920 _pluginfactory: Additional type checking
add cf5893578 Merge pull request #1905 from apache/abderrahim/type-checking
new b448e4c11 Support mapping subproject aliases to aliases of the parent project
new b76297d40 fixup! Support mapping subproject aliases to aliases of the parent project
new f3578aa88 Add automatic mapping of subproject aliases
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (50c50227b)
\
N -- N -- N refs/heads/abderrahim/junction-aliases (f3578aa88)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 3 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.
Summary of changes:
src/buildstream/_pluginfactory/elementfactory.py | 16 ++++++++++++----
src/buildstream/_pluginfactory/pluginfactory.py | 8 ++++----
src/buildstream/_pluginfactory/sourcefactory.py | 18 ++++++++++++++----
src/buildstream/_project.py | 22 +++++++++++-----------
src/buildstream/element.py | 6 +++---
src/buildstream/plugins/elements/junction.py | 14 +++++++++++++-
src/buildstream/source.py | 2 +-
7 files changed, 58 insertions(+), 28 deletions(-)
(buildstream) 03/03: Add automatic mapping of subproject aliases
Posted by ak...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
akitouni pushed a commit to branch abderrahim/junction-aliases
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit f3578aa8882df8ef022d47acfe0ec282a0f7102c
Author: Abderrahim Kitouni <ab...@codethink.co.uk>
AuthorDate: Thu Mar 28 14:29:35 2024 +0100
Add automatic mapping of subproject aliases
---
src/buildstream/_project.py | 6 +++---
src/buildstream/plugins/elements/junction.py | 12 +++++++++++-
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index 006a01fc7..3b64cc893 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -223,7 +223,7 @@ class Project:
if alias_url:
if self.junction:
parent_project = self.junction._get_project()
- parent_alias = self.junction.aliases.get_str(url_alias, default=None)
+ parent_alias = self.junction.get_parent_alias(url_alias)
if parent_alias:
# Delegate translation to parent project
return parent_project.translate_url(
@@ -391,7 +391,7 @@ class Project:
if self.junction:
parent_project = self.junction._get_project()
- parent_alias = self.junction.aliases.get_str(alias, default=None)
+ parent_alias = self.junction.get_parent_alias(alias)
if parent_alias:
return parent_project.alias_exists(parent_alias, first_pass=first_pass)
elif parent_project.disallow_subproject_uris:
@@ -418,7 +418,7 @@ class Project:
if self.junction:
parent_project = self.junction._get_project()
- parent_alias = self.junction.aliases.get_str(alias, default=None)
+ parent_alias = self.junction.get_parent_alias(alias)
if parent_alias:
# Delegate translation to parent project
return parent_project.get_alias_uris(parent_alias, first_pass=first_pass, tracking=tracking)
diff --git a/src/buildstream/plugins/elements/junction.py b/src/buildstream/plugins/elements/junction.py
index 5d457143f..cd8b13c7e 100644
--- a/src/buildstream/plugins/elements/junction.py
+++ b/src/buildstream/plugins/elements/junction.py
@@ -55,6 +55,9 @@ Overview
aliases:
subproject-alias: local-alias
+ # A default mapping can be set (defaults to none)
+ map-aliases: identity
+
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
@@ -343,7 +346,7 @@ class JunctionElement(Element):
def configure(self, node):
- node.validate_keys(["path", "options", "overrides", "aliases"])
+ node.validate_keys(["path", "options", "overrides", "aliases", "map-aliases"])
self.path = node.get_str("path", default="")
self.options = node.get_mapping("options", default={})
@@ -368,6 +371,13 @@ class JunctionElement(Element):
# Map from subproject alias to local alias
self.aliases = node.get_mapping("aliases", default={})
+ self.map_aliases = node.get_bool("map-aliases", default=False)
+
+ def get_parent_alias(self, alias):
+ parent_alias = self.aliases.get_str(alias, default=None)
+ if parent_alias is None and self.map_aliases:
+ parent_alias = alias
+ return parent_alias
def preflight(self):
pass
(buildstream) 02/03: fixup! Support mapping subproject aliases to aliases of the parent project
Posted by ak...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
akitouni pushed a commit to branch abderrahim/junction-aliases
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit b76297d40460712774408fcd4eaeef4508308841
Author: Abderrahim Kitouni <ab...@codethink.co.uk>
AuthorDate: Thu Mar 28 09:55:12 2024 +0100
fixup! Support mapping subproject aliases to aliases of the parent project
---
src/buildstream/_project.py | 16 ++++++++--------
src/buildstream/plugins/elements/junction.py | 2 ++
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index 6ae488731..006a01fc7 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -102,7 +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.disallow_subproject_uris: bool = False
self.config: ProjectConfig = ProjectConfig()
self.first_pass_config: ProjectConfig = ProjectConfig()
@@ -229,7 +229,7 @@ class Project:
return parent_project.translate_url(
parent_alias + utils._ALIAS_SEPARATOR + url_body, first_pass=first_pass
)
- elif not parent_project.allow_subproject_uris:
+ elif parent_project.disallow_subproject_uris:
return url
url = alias_url + url_body
@@ -394,7 +394,7 @@ class 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:
+ elif parent_project.disallow_subproject_uris:
return False
return config._aliases.get_str(alias, default=None) is not None
@@ -422,7 +422,7 @@ class Project:
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:
+ elif parent_project.disallow_subproject_uris:
return [None]
uri_list = []
@@ -815,14 +815,14 @@ class Project:
# Junction configuration
junctions_node = pre_config_node.get_mapping("junctions", default={})
- junctions_node.validate_keys(["duplicates", "internal", "allow-subproject-uris"])
+ junctions_node.validate_keys(["duplicates", "internal", "disallow-subproject-uris"])
- if self.junction and not self.junction._get_project().allow_subproject_uris:
+ if self.junction and not self.junction._get_project().disallow_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
+ self.disallow_subproject_uris = True
else:
- self.allow_subproject_uris = junctions_node.get_bool("allow-subproject-uris", default=True)
+ self.disallow_subproject_uris = junctions_node.get_bool("disallow-subproject-uris", default=False)
# 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 7ce3a07f6..5d457143f 100644
--- a/src/buildstream/plugins/elements/junction.py
+++ b/src/buildstream/plugins/elements/junction.py
@@ -50,6 +50,8 @@ Overview
overrides:
subproject-junction.bst: local-junction.bst
+ # Optionally override aliases in subprojects, to allow using mirrors
+ # defined in the parent project.
aliases:
subproject-alias: local-alias
(buildstream) 01/03: Support mapping subproject aliases to aliases of the parent project
Posted by ak...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
akitouni pushed a commit to branch abderrahim/junction-aliases
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit b448e4c116a82767bbf7a23a0e303a0aa04f5c90
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