summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-12-06 21:10:56 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-12-06 23:18:31 +0900
commitb1d2f001687a222893c45a9bf13af1705c9c483a (patch)
treeba6ffe789fbf2d01b96bef6541c400939edae380
parentbea4d4f541ce6de41def7bb87c32613931877f2a (diff)
downloadbuildstream-b1d2f001687a222893c45a9bf13af1705c9c483a.tar.gz
source.py: Add new delegate method validate_cache()
This is guaranteed to be called only once for a given session once the sources are known to be Consistency.CACHED, if source tracking is enabled in the session for this source, then this will only be called if the sources become cached after tracking completes.
-rw-r--r--buildstream/source.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/buildstream/source.py b/buildstream/source.py
index 5dc5abb63..bb54110ca 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -102,6 +102,11 @@ these methods are mandatory to implement.
submodules). For details on how to define a SourceFetcher, see
:ref:`SourceFetcher <core_source_fetcher>`.
+* :func:`Source.validate_cache() <buildstream.source.Source.validate_cache>`
+
+ Perform any validations which require the sources to be cached.
+
+ **Optional**: This is completely optional and will do nothing if left unimplemented.
Accessing previous sources
--------------------------
@@ -480,9 +485,22 @@ class Source(Plugin):
*Since: 1.2*
"""
-
return []
+ def validate_cache(self):
+ """Implement any validations once we know the sources are cached
+
+ This is guaranteed to be called only once for a given session
+ once the sources are known to be
+ :attr:`Consistency.CACHED <buildstream.types.Consistency.CACHED>`,
+ if source tracking is enabled in the session for this source,
+ then this will only be called if the sources become cached after
+ tracking completes.
+
+ *Since: 1.4*
+ """
+ pass
+
#############################################################
# Public Methods #
#############################################################
@@ -659,6 +677,11 @@ class Source(Plugin):
with context.silence():
self.__consistency = self.get_consistency() # pylint: disable=assignment-from-no-return
+ # Give the Source an opportunity to validate the cached
+ # sources as soon as the Source becomes Consistency.CACHED.
+ if self.__consistency == Consistency.CACHED:
+ self.validate_cache()
+
# Return cached consistency
#
def _get_consistency(self):