summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-03-02 09:30:03 +0100
committerJürg Billeter <j@bitron.ch>2019-03-06 10:31:06 +0100
commitbdb9bbd59b74c6fca64d8d2cb7bb876538360034 (patch)
tree7d61ae282bc902a8e6614a4e8df1666dc5be2f4a
parent5dc4066aa2ff4544490a8e1bfdddfe4af32b8d4a (diff)
downloadbuildstream-bdb9bbd59b74c6fca64d8d2cb7bb876538360034.tar.gz
sandbox.py: Add _use_cas_based_directory() method
Allow Sandbox implementations to decide whether to use CasBasedDirectory.
-rw-r--r--buildstream/sandbox/sandbox.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py
index ca4652599..7b10008bc 100644
--- a/buildstream/sandbox/sandbox.py
+++ b/buildstream/sandbox/sandbox.py
@@ -190,8 +190,9 @@ class Sandbox():
"""
if self._vdir is None or self._never_cache_vdirs:
- if 'BST_CAS_DIRECTORIES' in os.environ:
- self._vdir = CasBasedDirectory(self.__context.artifactcache.cas)
+ if self._use_cas_based_directory():
+ cascache = self.__context.get_cascache()
+ self._vdir = CasBasedDirectory(cascache)
else:
self._vdir = FileBasedDirectory(self._root)
return self._vdir
@@ -386,6 +387,17 @@ class Sandbox():
def _create_batch(self, main_group, flags, *, collect=None):
return _SandboxBatch(self, main_group, flags, collect=collect)
+ # _use_cas_based_directory()
+ #
+ # Whether to use CasBasedDirectory as sandbox root. If this returns `False`,
+ # FileBasedDirectory will be used.
+ #
+ # Returns:
+ # (bool): Whether to use CasBasedDirectory
+ #
+ def _use_cas_based_directory(self):
+ return 'BST_CAS_DIRECTORIES' in os.environ
+
################################################
# Private methods #
################################################