Loading buildstream/buildelement.py +3 −0 Original line number Original line Diff line number Diff line Loading @@ -155,6 +155,9 @@ class BuildElement(Element): command_dir = build_root command_dir = build_root sandbox.set_work_directory(command_dir) sandbox.set_work_directory(command_dir) # Tell sandbox which directory is preserved in the finished artifact sandbox.set_output_directory(install_root) # Setup environment # Setup environment sandbox.set_environment(self.get_environment()) sandbox.set_environment(self.get_environment()) Loading buildstream/sandbox/sandbox.py +33 −3 Original line number Original line Diff line number Diff line Loading @@ -99,9 +99,11 @@ class Sandbox(): self.__stdout = kwargs['stdout'] self.__stdout = kwargs['stdout'] self.__stderr = kwargs['stderr'] self.__stderr = kwargs['stderr'] # Setup the directories. Root should be available to subclasses, hence # Setup the directories. Root and output_directory should be # being single-underscore. The others are private to this class. # available to subclasses, hence being single-underscore. The # others are private to this class. self._root = os.path.join(directory, 'root') self._root = os.path.join(directory, 'root') self._output_directory = None self.__directory = directory self.__directory = directory self.__scratch = os.path.join(self.__directory, 'scratch') self.__scratch = os.path.join(self.__directory, 'scratch') for directory_ in [self._root, self.__scratch]: for directory_ in [self._root, self.__scratch]: Loading Loading @@ -144,11 +146,30 @@ class Sandbox(): self._vdir = FileBasedDirectory(self._root) self._vdir = FileBasedDirectory(self._root) return self._vdir return self._vdir def _set_virtual_directory(self, vdir): """ Sets virtual directory. Useful after remote execution has rewritten the working directory. """ self._vdir = vdir 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): def set_environment(self, environment): """Sets the environment variables for the sandbox """Sets the environment variables for the sandbox Args: Args: directory (dict): The environment variables to use in the sandbox environment (dict): The environment variables to use in the sandbox """ """ self.__env = environment self.__env = environment Loading @@ -160,6 +181,15 @@ class Sandbox(): """ """ self.__cwd = directory self.__cwd = directory def set_output_directory(self, directory): """Sets the output directory - the directory which is preserved as an artifact after assembly. Args: directory (str): An absolute path within the sandbox """ self._output_directory = directory def mark_directory(self, directory, *, artifact=False): def mark_directory(self, directory, *, artifact=False): """Marks a sandbox directory and ensures it will exist """Marks a sandbox directory and ensures it will exist Loading Loading
buildstream/buildelement.py +3 −0 Original line number Original line Diff line number Diff line Loading @@ -155,6 +155,9 @@ class BuildElement(Element): command_dir = build_root command_dir = build_root sandbox.set_work_directory(command_dir) sandbox.set_work_directory(command_dir) # Tell sandbox which directory is preserved in the finished artifact sandbox.set_output_directory(install_root) # Setup environment # Setup environment sandbox.set_environment(self.get_environment()) sandbox.set_environment(self.get_environment()) Loading
buildstream/sandbox/sandbox.py +33 −3 Original line number Original line Diff line number Diff line Loading @@ -99,9 +99,11 @@ class Sandbox(): self.__stdout = kwargs['stdout'] self.__stdout = kwargs['stdout'] self.__stderr = kwargs['stderr'] self.__stderr = kwargs['stderr'] # Setup the directories. Root should be available to subclasses, hence # Setup the directories. Root and output_directory should be # being single-underscore. The others are private to this class. # available to subclasses, hence being single-underscore. The # others are private to this class. self._root = os.path.join(directory, 'root') self._root = os.path.join(directory, 'root') self._output_directory = None self.__directory = directory self.__directory = directory self.__scratch = os.path.join(self.__directory, 'scratch') self.__scratch = os.path.join(self.__directory, 'scratch') for directory_ in [self._root, self.__scratch]: for directory_ in [self._root, self.__scratch]: Loading Loading @@ -144,11 +146,30 @@ class Sandbox(): self._vdir = FileBasedDirectory(self._root) self._vdir = FileBasedDirectory(self._root) return self._vdir return self._vdir def _set_virtual_directory(self, vdir): """ Sets virtual directory. Useful after remote execution has rewritten the working directory. """ self._vdir = vdir 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): def set_environment(self, environment): """Sets the environment variables for the sandbox """Sets the environment variables for the sandbox Args: Args: directory (dict): The environment variables to use in the sandbox environment (dict): The environment variables to use in the sandbox """ """ self.__env = environment self.__env = environment Loading @@ -160,6 +181,15 @@ class Sandbox(): """ """ self.__cwd = directory self.__cwd = directory def set_output_directory(self, directory): """Sets the output directory - the directory which is preserved as an artifact after assembly. Args: directory (str): An absolute path within the sandbox """ self._output_directory = directory def mark_directory(self, directory, *, artifact=False): def mark_directory(self, directory, *, artifact=False): """Marks a sandbox directory and ensures it will exist """Marks a sandbox directory and ensures it will exist Loading