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-20 17:39:54 +0200
commitcb8fd11e540fb85347d95c1f157af740b33301a9 (patch)
treeb5e81c03d47b8ce5a412a67f7544e60b19bdd539
parent977210795c9ec67309eae3b78e2100c6b2281823 (diff)
downloadbuildstream-artifact-version.tar.gz
element.py: Introduce artifact versionsartifact-version
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 60e81fda1..f00bb18fd 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 a bump 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
@@ -833,6 +860,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(),