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

[buildstream] 06/06: fixups

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

not-in-ldap pushed a commit to branch jennis/rebase_fixups
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 92dbd508c6d538aebdc430210f0b5883a323a8ce
Author: James Ennis <ja...@codethink.co.uk>
AuthorDate: Thu Apr 18 13:01:06 2019 +0100

    fixups
---
 buildstream/_cachekey/cachekey.py       |  4 ++--
 buildstream/_cachekey/strictcachekey.py |  9 ++++++---
 buildstream/element.py                  | 20 ++++++++++++++++----
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/buildstream/_cachekey/cachekey.py b/buildstream/_cachekey/cachekey.py
index d3ae190..15b0df0 100644
--- a/buildstream/_cachekey/cachekey.py
+++ b/buildstream/_cachekey/cachekey.py
@@ -71,11 +71,11 @@ class CacheKey():
 
     def _update_weak_cached(self):
         if self._weak_key and not self._weak_cached:
-            self._weak_cached = self._element._is_key_cached(self._weak_key)
+            self._weak_cached = self._element._is_weak_cached()
 
     def _update_strong_cached(self):
         if self._strict_key and not self._strong_cached:
-            self._strong_cached = self._element._is_key_cached(self._strict_key)
+            self._strong_cached = self._element._is_strong_cached()
 
     # Set the weak key
     def _calculate_weak_key(self):
diff --git a/buildstream/_cachekey/strictcachekey.py b/buildstream/_cachekey/strictcachekey.py
index e87fb54..e984886 100644
--- a/buildstream/_cachekey/strictcachekey.py
+++ b/buildstream/_cachekey/strictcachekey.py
@@ -40,6 +40,12 @@ class StrictCacheKey(CacheKey):
             # and not cached
             return
 
+        # Assemble the strict artifact
+        self._element._assemble_strict_artifact()
+
+        if self._strong_key is None:
+            self._strong_key = self._strict_key
+
         self._update_strong_cached()
 
         # TODO: Figure out why _weak_cached is only set if it's identical
@@ -47,9 +53,6 @@ class StrictCacheKey(CacheKey):
         if self._strict_key == self._weak_key:
             self._update_weak_cached()
 
-        if self._strong_key is None:
-            self._strong_key = self._strict_key
-
         self._element._check_ready_for_runtime()
 
     def get_key(self, strength):
diff --git a/buildstream/element.py b/buildstream/element.py
index bd9ccbd..9441102 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1308,6 +1308,15 @@ class Element(Plugin):
 
         self._check_ready_for_runtime()
 
+    def _assemble_strict_artifact(self):
+        context = self._get_context()
+        strict = self._get_cache_key(strength=_KeyStrength.STRICT)
+        weak = self._get_cache_key(strength=_KeyStrength.WEAK)
+        self.__strict_artifact = Artifact(self, context, strong_key=strict,
+                                          weak_key=weak)
+        self.__artifact = self.__strict_artifact
+
+
     # _get_display_key():
     #
     # Returns cache keys for display purposes
@@ -2373,13 +2382,16 @@ class Element(Plugin):
             self.__ready_for_runtime = all(
                 dep.__ready_for_runtime for dep in self.__runtime_dependencies)
 
-    # _is_key_cached():
+    # _is_strong_cached():
     #
     # TODO: DOCSTRING
     #
-    def _is_key_cached(self, key):
-        assert key
-        return self.__artifact.cached(key)
+    def _is_strong_cached(self):
+        return self.__strict_artifact.cached()
+
+    def _is_weak_cached(self):
+        return self.__artifact.cached()
+
 
     # _is_pending_assembly():
     #