summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim MacArthur <jim.macarthur@codethink.co.uk>2018-11-21 16:49:15 +0000
committerJim MacArthur <jim.macarthur@codethink.co.uk>2018-11-22 18:56:52 +0000
commit1abea743a7b823de79ec61c7a55a6a600168b0de (patch)
treec0ed80428385ebd5c63cecb5c2b35f55dd931f84
parentb42defc0e75526c46232a5d0e36bc55e17354885 (diff)
downloadbuildstream-1abea743a7b823de79ec61c7a55a6a600168b0de.tar.gz
artifactcache.py, _context.py: Move CASCache object into context
Since the artifact cache and remote execution share the same local CAS store, they should share the same CASCache object. Moving this into context allows us to do this.
-rw-r--r--buildstream/_artifactcache/artifactcache.py4
-rw-r--r--buildstream/_context.py7
2 files changed, 9 insertions, 2 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 2121a432d..a156dc3bc 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -30,7 +30,7 @@ from .. import _signals
from .. import utils
from .. import _yaml
-from .cascache import CASCache, CASRemote, CASRemoteSpec
+from .cascache import CASRemote, CASRemoteSpec
CACHE_SIZE_FILE = "cache_size"
@@ -58,7 +58,7 @@ class ArtifactCache():
self.context = context
self.extractdir = os.path.join(context.artifactdir, 'extract')
- self.cas = CASCache(context.artifactdir)
+ self.cas = context.get_cascache()
self.global_remote_specs = []
self.project_remote_specs = {}
diff --git a/buildstream/_context.py b/buildstream/_context.py
index e8342d101..7ca60e7aa 100644
--- a/buildstream/_context.py
+++ b/buildstream/_context.py
@@ -31,6 +31,7 @@ from ._exceptions import LoadError, LoadErrorReason, BstError
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 .plugin import _plugin_lookup
@@ -141,6 +142,7 @@ class Context():
self._workspaces = None
self._log_handle = None
self._log_filename = None
+ self._cascache = None
# load()
#
@@ -620,6 +622,11 @@ class Context():
if not os.environ.get('XDG_DATA_HOME'):
os.environ['XDG_DATA_HOME'] = os.path.expanduser('~/.local/share')
+ def get_cascache(self):
+ if self._cascache is None:
+ self._cascache = CASCache(self.artifactdir)
+ return self._cascache
+
# _node_get_option_str()
#