diff options
author | Jürg Billeter <j@bitron.ch> | 2017-07-07 09:24:29 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2017-07-14 10:26:34 +0200 |
commit | cc9a829ac604df2ea384f119a763428e3467025d (patch) | |
tree | 90078702c6f8bc7187ddfdd3991855b16e75bc08 | |
parent | c36d32cb0004b65ff4c288f9c6f90afbaaa6288b (diff) | |
download | buildstream-cc9a829ac604df2ea384f119a763428e3467025d.tar.gz |
element.py: Add _get_cache_key_from_artifact()
-rw-r--r-- | buildstream/element.py | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index c151dc28d..1bbb1fd2b 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') + keys = _yaml.load(os.path.join(metadir, 'keys.yaml')) + self.__cache_key_from_artifact = keys['strong'] + + return self.__cache_key_from_artifact + # _get_full_display_key(): # # Returns cache keys for display purposes |