This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch jbilleter/digest-environment in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 2839c14d3b5175c1f82e1c33c900fe96dcb6a661 Author: Abderrahim Kitouni <abderrahim.kito...@codethink.co.uk> AuthorDate: Wed Jul 9 10:11:45 2025 +0100 sandbox.py: Add method to create a sub-sandbox This allows an element to use a secondary sandbox for manipulating artifacts that don't affect the build. --- src/buildstream/sandbox/sandbox.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py index a503ac9f7..29a3e31bf 100644 --- a/src/buildstream/sandbox/sandbox.py +++ b/src/buildstream/sandbox/sandbox.py @@ -85,13 +85,18 @@ class Sandbox: self.__env = None # type: Optional[Dict[str, str]] self.__mount_sources = {} # type: Dict[str, str] self.__allow_run = True + self.__subsandboxes = [] # type: List[Sandbox] # Plugin element full name for logging plugin = kwargs.get("plugin", None) if plugin: self.__element_name = plugin._get_full_name() else: - self.__element_name = None + parent = kwargs.get("parent", None) + if parent: + self.__element_name = parent._get_element_name() + else: + self.__element_name = None # Configuration from kwargs common to all subclasses self.__config = kwargs["config"] @@ -558,6 +563,28 @@ class Sandbox: def _disable_run(self): self.__allow_run = False + # _create_subsandbox() + # + # Create an empty sandbox + # + # This allows an element to use a secondary sandbox for manipulating artifacts + # that does not affect the build sandbox. + # + def _create_subsandbox(self, **kwargs): + sub = Sandbox( + self.__context, + self.__project, + parent=self, + stdout=self.__stdout, + stderr=self.__stderr, + config=self.__config, + ) + self.__subsandboxes.append(sub) + return sub + + def _get_subsandboxes(self): + return self.__subsandboxes + # SandboxFlags() #