summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-01-22 17:34:44 +0100
committerJürg Billeter <j@bitron.ch>2020-02-11 21:08:59 +0100
commit8318fefc9ade579eb3cb754f77a9997bd511dd8d (patch)
tree702e7ce1345b4f3181bd46beb1ed607094d689b9
parent49c9e58af6b4980628485636d813699e4e7e3ffb (diff)
downloadbuildstream-8318fefc9ade579eb3cb754f77a9997bd511dd8d.tar.gz
buildelement.py: Use marker file to avoid rerunning configure
-rw-r--r--src/buildstream/buildelement.py32
-rw-r--r--src/buildstream/element.py5
2 files changed, 28 insertions, 9 deletions
diff --git a/src/buildstream/buildelement.py b/src/buildstream/buildelement.py
index f04d3b0dc..aeafbcdda 100644
--- a/src/buildstream/buildelement.py
+++ b/src/buildstream/buildelement.py
@@ -262,10 +262,34 @@ class BuildElement(Element):
def prepare(self, sandbox):
commands = self.__commands["configure-commands"]
- if commands:
- with sandbox.batch(SandboxFlags.ROOT_READ_ONLY, label="Running configure-commands"):
- for cmd in commands:
- self.__run_command(sandbox, cmd)
+ if not commands:
+ # No configure commands, nothing to do.
+ return
+
+ # 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`.
+ marker_filename = ".bst-prepared"
+
+ if self._get_workspace():
+ # We use an empty file as a marker whether prepare() has already
+ # been called in a previous build.
+
+ vdir = sandbox.get_virtual_directory()
+ buildroot = self.get_variable("build-root")
+ buildroot_vdir = vdir.descend(*buildroot.lstrip(os.sep).split(os.sep))
+
+ if buildroot_vdir._exists(marker_filename, follow_symlinks=True):
+ # Already prepared
+ return
+
+ with sandbox.batch(SandboxFlags.ROOT_READ_ONLY, label="Running configure-commands"):
+ for cmd in commands:
+ self.__run_command(sandbox, cmd)
+
+ if self._get_workspace():
+ sandbox._create_empty_file(marker_filename)
def generate_script(self):
script = ""
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 30bde25e2..f7b57a4ed 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -2324,11 +2324,6 @@ 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)
# __preflight():