diff options
-rw-r--r-- | src/buildstream/_element.pyx | 21 | ||||
-rw-r--r-- | src/buildstream/element.py | 6 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/buildstream/_element.pyx b/src/buildstream/_element.pyx index 56fa5f141..3beeb3512 100644 --- a/src/buildstream/_element.pyx +++ b/src/buildstream/_element.pyx @@ -109,3 +109,24 @@ def recursive_dependencies_helper(element, scope, visited): else: # Scope.NONE, unusual here. yield element + +def build_deps_cachekeys_helper(element): + ret = [] + visit_stack = [] + runtime_visited = BitMap() + + for dep in reversed(element._Element__build_dependencies): + visit_stack.append((dep, False)) + + while visit_stack: + element, visited = visit_stack.pop() + if visited: + ret.append(element._Element__strict_cache_key) + elif element._unique_id not in runtime_visited: + runtime_visited.add(element._unique_id) + visit_stack.append((element, True)) + visit_stack.extend(( + (dep, False) for dep in reversed(element._Element__runtime_dependencies) + if dep._unique_id not in runtime_visited)) + + return ret diff --git a/src/buildstream/element.py b/src/buildstream/element.py index 57322293d..e8d8dad6a 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -108,7 +108,7 @@ from .storage._filebaseddirectory import FileBasedDirectory from .storage._casbaseddirectory import CasBasedDirectory from .storage.directory import VirtualDirectoryError -from ._element import recursive_dependencies_helper +from ._element import recursive_dependencies_helper, build_deps_cachekeys_helper class ElementError(BstError): """This exception should be raised by :class:`.Element` implementations @@ -2902,9 +2902,7 @@ class Element(Plugin): return if self.__strict_cache_key is None: - dependencies = [ - e.__strict_cache_key for e in self.dependencies(Scope.BUILD) - ] + dependencies = build_deps_cachekeys_helper(self) self.__strict_cache_key = self._calculate_cache_key(dependencies) # __update_artifact_state() |