summaryrefslogtreecommitdiff
path: root/buildstream/plugins
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2017-06-14 22:54:23 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2017-06-15 11:37:34 +0100
commit9aae2d6e672bd2fe4b3203d950defea5806ab2df (patch)
tree5c527893986ec39de793bef70ff34487e4e46743 /buildstream/plugins
parent2620bfe2a15abcfdb15f4e70d8ddb1e943a2d97f (diff)
downloadbuildstream-9aae2d6e672bd2fe4b3203d950defea5806ab2df.tar.gz
import.py: Raise an error for elements that have no sources
Previously the build would start but then fail during assemble() once it became clear there were no files to import. Now an error is raised right away: Error loading pipeline: import element at gnu-toolchain/base-platform.bst [line 1 column 0]: An import element must have at least one source The usual cause of this error in my experience is when sources are chosen using the 'arches' conditional. If the user specifies an arch that the import element doesn't know about then they will get see this error which may not be particularly helpful.
Diffstat (limited to 'buildstream/plugins')
-rw-r--r--buildstream/plugins/elements/import.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/buildstream/plugins/elements/import.py b/buildstream/plugins/elements/import.py
index 23ba270f7..a6178a179 100644
--- a/buildstream/plugins/elements/import.py
+++ b/buildstream/plugins/elements/import.py
@@ -43,7 +43,11 @@ class ImportElement(BuildElement):
self.target = self.node_subst_member(node, 'target')
def preflight(self):
- pass
+ # Assert that we have at least one source to fetch.
+
+ sources = list(self.sources())
+ if not sources:
+ raise ElementError("{}: An import element must have at least one source.".format(self))
def get_unique_key(self):
return {
@@ -78,7 +82,7 @@ class ImportElement(BuildElement):
os.makedirs(os.path.dirname(outputdir), exist_ok=True)
if not os.path.exists(inputdir):
- raise ElementError("{}: No files were found at path '{}'"
+ raise ElementError("{}: No files were found inside directory '{}'"
.format(self, self.source))
# Move it over