summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.com>2017-07-17 11:23:59 +0100
committerTristan Maat <tristan.maat@codethink.com>2017-07-17 13:16:08 +0100
commit4a38386b4d5dc740c68eaf5e5fd3f7e4f59e003c (patch)
tree7424b7e16eaf0f177c90686d89a802894aff9f25
parent7227cd41b8f593357df2c4c10d16c5b48c421de1 (diff)
downloadbuildstream-4a38386b4d5dc740c68eaf5e5fd3f7e4f59e003c.tar.gz
element.py: Encode workspaced dependencies in metadata
-rw-r--r--buildstream/element.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index 08d2b9458..ae56365e6 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -137,6 +137,7 @@ class Element(Plugin):
self.__tainted = None
self.__workspaced_artifact = None
+ self.__workspaced_dependencies_artifact = None
def __lt__(self, other):
return self.name < other.name
@@ -713,12 +714,18 @@ class Element(Plugin):
# _tainted():
#
+ # Whether this artifact should be pushed to an artifact cache.
+ #
# Args:
# recalculate (bool) - Whether to force recalculation
#
# Returns:
# (bool) False if this artifact should be excluded from pushing.
#
+ # Note:
+ # This method should only be called after the element's
+ # artifact is present in the local artifact cache.
+ #
def _tainted(self, recalculate=False):
if recalculate or self.__tainted is None:
@@ -726,11 +733,12 @@ class Element(Plugin):
workspaced = self._workspaced_artifact()
# Whether this artifact's dependencies are tainted
- dependencies = any(d._tainted() for d in self.dependencies(Scope.BUILD)
- if d != self)
+ workspaced_dependencies = any(val for key, val in
+ self._workspaced_dependencies_artifact().items()
+ if key != _yaml.PROVENANCE_KEY)
# Other conditions should be or-ed
- self.__tainted = workspaced or dependencies
+ self.__tainted = workspaced or workspaced_dependencies
return self.__tainted
@@ -1020,13 +1028,17 @@ class Element(Plugin):
dependencies = {
e.name: e._get_cache_key_from_artifact() for e in self.dependencies(Scope.BUILD)
}
+ workspaced_dependencies = {
+ e.name: e._workspaced() for e in self.dependencies(Scope.BUILD)
+ }
meta = {
- 'workspaced': self._workspaced(),
'keys': {
'strong': self._get_cache_key_for_build(),
'weak': self._get_cache_key(_KeyStrength.WEAK),
'dependencies': dependencies
- }
+ },
+ 'workspaced': self._workspaced(),
+ 'workspaced_dependencies': workspaced_dependencies
}
_yaml.dump(_yaml.node_sanitize(meta), os.path.join(metadir, 'artifact.yaml'))
@@ -1169,6 +1181,17 @@ class Element(Plugin):
return self.__workspaced_artifact
+ def _workspaced_dependencies_artifact(self):
+
+ if self.__workspaced_dependencies_artifact is None:
+ self._assert_cached(recalculate=False)
+
+ metadir = os.path.join(self.__artifacts.extract(self), 'meta')
+ meta = _yaml.load(os.path.join(metadir, 'artifact.yaml'))
+ self.__workspaced_dependencies_artifact = meta['workspaced_dependencies']
+
+ return self.__workspaced_dependencies_artifact
+
# Run some element methods with logging directed to
# a dedicated log file, here we yield the filename
# we decided on for logging