summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2017-07-20 17:39:28 +0200
committerJürg Billeter <j@bitron.ch>2017-07-25 18:06:40 +0100
commite45b36750cd695cc1566a27b8f2f37a18c2ef159 (patch)
tree0e7d3de0c39a85c7ff95d34a9dacd3ba37fcd7d5
parent5e7cf0efb2cd5253635900fa150e68d8f5476ae1 (diff)
downloadbuildstream-e45b36750cd695cc1566a27b8f2f37a18c2ef159.tar.gz
element.py: Introduce artifact versions
Fixes #49
-rw-r--r--buildstream/element.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index a4fa696a1..a1a07bb78 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -511,6 +511,19 @@ class Element(Plugin):
return None
+ def get_artifact_version(self):
+ """Return the element plugin's artifact version
+
+ Returns:
+ (int): Artifact version
+
+ Elements must implement this method if they change their unique
+ key structure in an incompatible way or trigger a change in the
+ build output for the same unique key. Every further change
+ requires bumping the returned version.
+ """
+ return 0
+
#############################################################
# Abstract Element Methods #
#############################################################
@@ -801,6 +814,20 @@ class Element(Plugin):
return True
+ # _get_core_artifact_version():
+ #
+ # Return the artifact version of core BuildStream.
+ #
+ # Returns
+ # (int): Artifact version
+ #
+ # The returned version requires a bump whenever the cache key
+ # algorithm, the artifact structure, or the artifact metadata
+ # changes in an incompatible way.
+ #
+ def _get_core_artifact_version(self):
+ return 0
+
# __calculate_cache_key():
#
# Calculates the cache key
@@ -825,6 +852,8 @@ class Element(Plugin):
context = self.get_context()
project = self.get_project()
return utils._generate_key({
+ 'artifact-version': "{}.{}".format(self._get_core_artifact_version(),
+ self.get_artifact_version()),
'context': context._get_cache_key(),
'project': project._get_cache_key(),
'element': self.get_unique_key(),