summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Coldrick <thomas.coldrick@codethink.co.uk>2019-09-11 10:18:11 +0100
committerThomas Coldrick <othko97@gmail.com>2019-09-16 06:55:56 +0000
commit4e63710a5136c7ca8d87a5e86908e7de3de05f4a (patch)
tree017d4a7b430c36865830b9748433c80fec728d6c
parentb2af82add70ca6c582d08d916fb243493de397e2 (diff)
downloadbuildstream-4e63710a5136c7ca8d87a5e86908e7de3de05f4a.tar.gz
element.py: Abstract not producing artifacts
Currently the stack element does not produce an artifact, and sometimes has to be treated differently because of this. It is conceivable that someone will write a plugin that must be treated similarly and doesn't produce an artifact. As a result this commit abstracts this "not producing an artifact" feature of elements.
-rw-r--r--src/buildstream/element.py6
-rw-r--r--src/buildstream/plugins/elements/filter.py11
-rw-r--r--src/buildstream/plugins/elements/stack.py3
-rw-r--r--tests/elements/filter.py2
4 files changed, 16 insertions, 6 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 2efdd3abb..044b97458 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -211,6 +211,12 @@ class Element(Plugin):
*Since: 1.4*
"""
+ BST_ELEMENT_HAS_ARTIFACT = True
+ """Whether the element produces an artifact when built.
+
+ *Since: 1.90*
+ """
+
def __init__(self, context: 'Context', project: 'Project', meta: 'MetaElement', plugin_conf: Dict[str, Any]):
self.__cache_key_dict = None # Dict for cache key calculation
diff --git a/src/buildstream/plugins/elements/filter.py b/src/buildstream/plugins/elements/filter.py
index 2f9204215..d808c9e5a 100644
--- a/src/buildstream/plugins/elements/filter.py
+++ b/src/buildstream/plugins/elements/filter.py
@@ -200,12 +200,13 @@ class FilterElement(Element):
.format(self, type(self).__name__),
detail=detail, reason="filter-bdepend-also-rdepend")
- # If a stack, fail and inform user that the dependency can't be a stack
- if build_deps[0].get_kind() == 'stack':
- detail = "{} is a stack element, which has no artifact".format(build_deps[0].name)
- raise ElementError("{}: {} element's build dependency must not be a stack element"
+ # If a parent does not produce an artifact, fail and inform user that the dependency
+ # must produce artifacts
+ if not build_deps[0].BST_ELEMENT_HAS_ARTIFACT:
+ detail = "{} does not produce an artifact, so there is nothing to filter".format(build_deps[0].name)
+ raise ElementError("{}: {} element's build dependency must produce an artifact"
.format(self, type(self).__name__),
- detail=detail, reason="filter-bdepend-is-stack")
+ detail=detail, reason="filter-bdepend-no-artifact")
def get_unique_key(self):
key = {
diff --git a/src/buildstream/plugins/elements/stack.py b/src/buildstream/plugins/elements/stack.py
index 97517ca48..dbb59a43d 100644
--- a/src/buildstream/plugins/elements/stack.py
+++ b/src/buildstream/plugins/elements/stack.py
@@ -33,6 +33,9 @@ class StackElement(Element):
# This plugin has been modified to avoid the use of Sandbox.get_directory
BST_VIRTUAL_DIRECTORY = True
+ # This plugin does not produce any artifacts when built
+ BST_ELEMENT_HAS_ARTIFACT = False
+
def configure(self, node):
pass
diff --git a/tests/elements/filter.py b/tests/elements/filter.py
index b8dd4351e..fc64c0342 100644
--- a/tests/elements/filter.py
+++ b/tests/elements/filter.py
@@ -558,4 +558,4 @@ def test_filter_stack_depend_failure(datafiles, cli):
project = str(datafiles)
result = cli.run(project=project, args=['build', 'forbidden-stack-dep.bst'])
- result.assert_main_error(ErrorDomain.ELEMENT, "filter-bdepend-is-stack")
+ result.assert_main_error(ErrorDomain.ELEMENT, "filter-bdepend-no-artifact")