diff options
author | Tristan Maat <tristan.maat@codethink.com> | 2017-07-17 11:23:59 +0100 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-17 23:03:00 +0900 |
commit | 37ed5511f10fa0ec322846bdcda9e7231c4aac43 (patch) | |
tree | 75f2559be6b58940c17654cfb4e34a5143502507 | |
parent | 1d23595871cd7e1a0322e7674525c4911ffb5617 (diff) | |
download | buildstream-37ed5511f10fa0ec322846bdcda9e7231c4aac43.tar.gz |
element.py: Encode workspaced dependencies in metadata
-rw-r--r-- | buildstream/element.py | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index bfe301545..f773ab739 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -145,6 +145,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 @@ -721,12 +722,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: @@ -734,11 +741,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 @@ -1028,13 +1036,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')) @@ -1177,6 +1189,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 |