summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-03-02 09:41:05 +0100
committerJürg Billeter <j@bitron.ch>2019-03-06 10:31:06 +0100
commit1798559c95c11582afbecd975d811a157d231280 (patch)
treed9e05195785a94febbd055d8a51d1e076fd3ed59
parentbdb9bbd59b74c6fca64d8d2cb7bb876538360034 (diff)
downloadbuildstream-1798559c95c11582afbecd975d811a157d231280.tar.gz
sandbox.py: Add _disable_run() method
This enables use of CasBasedDirectory for faster staging when command execution is not required.
-rw-r--r--buildstream/sandbox/sandbox.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py
index 7b10008bc..f11ddea1d 100644
--- a/buildstream/sandbox/sandbox.py
+++ b/buildstream/sandbox/sandbox.py
@@ -117,6 +117,7 @@ class Sandbox():
self.__env = None
self.__mount_sources = {}
self.__allow_real_directory = kwargs['allow_real_directory']
+ self.__allow_run = True
# Plugin ID for logging
plugin = kwargs.get('plugin', None)
@@ -279,6 +280,9 @@ class Sandbox():
not exist yet, even if a workspace is being used.
"""
+ if not self.__allow_run:
+ raise SandboxError("Sandbox.run() has been disabled")
+
# Fallback to the sandbox default settings for
# the cwd and env.
#
@@ -396,6 +400,11 @@ class Sandbox():
# (bool): Whether to use CasBasedDirectory
#
def _use_cas_based_directory(self):
+ # Use CasBasedDirectory as sandbox root if neither Sandbox.get_directory()
+ # nor Sandbox.run() are required. This allows faster staging.
+ if not self.__allow_real_directory and not self.__allow_run:
+ return True
+
return 'BST_CAS_DIRECTORIES' in os.environ
################################################
@@ -574,6 +583,15 @@ class Sandbox():
else:
callback()
+ # _disable_run()
+ #
+ # Raise exception if `Sandbox.run()` is called. This enables use of
+ # CasBasedDirectory for faster staging when command execution is not
+ # required.
+ #
+ def _disable_run(self):
+ self.__allow_run = False
+
# _SandboxBatch()
#