diff options
author | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2018-10-25 17:35:25 +0100 |
---|---|---|
committer | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2018-12-11 12:56:32 +0000 |
commit | 67c7a58d0a2c3287cba128ef1f4babc57541439e (patch) | |
tree | bd1c2b75492985b272819310cbd29138ac3a69d4 /buildstream/_context.py | |
parent | 7892287a53c5ec3259fcd6f14736805b26b285b8 (diff) | |
download | buildstream-67c7a58d0a2c3287cba128ef1f4babc57541439e.tar.gz |
Create and store data inside projects when opening workspaces
Changes to _context.py:
* Context has been extended to contain a WorkspaceProjectCache, as there
are times when we want to use it before a Workspaces can be initialised
(looking up a WorkspaceProject to find the directory that the project is
in)
Changes to _stream.py:
* Removed staging the elements from workspace_open() and workspace_reset()
Changes in _workspaces.py:
* A new WorkspaceProject contains all the information needed to refer back
to a project from its workspace (currently this is the project path and
the element used to create this workspace)
* This is stored within a new WorkspaceProjectCache object, which keeps
WorkspaceProjects around so they don't need to be loaded from disk
repeatedly.
* Workspaces has been extended to contain the WorkspaceProjectCache, and
will use it when opening and closing workspaces.
* Workspaces.create_workspace has been extended to handle the staging of
the element into the workspace, in addition to creating the equivalent
WorkspaceProject file.
This is a part of #222
Diffstat (limited to 'buildstream/_context.py')
-rw-r--r-- | buildstream/_context.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/buildstream/_context.py b/buildstream/_context.py index 7ca60e7aa..55d0fd489 100644 --- a/buildstream/_context.py +++ b/buildstream/_context.py @@ -32,7 +32,7 @@ from ._message import Message, MessageType from ._profile import Topics, profile_start, profile_end from ._artifactcache import ArtifactCache from ._artifactcache.cascache import CASCache -from ._workspaces import Workspaces +from ._workspaces import Workspaces, WorkspaceProjectCache from .plugin import _plugin_lookup @@ -140,6 +140,7 @@ class Context(): self._projects = [] self._project_overrides = {} self._workspaces = None + self._workspace_project_cache = WorkspaceProjectCache() self._log_handle = None self._log_filename = None self._cascache = None @@ -285,7 +286,7 @@ class Context(): # def add_project(self, project): if not self._projects: - self._workspaces = Workspaces(project) + self._workspaces = Workspaces(project, self._workspace_project_cache) self._projects.append(project) # get_projects(): @@ -312,6 +313,16 @@ class Context(): def get_workspaces(self): return self._workspaces + # get_workspace_project_cache(): + # + # Return the WorkspaceProjectCache object used for this BuildStream invocation + # + # Returns: + # (WorkspaceProjectCache): The WorkspaceProjectCache object + # + def get_workspace_project_cache(self): + return self._workspace_project_cache + # get_overrides(): # # Fetch the override dictionary for the active project. This returns |