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:58:56 UTC

[buildstream] 20/26: Replace workspace.prepared callback with attribute marking

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

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

commit 4d0d43dee0672dc01b10a0f35a0bdab1d4c8adbe
Author: Darius Makovsky <tr...@protonmail.com>
AuthorDate: Fri Nov 15 13:15:53 2019 +0000

    Replace workspace.prepared callback with attribute marking
    
    Supports workspace builds via RE
---
 src/buildstream/buildelement.py    |  1 +
 src/buildstream/element.py         | 17 +++++++++++++++--
 src/buildstream/sandbox/sandbox.py |  3 +++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/buildstream/buildelement.py b/src/buildstream/buildelement.py
index f04d3b0..ae2a3e2 100644
--- a/src/buildstream/buildelement.py
+++ b/src/buildstream/buildelement.py
@@ -266,6 +266,7 @@ class BuildElement(Element):
             with sandbox.batch(SandboxFlags.ROOT_READ_ONLY, label="Running configure-commands"):
                 for cmd in commands:
                     self.__run_command(sandbox, cmd)
+        sandbox.prepared = True
 
     def generate_script(self):
         script = ""
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 20cc809..c2018b3 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -389,6 +389,7 @@ class Element(Plugin):
 
         *Since: 1.2*
         """
+        sandbox.prepared = True
 
     def assemble(self, sandbox: "Sandbox") -> str:
         """Assemble the output artifact
@@ -2378,12 +2379,24 @@ class Element(Plugin):
     # Internal method for calling public abstract prepare() method.
     #
     def __prepare(self, sandbox):
-        # FIXME:
         # We need to ensure that the prepare() method is only called
         # once in workspaces, because the changes will persist across
         # incremental builds - not desirable, for example, in the case
         # of autotools' `./configure`.
-        self.prepare(sandbox)
+        workspace = self._get_workspace()
+        prepared = False
+        if workspace and workspace.prepared:
+            # FIXME: ideally we don't have to check this, eventually we would
+            # like to get the saved old_ref and apply the new workspace on top
+            # to support incremental builds.
+            if [s._key for s in self.__sources] == [workspace.last_successful]:
+                prepared = False
+
+        if not prepared:
+            self.prepare(sandbox)
+
+        if workspace and sandbox.prepared:
+            workspace.prepared = True
 
     # __preflight():
     #
diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py
index e91e890..26e551d 100644
--- a/src/buildstream/sandbox/sandbox.py
+++ b/src/buildstream/sandbox/sandbox.py
@@ -168,6 +168,9 @@ class Sandbox:
         # Pending command batch
         self.__batch = None
 
+        # was the sandbox prepared
+        self.prepared = False
+
     def get_directory(self) -> str:
         """Fetches the sandbox root directory