diff options
author | Jürg Billeter <j@bitron.ch> | 2019-03-02 09:41:05 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-03-02 12:37:36 +0100 |
commit | 09941d4164f4585c9156b18df130a87502820d62 (patch) | |
tree | c78447cf12e32aaf988daafd8a3df81ea7aba4a1 | |
parent | 54d3f6b21c23f9a28c436ab401199f71f6309742 (diff) | |
download | buildstream-09941d4164f4585c9156b18df130a87502820d62.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.py | 18 |
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() # |