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:34:14 UTC

[buildstream] 02/02: element.py: Separate initial resolving of elements from _update_state

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

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

commit b3371fd8ce271424fe5f95669f62e3a47f06f91a
Author: James Ennis <ja...@codethink.co.uk>
AuthorDate: Mon Jun 10 16:46:28 2019 +0100

    element.py: Separate initial resolving of elements from _update_state
    
    A new _resolve_cache_keys_and_state() method has been added to
    Element. This ensures that sources are consistent, calculates
    the cache keys and then determines the artifact state.
---
 src/buildstream/_pipeline.py |  7 +++++--
 src/buildstream/element.py   | 26 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/buildstream/_pipeline.py b/src/buildstream/_pipeline.py
index d448133..427836a 100644
--- a/src/buildstream/_pipeline.py
+++ b/src/buildstream/_pipeline.py
@@ -135,8 +135,11 @@ class Pipeline():
                 # Preflight
                 element._preflight()
 
-                # Determine initial element state.
-                element._update_state()
+                element._resolve_cache_keys_and_state()
+
+                # EWWW
+                if element._get_workspace() and not element._cached_success():
+                    element._set_required()
 
     # dependencies()
     #
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index a448b86..fdbddc1 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -1170,6 +1170,32 @@ class Element(Plugin):
         # cache cannot be queried until strict cache key is available
         return self.__strict_cache_key is not None
 
+    def _resolve_cache_keys_and_state(self):
+        context = self._get_context()
+
+        # Ensure the element's sources are resolved
+        self.__update_source_state()
+        if self._get_consistency() == Consistency.INCONSISTENT:
+            return
+
+        # Update the cache keys
+        # Note that for non-strict mode, the strong cache key cannot be
+        # calculated until we have updated the artifact state
+        self.__update_cache_keys()
+
+        # update the artifact state
+        self.__update_artifact_state()
+
+        if not context.get_strict():
+            self.__update_cache_key_non_strict()
+
+        # If the element is workspaced, it could potentially already be cached,
+        # therefore, determine the artifact data of the workspaced element
+        # immediately and check if it's cached.
+        # If not, reset the data
+        if self._get_workspace() and not self._cached_success():
+            self.__reset_cache_data()
+
     # _update_state()
     #
     # Keep track of element state. Calculate cache keys if possible and