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

[buildstream] 06/12: elements: Port build and script kinds to BST_STAGE_INTEGRATES

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

not-in-ldap pushed a commit to branch richardmaw/shell-multi-stage
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 5e5792642ec043aacea3169402b7e10881a35c74
Author: Richard Maw <ri...@codethink.co.uk>
AuthorDate: Mon Oct 29 13:39:55 2018 +0000

    elements: Port build and script kinds to BST_STAGE_INTEGRATES
    
    This is mostly just marking which elements work as expected
    from changes to their base class.
    
    Junction and Filter elements expect overriding stage to be sufficient
    to prevent it doing anything in those contexts,
    and since we're not intending to deprecate BST_STAGE_INTEGRATES elements
    there's no harm in them continuing to do so
    when they aren't expected to work in contexts we require
    BST_STAGE_INTEGRATES to be False.
---
 buildstream/buildelement.py                 | 15 ++++++++-------
 buildstream/plugins/elements/autotools.py   |  2 ++
 buildstream/plugins/elements/cmake.py       |  2 ++
 buildstream/plugins/elements/compose.py     | 12 ++++++++----
 buildstream/plugins/elements/distutils.py   |  3 ++-
 buildstream/plugins/elements/filter.py      |  2 +-
 buildstream/plugins/elements/import.py      |  7 ++++++-
 buildstream/plugins/elements/junction.py    |  2 +-
 buildstream/plugins/elements/make.py        |  2 ++
 buildstream/plugins/elements/makemaker.py   |  3 ++-
 buildstream/plugins/elements/manual.py      |  2 ++
 buildstream/plugins/elements/meson.py       |  2 ++
 buildstream/plugins/elements/modulebuild.py |  3 ++-
 buildstream/plugins/elements/pip.py         |  3 ++-
 buildstream/plugins/elements/qmake.py       |  2 ++
 buildstream/plugins/elements/script.py      |  3 +++
 buildstream/plugins/elements/stack.py       |  8 +++++++-
 17 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/buildstream/buildelement.py b/buildstream/buildelement.py
index f1b13e7..67d9594 100644
--- a/buildstream/buildelement.py
+++ b/buildstream/buildelement.py
@@ -211,17 +211,18 @@ class BuildElement(Element):
         self.batch_prepare_assemble(SandboxFlags.ROOT_READ_ONLY,
                                     collect=self.get_variable('install-root'))
 
-    def stage(self, sandbox):
+    def stage(self, sandbox, *, visited=None):
+        assert not self.BST_STAGE_INTEGRATES or visited is None
 
         # 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, Scope.BUILD, visited=visited)
 
-        # Run any integration commands provided by the dependencies
-        # once they are all staged and ready
-        with sandbox.batch(SandboxFlags.NONE, label="Integrating sandbox"):
-            for dep in self.dependencies(Scope.BUILD):
-                dep.integrate(sandbox)
+        if self.BST_STAGE_INTEGRATES:
+            # Run any integration commands provided by the dependencies
+            # once they are all staged and ready
+            with self.timed_activity("Integrating sandbox"):
+                self.integrate_dependency_artifacts(sandbox, Scope.BUILD)
 
         # Stage sources in the build root
         self.stage_sources(sandbox, self.get_variable('build-root'))
diff --git a/buildstream/plugins/elements/autotools.py b/buildstream/plugins/elements/autotools.py
index 43fe7ad..8ea24c1 100644
--- a/buildstream/plugins/elements/autotools.py
+++ b/buildstream/plugins/elements/autotools.py
@@ -62,6 +62,8 @@ from buildstream import BuildElement
 class AutotoolsElement(BuildElement):
     # Supports virtual directories (required for remote execution)
     BST_VIRTUAL_DIRECTORY = True
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
 
 
 # Plugin entry point
diff --git a/buildstream/plugins/elements/cmake.py b/buildstream/plugins/elements/cmake.py
index de9aa96..3ce2d42 100644
--- a/buildstream/plugins/elements/cmake.py
+++ b/buildstream/plugins/elements/cmake.py
@@ -61,6 +61,8 @@ from buildstream import BuildElement
 class CMakeElement(BuildElement):
     # Supports virtual directories (required for remote execution)
     BST_VIRTUAL_DIRECTORY = True
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
 
 
 # Plugin entry point
