You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:11:13 UTC

[buildstream] 04/41: Sandbox.py: Add get_virtual_directory and get_virtual_toplevel_directory

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch jmac/googlecas_and_virtual_directories_1
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 92cc9a1dede46f64c6f1ed150bba700e9e9aa11f
Author: Jim MacArthur <ji...@codethink.co.uk>
AuthorDate: Tue May 8 16:17:50 2018 +0100

    Sandbox.py: Add get_virtual_directory and get_virtual_toplevel_directory
---
 buildstream/sandbox/sandbox.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py
index c99bbaf..979367b 100644
--- a/buildstream/sandbox/sandbox.py
+++ b/buildstream/sandbox/sandbox.py
@@ -32,6 +32,7 @@ See also: :ref:`sandboxing`.
 
 import os
 from .._exceptions import ImplError, BstError
+from ._filebaseddirectory import FileBasedDirectory
 
 
 class SandboxFlags():
@@ -123,6 +124,33 @@ class Sandbox():
         else:
             raise BstError("You can't use get_directory")
 
+    def get_virtual_directory(self):
+        """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:
+           (str): The sandbox root directory
+
+        """
+        # For now, just create a new Directory every time we're asked
+        return FileBasedDirectory(self._root)
+
+    def get_virtual_toplevel_directory(self):
+        """Fetches the sandbox's toplevel directory
+
+        The toplevel directory contains 'root', 'scratch' and later
+        'artifact' where output is copied to.
+
+        Returns:
+           (str): The sandbox toplevel directory
+
+        """
+        # For now, just create a new Directory every time we're asked
+        return FileBasedDirectory(self.__directory)
+
     def set_environment(self, environment):
         """Sets the environment variables for the sandbox