summaryrefslogtreecommitdiff
path: root/src/buildstream/plugins
diff options
context:
space:
mode:
authorBenjamin Schubert <bschubert15@bloomberg.net>2019-11-27 16:26:37 +0000
committerBenjamin Schubert <bschubert15@bloomberg.net>2020-01-16 16:33:19 +0000
commit4a47af24fca8aeb6c0c0fe6bd754712ecce5211d (patch)
tree08f72ea7bbc2979637900b1bcaeb8aa798d41c52 /src/buildstream/plugins
parent93ebe4992c32b2588ae213a98c3e05d60c974a00 (diff)
downloadbuildstream-4a47af24fca8aeb6c0c0fe6bd754712ecce5211d.tar.gz
source.py: Add a new 'is_resolved' to get whether a source is resolved.
`get_consistency` is coarse grained and hard to optimize, in addition to being un-userfriendly. This adds a new `is_resolved` that has for default implementation `get_ref() is not None`, which is true for most sources in BuildStream. Sources for which this is not true can override the method to give a more accurate description. Checking for this before looking whether the source is cached can reduce the amount of work necessary in some pipeline and opens the door for more optimizations and the removal of the source state check.
Diffstat (limited to 'src/buildstream/plugins')
-rw-r--r--src/buildstream/plugins/sources/local.py3
-rw-r--r--src/buildstream/plugins/sources/patch.py3
-rw-r--r--src/buildstream/plugins/sources/workspace.py3
3 files changed, 9 insertions, 0 deletions
diff --git a/src/buildstream/plugins/sources/local.py b/src/buildstream/plugins/sources/local.py
index 90d8a8f6f..f4a7270e6 100644
--- a/src/buildstream/plugins/sources/local.py
+++ b/src/buildstream/plugins/sources/local.py
@@ -64,6 +64,9 @@ class LocalSource(Source):
def get_consistency(self):
return Consistency.CACHED
+ def is_resolved(self):
+ return True
+
# We dont have a ref, we're a local file...
def load_ref(self, node):
pass
diff --git a/src/buildstream/plugins/sources/patch.py b/src/buildstream/plugins/sources/patch.py
index 082983023..cc3e6e2c4 100644
--- a/src/buildstream/plugins/sources/patch.py
+++ b/src/buildstream/plugins/sources/patch.py
@@ -67,6 +67,9 @@ class PatchSource(Source):
def get_unique_key(self):
return [self.path, utils.sha256sum(self.fullpath), self.strip_level]
+ def is_resolved(self):
+ return True
+
def get_consistency(self):
return Consistency.CACHED
diff --git a/src/buildstream/plugins/sources/workspace.py b/src/buildstream/plugins/sources/workspace.py
index 3d4c93b5c..88c32f754 100644
--- a/src/buildstream/plugins/sources/workspace.py
+++ b/src/buildstream/plugins/sources/workspace.py
@@ -69,6 +69,9 @@ class WorkspaceSource(Source):
def preflight(self) -> None:
pass # pragma: nocover
+ def is_resolved(self):
+ return os.path.exists(self._get_local_path())
+
def get_ref(self) -> None:
return None