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-27 15:32:19 +0000
commitf224d4cba844d6983c46ed2f4154cce41912bd94 (patch)
tree83ff88beeebb1f40c21295a965ac995384e01167
parentd5b5538de087ce560601dc980142a86220c38b0c (diff)
downloadbuildstream-f224d4cba844d6983c46ed2f4154cce41912bd94.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()
#