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-02 12:37:36 +0100
commit54d3f6b21c23f9a28c436ab401199f71f6309742 (patch)
tree35efa78e018c819e29f848475bbb82e736291e3a
parentc2f0235fb367e754de046fafc9c1c09977346541 (diff)
downloadbuildstream-54d3f6b21c23f9a28c436ab401199f71f6309742.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 #
################################################