summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk>2019-03-04 15:37:18 +0000
committerJürg Billeter <j@bitron.ch>2019-03-14 07:12:34 +0000
commitafbf208525af234e9a2eda1b98224aaafa80ee1d (patch)
tree026681105c16869f2cf73ce090ebfa7fba8f3c61
parent1109b800dafc41d9e4428ca9e1b40542de671f9c (diff)
downloadbuildstream-afbf208525af234e9a2eda1b98224aaafa80ee1d.tar.gz
source.py: Add source cache key
This adds o _key: property to access cache key o generate_key: method to generate key given previous sources o _get_source_name: method to create ref for given source Part of #440
-rw-r--r--buildstream/source.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/buildstream/source.py b/buildstream/source.py
index 97995a8da..abbf758c9 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -170,6 +170,7 @@ from . import _yaml, utils
from ._exceptions import BstError, ImplError, ErrorDomain
from ._loader.metasource import MetaSource
from ._projectrefs import ProjectRefStorage
+from ._cachekey import generate_key
class SourceError(BstError):
@@ -295,6 +296,8 @@ class Source(Plugin):
self.__directory = meta.directory # Staging relative directory
self.__consistency = Consistency.INCONSISTENT # Cached consistency state
+ self.__key = None # Cache key for source
+
# The alias_override is only set on a re-instantiated Source
self.__alias_override = alias_override # Tuple of alias and its override to use instead
self.__expected_alias = None # The primary alias
@@ -956,6 +959,26 @@ class Source(Plugin):
else:
return None
+ def _generate_key(self, previous_sources):
+ keys = [self._get_unique_key(True)]
+
+ for previous_source in previous_sources:
+ keys.append(previous_source._get_unique_key(True))
+
+ self.__key = generate_key(keys)
+
+ @property
+ def _key(self):
+ return self.__key
+
+ # Gives a ref path that points to where sources are kept in the CAS
+ def _get_source_name(self):
+ # @ is used to prevent conflicts with project names
+ return "{}/{}/{}".format(
+ '@sources',
+ self.get_kind(),
+ self._key)
+
#############################################################
# Local Private Methods #
#############################################################