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>2019-08-03 22:18:16 -0400
commitc969fc86b2331be29055c1ffbb28589e5f990a85 (patch)
tree99675d74e7185753e3d5b80d5a15619ac47ed953
parentd1316fa759d71d531bf6a1802e3827ccf4b5cc23 (diff)
downloadbuildstream-c969fc86b2331be29055c1ffbb28589e5f990a85.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 ed4dd9617..24e5b6c5b 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -87,6 +87,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
--------------------------
@@ -487,9 +492,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 #
#############################################################
@@ -649,6 +667,11 @@ class Source(Plugin):
with context.silence():
self.__consistency = self.get_consistency()
+ # 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):