summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2017-07-07 09:24:29 +0200
committerJürg Billeter <j@bitron.ch>2017-07-14 14:13:51 +0200
commitcb225c2aaabef6ef1627ca68caeeb2d0b99af78e (patch)
tree1aca79dafb9f0a830cb8d6c12a6320dc143fcc60
parentcc05e8365c3c6034c04fc6156ccbce285200704b (diff)
downloadbuildstream-cb225c2aaabef6ef1627ca68caeeb2d0b99af78e.tar.gz
element.py: Add _get_cache_key_from_artifact()
-rw-r--r--buildstream/element.py43
1 files changed, 34 insertions, 9 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index 310bf0ddc..3a652d657 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -99,15 +99,16 @@ class Element(Plugin):
and creating directory names and such.
"""
- self.__runtime_dependencies = [] # Direct runtime dependency Elements
- self.__build_dependencies = [] # Direct build dependency Elements
- self.__sources = [] # List of Sources
- self.__cache_key = None # Our cached cache key
- self.__weak_cache_key = None # Our cached weak cache key
- self.__artifacts = artifacts # Artifact cache
- self.__cached = None # Whether we have a cached artifact
- self.__built = False # Element was locally built
- self.__log_path = None # Path to dedicated log file or None
+ self.__runtime_dependencies = [] # Direct runtime dependency Elements
+ self.__build_dependencies = [] # Direct build dependency Elements
+ self.__sources = [] # List of Sources
+ self.__cache_key = None # Our cached cache key
+ self.__weak_cache_key = None # Our cached weak cache key
+ self.__cache_key_from_artifact = None # Our cached cache key from artifact
+ self.__artifacts = artifacts # Artifact cache
+ self.__cached = None # Whether we have a cached artifact
+ self.__built = False # Element was locally built
+ self.__log_path = None # Path to dedicated log file or None
self.__splits = None
# Ensure we have loaded this class's defaults
@@ -807,6 +808,30 @@ class Element(Plugin):
else:
return self.__weak_cache_key
+ # _get_cache_key_from_artifact():
+ #
+ # Returns the strong cache key as stored in the cached artifact
+ #
+ # Args:
+ # recalculate (bool): Whether to forcefully recalculate
+ #
+ # Returns:
+ # (str): A hex digest cache key for this Element
+ #
+ def _get_cache_key_from_artifact(self, recalculate=False):
+ if recalculate:
+ self.__cache_key_from_artifact = None
+
+ if self.__cache_key_from_artifact is None:
+ self._assert_cached(recalculate=False)
+
+ # Load the strong cache key from the artifact
+ metadir = os.path.join(self.__artifacts.extract(self), 'meta')
+ meta = _yaml.load(os.path.join(metadir, 'artifact.yaml'))
+ self.__cache_key_from_artifact = meta['keys']['strong']
+
+ return self.__cache_key_from_artifact
+
# _get_full_display_key():
#
# Returns cache keys for display purposes