Skip to content

Commit a291951

Browse files
committed
element.py: Add subsandbox() method
1 parent 30c7168 commit a291951

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/buildstream/element.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,21 @@ def run_cleanup_commands(self, sandbox: "Sandbox") -> None:
828828

829829
sandbox._clean_directory(build_root)
830830

831+
@contextmanager
832+
def subsandbox(self, sandbox: "Sandbox") -> Iterator["Sandbox"]:
833+
"""A context manager for a subsandbox.
834+
835+
Args:
836+
sandbox: The main build sandbox
837+
838+
This allows an element to use a secondary sandbox for manipulating
839+
artifacts without affecting the main build sandbox. The subsandbox
840+
is initially empty.
841+
"""
842+
subsandbox = sandbox._create_subsandbox()
843+
with self.__collect_overlaps(subsandbox):
844+
yield subsandbox
845+
831846
#############################################################
832847
# Private Methods used in BuildStream #
833848
#############################################################

0 commit comments

Comments
 (0)