summaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/buildstream/_loader/loader.py47
-rw-r--r--src/buildstream/element.py11
-rw-r--r--src/buildstream/plugins/sources/workspace.py11
3 files changed, 21 insertions, 48 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,
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 65b87e631..86d394ffe 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -1025,23 +1025,12 @@ class Element(Plugin):
redundant_ref = source._load_ref()
- if meta_source.kind == 'workspace':
- _workspace_source = source
- continue
-
element.__sources.append(source)
# Collect redundant refs which occurred at load time
if redundant_ref is not None:
cls.__redundant_source_refs.append((source, redundant_ref))
- # workspace handling: if the metasources included a workspace source, then
- # this should replace the element.__sources and should in turn own those sources
- # directly
- if _workspace_source is not None:
- _workspace_source.set_element_sources(element.__sources)
- element.__sources = [_workspace_source]
-
# Instantiate dependencies
for meta_dep in meta.dependencies:
dependency = Element._new_from_meta(meta_dep, task)
diff --git a/src/buildstream/plugins/sources/workspace.py b/src/buildstream/plugins/sources/workspace.py
index 9cc524f89..b5b92eb62 100644
--- a/src/buildstream/plugins/sources/workspace.py
+++ b/src/buildstream/plugins/sources/workspace.py
@@ -54,19 +54,11 @@ class WorkspaceSource(Source):
# Cached unique key
self.__unique_key = None
- # the element source objects from the specified metasources
- self.__element_sources = []
# the digest of the Directory following the import of the workspace
self.__digest = None
# the CasBasedDirectory which the path is imported into
self.__cas_dir = None
- def set_element_sources(self, _element_sources: [Source]) -> None:
- self.__element_sources = _element_sources
-
- def get_element_sources(self) -> [Source]:
- return self.__element_sources
-
def track(self) -> SourceRef:
return None
@@ -76,8 +68,7 @@ class WorkspaceSource(Source):
self.__digest = node.get_str('ref')
def preflight(self) -> None:
- for source in self.get_element_sources():
- source.preflight()
+ pass # pragma: nocover
def get_ref(self) -> None:
return None