diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-25 22:50:37 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-25 23:26:42 +0900 |
commit | 7caecc685232a11d69f133858194d806531084a9 (patch) | |
tree | 6fd389b123b3420b13fffadddd571c49bc3baa90 /buildstream/_loader | |
parent | 38ac499288afc482fbd6e0e63e86f90b108e94be (diff) | |
download | buildstream-7caecc685232a11d69f133858194d806531084a9.tar.gz |
_loader: Give the loaded MetaSource objects the kind of the owning element
This is needed so that Sources can derive whether they belong
to a junction or not, which is needed for separating where
junction refs are stored.
Diffstat (limited to 'buildstream/_loader')
-rw-r--r-- | buildstream/_loader/loader.py | 8 | ||||
-rw-r--r-- | buildstream/_loader/metasource.py | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py index a79e80bb3..8e6c76425 100644 --- a/buildstream/_loader/loader.py +++ b/buildstream/_loader/loader.py @@ -372,6 +372,7 @@ class Loader(): meta_sources = [] sources = _yaml.node_get(node, list, Symbol.SOURCES, default_value=[]) + element_kind = _yaml.node_get(node, str, Symbol.KIND) # Safe loop calling into _yaml.node_get() for each element ensures # we have good error reporting @@ -386,11 +387,10 @@ class Loader(): del source[Symbol.DIRECTORY] index = sources.index(source) - meta_source = MetaSource(element_name, index, kind, source, directory) + meta_source = MetaSource(element_name, index, element_kind, kind, source, directory) meta_sources.append(meta_source) - kind = _yaml.node_get(node, str, Symbol.KIND) - meta_element = MetaElement(self.project, element_name, kind, + meta_element = MetaElement(self.project, element_name, element_kind, elt_provenance, meta_sources, _yaml.node_get(node, Mapping, Symbol.CONFIG, default_value={}), _yaml.node_get(node, Mapping, Symbol.VARIABLES, default_value={}), @@ -404,7 +404,7 @@ class Loader(): # Descend for dep in element.deps: - if kind == 'junction': + if element_kind == 'junction': raise LoadError(LoadErrorReason.INVALID_DATA, "{}: Junctions do not support dependencies".format(dep.provenance)) diff --git a/buildstream/_loader/metasource.py b/buildstream/_loader/metasource.py index 5f3fa3608..75e191595 100644 --- a/buildstream/_loader/metasource.py +++ b/buildstream/_loader/metasource.py @@ -28,12 +28,14 @@ class MetaSource(): # Args: # element_name: The name of the owning element # element_index: The index of the source in the owning element's source list + # element_kind: The kind of the owning element # kind: The kind of the source # config: The configuration data for the source # - def __init__(self, element_name, element_index, kind, config, directory): + def __init__(self, element_name, element_index, element_kind, kind, config, directory): self.element_name = element_name self.element_index = element_index + self.element_kind = element_kind self.kind = kind self.config = config self.directory = directory |