diff --git a/buildstream/plugins/elements/compose.py b/buildstream/plugins/elements/compose.py
index d61a324..1c34480 100644
--- a/buildstream/plugins/elements/compose.py
+++ b/buildstream/plugins/elements/compose.py
@@ -58,6 +58,9 @@ class ComposeElement(Element):
     # This plugin has been modified to avoid the use of Sandbox.get_directory
     BST_VIRTUAL_DIRECTORY = True
 
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
+
     def configure(self, node):
         self.node_validate(node, [
             'integrate', 'include', 'exclude', 'include-orphans'
@@ -86,7 +89,10 @@ class ComposeElement(Element):
     def configure_sandbox(self, sandbox):
         pass
 
-    def stage(self, sandbox):
+    def stage(self, sandbox, *, visited=None):
+        pass
+
+    def integrate_dependency_artifacts(self, sandbox, scope, *, visited=None):
         pass
 
     def assemble(self, sandbox):
@@ -122,9 +128,7 @@ class ComposeElement(Element):
                     snapshot = set(vbasedir.list_relative_paths())
                     vbasedir.mark_unmodified()
 
-                with sandbox.batch(0):
-                    for dep in self.dependencies(Scope.BUILD):
-                        dep.integrate(sandbox)
+                super().integrate_dependency_artifacts(sandbox, Scope.BUILD)
 
                 if require_split:
                     # Calculate added, modified and removed files
diff --git a/buildstream/plugins/elements/distutils.py b/buildstream/plugins/elements/distutils.py
index 20a2d67..efef493 100644
--- a/buildstream/plugins/elements/distutils.py
+++ b/buildstream/plugins/elements/distutils.py
@@ -36,7 +36,8 @@ from buildstream import BuildElement
 
 # Element implementation for the python 'distutils' kind.
 class DistutilsElement(BuildElement):
-    pass
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
 
 
 # Plugin entry point
diff --git a/buildstream/plugins/elements/filter.py b/buildstream/plugins/elements/filter.py
index 6723253..3d882c7 100644
--- a/buildstream/plugins/elements/filter.py
+++ b/buildstream/plugins/elements/filter.py
@@ -97,7 +97,7 @@ class FilterElement(Element):
     def configure_sandbox(self, sandbox):
         pass
 
-    def stage(self, sandbox):
+    def stage(self, sandbox, *, visited=None):
         pass
 
     def assemble(self, sandbox):
diff --git a/buildstream/plugins/elements/import.py b/buildstream/plugins/elements/import.py
index ec491a0..a65994a 100644
--- a/buildstream/plugins/elements/import.py
+++ b/buildstream/plugins/elements/import.py
@@ -43,6 +43,8 @@ class ImportElement(BuildElement):
 
     # This plugin has been modified to avoid the use of Sandbox.get_directory
     BST_VIRTUAL_DIRECTORY = True
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
 
     def configure(self, node):
         self.source = self.node_subst_member(node, 'source')
@@ -64,7 +66,10 @@ class ImportElement(BuildElement):
     def configure_sandbox(self, sandbox):
         pass
 
-    def stage(self, sandbox):
+    def stage(self, sandbox, *, visited=None):
+        pass
+
+    def integrate_dependency_artifacts(self, sandbox, scope, *, visited=None):
         pass
 
     def assemble(self, sandbox):
diff --git a/buildstream/plugins/elements/junction.py b/buildstream/plugins/elements/junction.py
index 7f98173..05d5bff 100644
--- a/buildstream/plugins/elements/junction.py
+++ b/buildstream/plugins/elements/junction.py
@@ -152,7 +152,7 @@ class JunctionElement(Element):
     def configure_sandbox(self, sandbox):
         raise PipelineError("Cannot build junction elements")
 
-    def stage(self, sandbox):
+    def stage(self, sandbox, *, visited=None):
         raise PipelineError("Cannot stage junction elements")
 
     def generate_script(self):
diff --git a/buildstream/plugins/elements/make.py b/buildstream/plugins/elements/make.py
index a22de16..5a3387e 100644
--- a/buildstream/plugins/elements/make.py
+++ b/buildstream/plugins/elements/make.py
@@ -43,6 +43,8 @@ from buildstream import BuildElement
 class MakeElement(BuildElement):
     # Supports virtual directories (required for remote execution)
     BST_VIRTUAL_DIRECTORY = True
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
 
 
 # Plugin entry point
diff --git a/buildstream/plugins/elements/makemaker.py b/buildstream/plugins/elements/makemaker.py
index 8ad9799..f2cd7a7 100644
--- a/buildstream/plugins/elements/makemaker.py
+++ b/buildstream/plugins/elements/makemaker.py
@@ -36,7 +36,8 @@ from buildstream import BuildElement
 
 # Element implementation for the 'makemaker' kind.
 class MakeMakerElement(BuildElement):
-    pass
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
 
 
 # Plugin entry point
diff --git a/buildstream/plugins/elements/manual.py b/buildstream/plugins/elements/manual.py
index 8f951ab..393a009 100644
--- a/buildstream/plugins/elements/manual.py
+++ b/buildstream/plugins/elements/manual.py
@@ -38,6 +38,8 @@ from buildstream import BuildElement
 class ManualElement(BuildElement):
     # Supports virtual directories (required for remote execution)
     BST_VIRTUAL_DIRECTORY = True
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
 
 
 # Plugin entry point
diff --git a/buildstream/plugins/elements/meson.py b/buildstream/plugins/elements/meson.py
index 0d5ca00..312ae40 100644
--- a/buildstream/plugins/elements/meson.py
+++ b/buildstream/plugins/elements/meson.py
@@ -58,6 +58,8 @@ from buildstream import BuildElement
 class MesonElement(BuildElement):
     # Supports virtual directories (required for remote execution)
     BST_VIRTUAL_DIRECTORY = True
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
 
 
 # Plugin entry point
diff --git a/buildstream/plugins/elements/modulebuild.py b/buildstream/plugins/elements/modulebuild.py
index d619a1d..89ec908 100644
--- a/buildstream/plugins/elements/modulebuild.py
+++ b/buildstream/plugins/elements/modulebuild.py
@@ -36,7 +36,8 @@ from buildstream import BuildElement
 
 # Element implementation for the 'modulebuild' kind.
 class ModuleBuildElement(BuildElement):
-    pass
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
 
 
 # Plugin entry point
diff --git a/buildstream/plugins/elements/pip.py b/buildstream/plugins/elements/pip.py
index 02b593a..f2cf377 100644
--- a/buildstream/plugins/elements/pip.py
+++ b/buildstream/plugins/elements/pip.py
@@ -36,7 +36,8 @@ from buildstream import BuildElement
 
 # Element implementation for the 'pip' kind.
 class PipElement(BuildElement):
-    pass
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
 
 
 # Plugin entry point
diff --git a/buildstream/plugins/elements/qmake.py b/buildstream/plugins/elements/qmake.py
index d6776b0..314219d 100644
--- a/buildstream/plugins/elements/qmake.py
+++ b/buildstream/plugins/elements/qmake.py
@@ -38,6 +38,8 @@ from buildstream import BuildElement
 class QMakeElement(BuildElement):
     # Supports virtual directories (required for remote execution)
     BST_VIRTUAL_DIRECTORY = True
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
 
 
 # Plugin entry point
diff --git a/buildstream/plugins/elements/script.py b/buildstream/plugins/elements/script.py
index 4e422c5..5ad93dd 100644
--- a/buildstream/plugins/elements/script.py
+++ b/buildstream/plugins/elements/script.py
@@ -42,6 +42,9 @@ import buildstream
 class ScriptElement(buildstream.ScriptElement):
     # pylint: disable=attribute-defined-outside-init
 
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
+
     def configure(self, node):
         for n in self.node_get_member(node, list, 'layout', []):
             dst = self.node_subst_member(n, 'destination')
diff --git a/buildstream/plugins/elements/stack.py b/buildstream/plugins/elements/stack.py
index 138afed..54e540c 100644
--- a/buildstream/plugins/elements/stack.py
+++ b/buildstream/plugins/elements/stack.py
@@ -33,6 +33,9 @@ class StackElement(Element):
     # This plugin has been modified to avoid the use of Sandbox.get_directory
     BST_VIRTUAL_DIRECTORY = True
 
+    # This plugin has been modified to permit calling integration after staging
+    BST_STAGE_INTEGRATES = False
+
     def configure(self, node):
         pass
 
@@ -47,7 +50,10 @@ class StackElement(Element):
     def configure_sandbox(self, sandbox):
         pass
 
-    def stage(self, sandbox):
+    def stage(self, sandbox, *, visited=None):
+        pass
+
+    def integrate_dependency_artifacts(self, sandbox, scope, *, visited=None):
         pass
 
     def assemble(self, sandbox):