summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Coldrick <othko97@gmail.com>2019-08-15 10:22:31 +0100
committerThomas Coldrick <othko97@gmail.com>2019-08-16 08:27:17 +0100
commit3bdca81d7266b8df41c429e3e4a0bc84ea2aef3d (patch)
tree0dedd3fe7b06f1783ff28d31eaa9b3279cac825b
parentcf3f925764cfe6949aedbdcd313a93654f7c7657 (diff)
downloadbuildstream-coldtom/filter-stacks.tar.gz
filter.py: Allow dependency on stack elementscoldtom/filter-stacks
Staging the artifact of a stack element currently creates an empty filter. This commit changes the logic in a filter element to stage the artifacts of dependencies of stack elements. We recursively expand stack elements into their dependencies.
-rw-r--r--src/buildstream/plugins/elements/filter.py61
1 files changed, 34 insertions, 27 deletions
diff --git a/src/buildstream/plugins/elements/filter.py b/src/buildstream/plugins/elements/filter.py
index c2c2e0125..556153b2d 100644
--- a/src/buildstream/plugins/elements/filter.py
+++ b/src/buildstream/plugins/elements/filter.py
@@ -216,35 +216,42 @@ class FilterElement(Element):
def assemble(self, sandbox):
with self.timed_activity("Staging artifact", silent_nested=True):
for dep in self.dependencies(Scope.BUILD, recurse=False):
- # Check that all the included/excluded domains exist
- pub_data = dep.get_public_data('bst')
- split_rules = pub_data.get_mapping('split-rules', {})
- unfound_includes = []
- for domain in self.include:
- if domain not in split_rules:
- unfound_includes.append(domain)
- unfound_excludes = []
- for domain in self.exclude:
- if domain not in split_rules:
- unfound_excludes.append(domain)
-
- detail = []
- if unfound_includes:
- detail.append("Unknown domains were used in {}".format(self.include_node.get_provenance()))
- detail.extend([' - {}'.format(domain) for domain in unfound_includes])
-
- if unfound_excludes:
- detail.append("Unknown domains were used in {}".format(self.exclude_node.get_provenance()))
- detail.extend([' - {}'.format(domain) for domain in unfound_excludes])
-
- if detail:
- detail = '\n'.join(detail)
- raise ElementError("Unknown domains declared.", detail=detail)
-
- dep.stage_artifact(sandbox, include=self.include,
- exclude=self.exclude, orphans=self.include_orphans)
+ self._assemble_single(sandbox, dep)
return ""
+ def _assemble_single(self, sandbox, dep):
+ # Check that all the included/excluded domains exist
+ if dep.get_kind() == 'stack':
+ for subdep in dep.dependencies(Scope.RUN, recurse=False):
+ self._assemble_single(sandbox, subdep)
+
+ pub_data = dep.get_public_data('bst')
+ split_rules = pub_data.get_mapping('split-rules', {})
+ unfound_includes = []
+ for domain in self.include:
+ if domain not in split_rules:
+ unfound_includes.append(domain)
+ unfound_excludes = []
+ for domain in self.exclude:
+ if domain not in split_rules:
+ unfound_excludes.append(domain)
+
+ detail = []
+ if unfound_includes:
+ detail.append("Unknown domains were used in {}".format(self.include_node.get_provenance()))
+ detail.extend([' - {}'.format(domain) for domain in unfound_includes])
+
+ if unfound_excludes:
+ detail.append("Unknown domains were used in {}".format(self.exclude_node.get_provenance()))
+ detail.extend([' - {}'.format(domain) for domain in unfound_excludes])
+
+ if detail:
+ detail = '\n'.join(detail)
+ raise ElementError("Unknown domains declared.", detail=detail)
+
+ dep.stage_artifact(sandbox, include=self.include,
+ exclude=self.exclude, orphans=self.include_orphans)
+
def _get_source_element(self):
# Filter elements act as proxies for their sole build-dependency
build_deps = list(self.dependencies(Scope.BUILD, recurse=False))