summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-06-25 23:26:20 +0100
committerBenjamin Schubert <ben.c.schubert@gmail.com>2019-06-26 17:29:15 +0100
commit5a7014c352b24f253b9dcf3f06ca8d85f6482d1b (patch)
tree272443020c712b2ee98bb8fc8072cd199b20d67b
parent024b1ddfadbb71c6f10caa553a10885827b9366f (diff)
downloadbuildstream-bschubert/node-api-lazy-provenance.tar.gz
_loader/types: Compute provenance directly in 'Dependency'bschubert/node-api-lazy-provenance
-rw-r--r--src/buildstream/_loader/types.pyx15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/buildstream/_loader/types.pyx b/src/buildstream/_loader/types.pyx
index dfd8f9046..4198826e2 100644
--- a/src/buildstream/_loader/types.pyx
+++ b/src/buildstream/_loader/types.pyx
@@ -55,8 +55,6 @@ class Symbol():
# dep_type (str): The type of dependency, can be
# Symbol.ALL, Symbol.BUILD, or Symbol.RUNTIME
# junction (str): The element name of the junction, or None
-# provenance (ProvenanceInformation): The YAML node provenance of where this
-# dependency was declared
#
cdef class Dependency:
cdef public _yaml.ProvenanceInformation provenance
@@ -65,12 +63,11 @@ cdef class Dependency:
cdef public str junction
def __init__(self,
- object dep,
- _yaml.ProvenanceInformation provenance,
+ _yaml.Node dep,
str default_dep_type=None):
cdef str dep_type
- self.provenance = provenance
+ self.provenance = _yaml.node_get_provenance(dep)
if type(dep) is _yaml.ScalarNode:
self.name = dep.as_str()
@@ -100,7 +97,7 @@ cdef class Dependency:
else:
raise LoadError(LoadErrorReason.INVALID_DATA,
- "{}: Dependency is not specified as a string or a dictionary".format(provenance))
+ "{}: Dependency is not specified as a string or a dictionary".format(self.provenance))
# `:` characters are not allowed in filename if a junction was
# explicitly specified
@@ -140,13 +137,9 @@ cdef class Dependency:
cdef void _extract_depends_from_node(_yaml.Node node, str key, str default_dep_type, list acc) except *:
cdef _yaml.SequenceNode depends = node.get_sequence(key, [])
cdef _yaml.Node dep_node
- cdef _yaml.ProvenanceInformation dep_provenance
for dep_node in depends:
- # FIXME: the provenance information would be obtainable from the Node directly if we stop
- # stripping provenance and have proper nodes for str elements
- dep_provenance = <_yaml.ProvenanceInformation> _yaml.node_get_provenance(dep_node)
- dependency = Dependency(dep_node, dep_provenance, default_dep_type=default_dep_type)
+ dependency = Dependency(dep_node, default_dep_type=default_dep_type)
acc.append(dependency)
# Now delete the field, we dont want it anymore