summaryrefslogtreecommitdiff
path: root/buildstream
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2020-05-10 17:07:06 +0200
committerValentin David <valentin.david@codethink.co.uk>2020-05-10 18:51:02 +0200
commitcd6d0572ef70b93636d7940d06ad0b13e0aca486 (patch)
tree728e7ade7898ea31f87e8d7cf0b408cdd7475e99 /buildstream
parent62eee7be681c74c6b6aa679acac9d27bf1b871e9 (diff)
downloadbuildstream-valentindavid/junction-replacements-1.4.tar.gz
Allow junctions to inject dependencies from current project to junctioned onevalentindavid/junction-replacements-1.4
There are cases where downstream projects want to overwrite upstream elements. So far, either the downstream project just allows overlaps and hopes that ABI is compatible. There are also files left from original elements when not overwritten. Or downstream adds an "overlay" with local source to the junctions. However on the latter, elements in the overlay are considered as part of upstream, which means in cannot depend on element outside of upstream (unless cyclic junction maybe?). Here we add a feature to junctions to allow injecting elements from current project to junctions. This is useful for example in the case of GNOME SDK needing to override GLib, GObjectIntrospection, libsoup, etc. from Freedesktop SDK.
Diffstat (limited to 'buildstream')
-rw-r--r--buildstream/_loader/loader.py13
-rw-r--r--buildstream/plugins/elements/junction.py1
2 files changed, 14 insertions, 0 deletions
diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py
index ec929eadb..dc15109c8 100644
--- a/buildstream/_loader/loader.py
+++ b/buildstream/_loader/loader.py
@@ -217,6 +217,13 @@ class Loader():
if ticker:
ticker(filename)
+ if self.project.junction and filename in self.project.junction.replacements:
+ replacement = _yaml.node_get(self.project.junction.replacements, str, filename)
+ elt = self._parent._load_file(replacement,
+ rewritable, ticker, fetch_subprojects, provenance=provenance)
+ self._elements[filename] = elt
+ return elt
+
# Load the data and process any conditional statements therein
fullpath = os.path.join(self._basedir, filename)
try:
@@ -311,6 +318,8 @@ class Loader():
validated = {}
element = self._elements[element_name]
+ if getattr(element, '_loader', self) != self:
+ return element._loader._check_circular_deps(element.name, check_elements, validated)
# element name must be unique across projects
# to be usable as key for the check_elements and validated dicts
@@ -353,6 +362,8 @@ class Loader():
visited = {}
element = self._elements[element_name]
+ if getattr(element, '_loader', self) != self:
+ return element._loader._sort_dependencies(element.name, visited)
# element name must be unique across projects
# to be usable as key for the visited dict
@@ -424,6 +435,8 @@ class Loader():
def _collect_element(self, element_name):
element = self._elements[element_name]
+ if element._loader != self:
+ return element._loader._collect_element(element.name)
# Return the already built one, if we already built it
meta_element = self._meta_elements.get(element_name)
diff --git a/buildstream/plugins/elements/junction.py b/buildstream/plugins/elements/junction.py
index d2c62fe48..f87ac2273 100644
--- a/buildstream/plugins/elements/junction.py
+++ b/buildstream/plugins/elements/junction.py
@@ -142,6 +142,7 @@ class JunctionElement(Element):
def configure(self, node):
self.path = self.node_get_member(node, str, 'path', default='')
self.options = self.node_get_member(node, Mapping, 'options', default={})
+ self.replacements = self.node_get_member(node, Mapping, 'replacements', default={})
def preflight(self):
pass