summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-16 15:53:17 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-16 15:53:17 +0900
commit7c2a43d103e3034aa25ac7bd8571758a50526e61 (patch)
treec8d333790084d7527721cd3b817edf2e8a71133e
parent5cedd894cc8d74ad68255a115ec4d69dba31090f (diff)
downloadbuildstream-7c2a43d103e3034aa25ac7bd8571758a50526e61.tar.gz
element.py: Document new BST_FORBID_SOURCES and BST_FORBID_RDEPENDS as available since 1.2
Also use any() for the check on the generators, instead of expanding the whole list exhaustively and checking if the list is not empty.
-rw-r--r--buildstream/element.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index 79383bcc0..305f8cf7e 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -174,10 +174,14 @@ class Element(Plugin):
BST_FORBID_RDEPENDS = False
"""Whether to raise exceptions if an element has runtime-dependencies.
+
+ *Since: 1.2*
"""
BST_FORBID_SOURCES = False
"""Whether to raise exceptions if an element has sources.
+
+ *Since: 1.2*
"""
def __init__(self, context, project, artifacts, meta, plugin_conf):
@@ -1093,14 +1097,12 @@ class Element(Plugin):
#
def _preflight(self):
if self.BST_FORBID_RDEPENDS:
- runtime_deps = list(self.dependencies(Scope.RUN, recurse=False))
- if runtime_deps:
+ if any(self.dependencies(Scope.RUN, recurse=False)):
raise ElementError("{}: Runtime dependencies are forbidden for '{}' elements"
.format(self, self.get_kind()), reason="element-forbidden-rdepends")
if self.BST_FORBID_SOURCES:
- sources = list(self.sources())
- if sources:
+ if any(self.sources()):
raise ElementError("{}: Sources are forbidden for '{}' elements"
.format(self, self.get_kind()), reason="element-forbidden-sources")