diff options
author | Jürg Billeter <j@bitron.ch> | 2020-02-27 09:35:02 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-04-28 05:01:39 +0000 |
commit | e1f96f6dd4174cb9d1e8bb71724f281088d7a1f4 (patch) | |
tree | 856c2caa6b593a589d2fbb0e23b8ccbe651134d1 | |
parent | db4f9978b4392c0c095a4670d41e4d77001d34e3 (diff) | |
download | buildstream-e1f96f6dd4174cb9d1e8bb71724f281088d7a1f4.tar.gz |
sandbox: Remove Sandbox.get_directory()
Require element plugins to use `Sandbox.get_virtual_directory()`.
-rw-r--r-- | src/buildstream/sandbox/_sandboxbuildboxrun.py | 4 | ||||
-rw-r--r-- | src/buildstream/sandbox/sandbox.py | 36 |
2 files changed, 4 insertions, 36 deletions
diff --git a/src/buildstream/sandbox/_sandboxbuildboxrun.py b/src/buildstream/sandbox/_sandboxbuildboxrun.py index 246fdd450..c10669fe0 100644 --- a/src/buildstream/sandbox/_sandboxbuildboxrun.py +++ b/src/buildstream/sandbox/_sandboxbuildboxrun.py @@ -36,10 +36,6 @@ from ._sandboxreapi import SandboxREAPI # BuildBox-based sandbox implementation. # class SandboxBuildBoxRun(SandboxREAPI): - def __init__(self, context, project, directory, **kwargs): - kwargs["allow_real_directory"] = False - super().__init__(context, project, directory, **kwargs) - @classmethod def check_available(cls): try: diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py index 0a09788f4..fc8e4f1d0 100644 --- a/src/buildstream/sandbox/sandbox.py +++ b/src/buildstream/sandbox/sandbox.py @@ -125,7 +125,6 @@ class Sandbox: self.__cwd = None # type: Optional[str] self.__env = None # type: Optional[Dict[str, str]] self.__mount_sources = {} # type: Dict[str, str] - self.__allow_real_directory = kwargs["allow_real_directory"] self.__allow_run = True # Plugin element full name for logging @@ -154,47 +153,20 @@ class Sandbox: self._vdir = None # type: Optional[Directory] self._usebuildtree = False - # This is set if anyone requests access to the underlying - # directory via get_directory. - self._never_cache_vdirs = False - # Pending command batch self.__batch = None - def get_directory(self) -> str: - """Fetches the sandbox root directory - - The root directory is where artifacts for the base - runtime environment should be staged. Only works if - BST_VIRTUAL_DIRECTORY is not set. - - Returns: - The sandbox root directory - - """ - if self.__allow_real_directory: - self._never_cache_vdirs = True - return self._root - else: - raise BstError("You can't use get_directory") - def get_virtual_directory(self) -> Directory: """Fetches the sandbox root directory as a virtual Directory. The root directory is where artifacts for the base runtime environment should be staged. - Use caution if you use get_directory and - get_virtual_directory. If you alter the contents of the - directory returned by get_directory, all objects returned by - get_virtual_directory or derived from them are invalid and you - must call get_virtual_directory again to get a new copy. - Returns: The sandbox root directory """ - if self._vdir is None or self._never_cache_vdirs: + if self._vdir is None: if self._use_cas_based_directory(): cascache = self.__context.get_cascache() self._vdir = CasBasedDirectory(cascache) @@ -400,9 +372,9 @@ 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: + # Use CasBasedDirectory as sandbox root if Sandbox.run() is not used. + # This allows faster staging. + if not self.__allow_run: return True return "BST_CAS_DIRECTORIES" in os.environ |