You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:15:07 UTC

[buildstream] 01/01: Do not use a sandbox when not required for checkout

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

tvb pushed a commit to branch willsalmon/checkout_no_sandbox
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit ef44916b4339a26ff3fb54c04b70f00c36a47dc1
Author: William Salmon <wi...@codethink.co.uk>
AuthorDate: Fri Jul 3 16:50:18 2020 +0100

    Do not use a sandbox when not required for checkout
---
 src/buildstream/_stream.py      | 14 +++++++++++---
 src/buildstream/buildelement.py |  2 +-
 src/buildstream/element.py      |  9 ++++-----
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index 3d646a7..95832bb 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -55,6 +55,7 @@ from .types import _KeyStrength, _PipelineSelection, _SchedulerErrorAction
 from .plugin import Plugin
 from . import utils, _yaml, _site
 from . import Scope
+from .storage._casbaseddirectory import CasBasedDirectory
 
 
 # Stream()
@@ -553,9 +554,16 @@ class Stream:
                 _PipelineSelection.NONE: Scope.NONE,
                 _PipelineSelection.ALL: Scope.ALL,
             }
-            with target._prepare_sandbox(scope=scope[selection], integrate=integrate) as sandbox:
-                # Copy or move the sandbox to the target directory
-                virdir = sandbox.get_virtual_directory()
+            if integrate:
+                with target._prepare_sandbox(scope=scope[selection], integrate=integrate) as sandbox:
+                    # Copy or move the sandbox to the target directory
+                    virdir = sandbox.get_virtual_directory()
+                    self._export_artifact(tar, location, compression, target, hardlinks, virdir)
+            else:
+                # This allows for checking out elements when they were build with a non local sandbox
+                virdir = CasBasedDirectory(target._get_context().get_cascache())
+                with target.timed_activity("Staging dependencies", silent_nested=True):
+                    target.stage_dependency_artifacts(virdir, scope[selection])
                 self._export_artifact(tar, location, compression, target, hardlinks, virdir)
         except BstError as e:
             raise StreamError(
diff --git a/src/buildstream/buildelement.py b/src/buildstream/buildelement.py
index aa42706..cec8072 100644
--- a/src/buildstream/buildelement.py
+++ b/src/buildstream/buildelement.py
@@ -222,7 +222,7 @@ class BuildElement(Element):
 
         # Stage deps in the sandbox root
         with self.timed_activity("Staging dependencies", silent_nested=True):
-            self.stage_dependency_artifacts(sandbox, Scope.BUILD)
+            self.stage_dependency_artifacts(sandbox.get_virtual_directory(), Scope.BUILD)
 
         # Run any integration commands provided by the dependencies
         # once they are all staged and ready
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 6a0fa5f..a87ff73 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -609,7 +609,7 @@ class Element(Plugin):
 
     def stage_artifact(
         self,
-        sandbox: "Sandbox",
+        vbasedir: "Directory",
         *,
         path: str = None,
         include: Optional[List[str]] = None,
@@ -668,7 +668,6 @@ class Element(Plugin):
 
             # Hard link it into the staging area
             #
-            vbasedir = sandbox.get_virtual_directory()
             vstagedir = vbasedir if path is None else vbasedir.descend(*path.lstrip(os.sep).split(os.sep), create=True)
 
             split_filter = self.__split_filter_func(include, exclude, orphans)
@@ -681,7 +680,7 @@ class Element(Plugin):
 
     def stage_dependency_artifacts(
         self,
-        sandbox: "Sandbox",
+        vbasedir: "Directory",
         scope: Scope,
         *,
         path: str = None,
@@ -714,7 +713,7 @@ class Element(Plugin):
         files_written = {}  # type: Dict[str, List[str]]
 
         for dep in self.dependencies(scope):
-            result = dep.stage_artifact(sandbox, path=path, include=include, exclude=exclude, orphans=orphans)
+            result = dep.stage_artifact(vbasedir, path=path, include=include, exclude=exclude, orphans=orphans)
             if result.overwritten:
                 for overwrite in result.overwritten:
                     # Completely new overwrite
@@ -1286,7 +1285,7 @@ class Element(Plugin):
             else:
                 # Stage deps in the sandbox root
                 with self.timed_activity("Staging dependencies", silent_nested=True):
-                    self.stage_dependency_artifacts(sandbox, scope)
+                    self.stage_dependency_artifacts(sandbox.get_virtual_directory(), scope)
 
                 # Run any integration commands provided by the dependencies
                 # once they are all staged and ready