diff options
author | Tristan Maat <tristan.maat@codethink.co.uk> | 2019-09-18 15:03:05 +0100 |
---|---|---|
committer | Tristan Maat <tristan.maat@codethink.co.uk> | 2019-10-10 12:21:15 +0100 |
commit | acf99b789a92e9e124e9492d1dbbc34b83f5ab23 (patch) | |
tree | 37aae10af52ccad97cc08d0fffb2feccb50b56aa /src/buildstream | |
parent | 28803a91bb0525a197de004dce5fbe750a00fbde (diff) | |
download | buildstream-acf99b789a92e9e124e9492d1dbbc34b83f5ab23.tar.gz |
loader.py: Avoid loading deps of junction metaelements
By avoiding this, loading metaelements of junctions becomes cheap even
for junctions with erroneous dependencies, and we can ignore their
task reporting.
Task reporting for junction metaelement loading is confusing, since
the junction element itself will never be part of the pipeline, so
we'd rather not have this show up as an actual loaded element.
Elements loaded from the junction are loaded separately, therefore
this does not affect their progress display.
Diffstat (limited to 'src/buildstream')
-rw-r--r-- | src/buildstream/_loader/loader.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/buildstream/_loader/loader.py b/src/buildstream/_loader/loader.py index d578787a3..5eaed9337 100644 --- a/src/buildstream/_loader/loader.py +++ b/src/buildstream/_loader/loader.py @@ -593,12 +593,30 @@ class Loader(): # meta junction element # XXX: This is a likely point for progress reporting to end up # missing some elements, but it currently doesn't appear to be the case. - meta_element = self._collect_element(self._elements[filename], None) + meta_element = self._collect_element_no_deps(self._elements[filename], None) if meta_element.kind != 'junction': raise LoadError("{}{}: Expected junction but element kind is {}" .format(provenance_str, filename, meta_element.kind), LoadErrorReason.INVALID_DATA) + # We check that junctions have no dependencies a little + # early. This is cheating, since we don't technically know + # that junctions aren't allowed to have dependencies. + # + # However, this makes progress reporting more intuitive + # because we don't need to load dependencies of an element + # that shouldn't have any, and therefore don't need to + # duplicate the load count for elements that shouldn't be. + # + # We also fail slightly earlier (since we don't need to go + # through the entire loading process), which is nice UX. It + # would be nice if this could be done for *all* element types, + # but since we haven't loaded those yet that's impossible. + if self._elements[filename].dependencies: + raise LoadError( + "Dependencies are forbidden for 'junction' elements", + LoadErrorReason.INVALID_JUNCTION) + element = Element._new_from_meta(meta_element) element._update_state() |