summaryrefslogtreecommitdiff
path: root/src/buildstream/_loader/loader.py
diff options
context:
space:
mode:
authorDarius Makovsky <traveltissues@protonmail.com>2019-10-17 14:45:34 +0100
committerDarius Makovsky <traveltissues@protonmail.com>2019-10-17 17:17:26 +0100
commit43288a759cf84cb2de8e6abd33e4b75950bc31a5 (patch)
tree027b7781a1d258c63eb4c5b01f8e785153d1a801 /src/buildstream/_loader/loader.py
parent67f9de28c898e59dfb56effeab07c4cc86929899 (diff)
downloadbuildstream-traveltissues/notes.tar.gz
Remove special loading for workspacestraveltissues/notes
WorkspaceSource.init_workspace raises an exception so it is no longer necessary to retain the original source objects of the loaded element.
Diffstat (limited to 'src/buildstream/_loader/loader.py')
-rw-r--r--src/buildstream/_loader/loader.py47
1 files changed, 20 insertions, 27 deletions
diff --git a/src/buildstream/_loader/loader.py b/src/buildstream/_loader/loader.py
index 0c0d9d65a..cceda284c 100644
--- a/src/buildstream/_loader/loader.py
+++ b/src/buildstream/_loader/loader.py
@@ -442,41 +442,34 @@ class Loader():
elt_provenance = node.get_provenance()
meta_sources = []
- sources = node.get_sequence(Symbol.SOURCES, default=[])
element_kind = node.get_str(Symbol.KIND)
- def make_metasource(_index, _source, skip_workspace=True):
- kind = _source.get_str(Symbol.KIND)
- # the workspace source plugin cannot be used unless the element is workspaced
- if kind == 'workspace' and skip_workspace:
- return None
-
- del _source[Symbol.KIND]
-
- # Directory is optional
- directory = _source.get_str(Symbol.DIRECTORY, default=None)
- if directory:
- del _source[Symbol.DIRECTORY]
-
- return MetaSource(element.name, _index, element_kind, kind, _source, directory)
-
- for index, source in enumerate(sources):
- meta_source = make_metasource(index, source)
- if meta_source:
- meta_sources.append(meta_source)
-
# if there's a workspace for this element then just append a dummy workspace
- # metasources. When sources are instantiated, the workspace will own the
- # element sources. These can then be referred to when resetting or similar operations.
+ # metasource.
workspace = self._context.get_workspaces().get_workspace(element.name)
+ skip_workspace = True
if workspace and not ignore_workspaces:
workspace_node = {'kind': 'workspace'}
workspace_node['path'] = workspace.get_absolute_path()
workspace_node['ref'] = str(workspace.to_dict().get('last_successful', 'ignored'))
- sources.append(workspace_node)
- meta_source = make_metasource(len(sources), sources.mapping_at(-1), False)
- if meta_source:
- meta_sources.append(meta_source)
+ node[Symbol.SOURCES] = [workspace_node]
+ skip_workspace = False
+
+ sources = node.get_sequence(Symbol.SOURCES, default=[])
+ for index, source in enumerate(sources):
+ kind = source.get_str(Symbol.KIND)
+ # the workspace source plugin cannot be used unless the element is workspaced
+ if kind == 'workspace' and skip_workspace:
+ continue
+
+ del source[Symbol.KIND]
+
+ # Directory is optional
+ directory = source.get_str(Symbol.DIRECTORY, default=None)
+ if directory:
+ del source[Symbol.DIRECTORY]
+ meta_source = MetaSource(element.name, index, element_kind, kind, source, directory)
+ meta_sources.append(meta_source)
meta_element = MetaElement(self.project, element.name, element_kind,
elt_provenance, meta_sources,