diff options
author | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-08-09 22:32:15 +0900 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-08-10 10:26:49 +0000 |
commit | f5384afb7b217db9910a3f6f1fca9bead476b97f (patch) | |
tree | 202420bf8cb5128efeda922f9ceb76488a8a6df8 | |
parent | c38036d736a2174c8f6391e32d46520c5b5c628b (diff) | |
download | buildstream-f5384afb7b217db9910a3f6f1fca9bead476b97f.tar.gz |
_loader/loadelement.pyx: Dependency now implements `provenance` as a property
Since ProvenanceInformation are created on the demand, it's better
to just hold on to the originating Node and create the provenance
only when needed.
-rw-r--r-- | src/buildstream/_loader/loadelement.pyx | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/buildstream/_loader/loadelement.pyx b/src/buildstream/_loader/loadelement.pyx index 49de8d02e..0f0f86639 100644 --- a/src/buildstream/_loader/loadelement.pyx +++ b/src/buildstream/_loader/loadelement.pyx @@ -58,7 +58,7 @@ cdef class Dependency: cdef readonly str name # The project local dependency name cdef readonly str junction # The junction path of the dependency name, if any cdef readonly bint strict # Whether this is a strict dependency - cdef readonly ProvenanceInformation provenance # The provenance of the dependency + cdef Node _node # The original node of the dependency def __cinit__(self, element=None, dep_type=None): self.element = element @@ -66,7 +66,16 @@ cdef class Dependency: self.name = None self.junction = None self.strict = False - self.provenance = None + self._node = None + + # provenance + # + # A property to return the ProvenanceInformation for this + # dependency. + # + @property + def provenance(self): + return self._node.get_provenance() # set_element() # @@ -94,7 +103,7 @@ cdef class Dependency: cdef load(self, Node dep, str default_dep_type): cdef str dep_type - self.provenance = dep.get_provenance() + self._node = dep self.element = None if type(dep) is ScalarNode: |