diff options
author | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-06-08 15:06:59 +0900 |
---|---|---|
committer | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-06-19 17:22:31 +0900 |
commit | ed0275786967c0c55369b9604f613a39426c381f (patch) | |
tree | 8db75b0996af7082064e1512663a281580ceb962 | |
parent | e4e3b4568e6f7e1575fdd90ec2c688ceee97322e (diff) | |
download | buildstream-ed0275786967c0c55369b9604f613a39426c381f.tar.gz |
_loader: Fix invalid junction error to include provenance
When a junction element has dependencies, we were not even specifying
which junction element was guilty of having dependencies and only
saying that such a thing would be forbidden (wherever it might be in
your project).
Fix this by using the provenance of the dependency in the junction,
specifying exactly where the invalid dependency exists.
This required carrying the provenance onto the other Dependency() object.
-rw-r--r-- | src/buildstream/_loader/loadelement.pyx | 4 | ||||
-rw-r--r-- | src/buildstream/_loader/loader.py | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/buildstream/_loader/loadelement.pyx b/src/buildstream/_loader/loadelement.pyx index 784ab8f7b..de2f96b37 100644 --- a/src/buildstream/_loader/loadelement.pyx +++ b/src/buildstream/_loader/loadelement.pyx @@ -52,11 +52,13 @@ cdef class Dependency: cdef readonly LoadElement element cdef readonly str dep_type cdef readonly bint strict + cdef readonly ProvenanceInformation provenance - def __cinit__(self, LoadElement element, str dep_type, bint strict): + def __cinit__(self, LoadElement element, str dep_type, bint strict, ProvenanceInformation provenance): self.element = element self.dep_type = dep_type self.strict = strict + self.provenance = provenance # LoadElement(): diff --git a/src/buildstream/_loader/loader.py b/src/buildstream/_loader/loader.py index 13d8f9f21..e63dd6c57 100644 --- a/src/buildstream/_loader/loader.py +++ b/src/buildstream/_loader/loader.py @@ -120,7 +120,7 @@ class Loader: dummy_target = LoadElement(Node.from_dict({}), "", self) # Pylint is not very happy with Cython and can't understand 'dependencies' is a list dummy_target.dependencies.extend( # pylint: disable=no-member - Dependency(element, Symbol.RUNTIME, False) for element in target_elements + Dependency(element, Symbol.RUNTIME, False, None) for element in target_elements ) with PROFILER.profile(Topics.CIRCULAR_CHECK, "_".join(targets)): @@ -403,7 +403,7 @@ class Loader: # All is well, push the dependency onto the LoadElement # Pylint is not very happy with Cython and can't understand 'dependencies' is a list current_element[0].dependencies.append( # pylint: disable=no-member - Dependency(dep_element, dep.dep_type, dep.strict) + Dependency(dep_element, dep.dep_type, dep.strict, dep.provenance) ) else: # We do not have any more dependencies to load for this @@ -613,7 +613,11 @@ class Loader: # would be nice if this could be done for *all* element types, # but since we haven't loaded those yet that's impossible. if load_element.dependencies: - raise LoadError("Dependencies are forbidden for 'junction' elements", LoadErrorReason.INVALID_JUNCTION) + # Use the first dependency in the list as provenance + p = load_element.dependencies[0].provenance + raise LoadError( + "{}: Dependencies are forbidden for 'junction' elements".format(p), LoadErrorReason.INVALID_JUNCTION + ) element = Element._new_from_meta(meta_element) element._initialize_state() |