summaryrefslogtreecommitdiff
path: root/src/buildstream/element.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildstream/element.py')
-rw-r--r--src/buildstream/element.py40
1 files changed, 11 insertions, 29 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 8e006ea6b..af8ee80a4 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -104,6 +104,7 @@ from .sandbox._config import SandboxConfig
from .sandbox._sandboxremote import SandboxRemote
from .types import Consistency, CoreWarnings, Scope, _KeyStrength, _UniquePriorityQueue
from ._artifact import Artifact
+from ._element import deps_visit, DepScope
from .storage.directory import Directory
from .storage._filebaseddirectory import FileBasedDirectory
@@ -419,34 +420,6 @@ class Element(Plugin):
if scope in (Scope.RUN, Scope.ALL):
yield from self.__runtime_dependencies
else:
- def visit(element, scope, visited):
- if scope == Scope.ALL:
- visited[0].add(element._unique_id)
- visited[1].add(element._unique_id)
-
- for dep in chain(element.__build_dependencies, element.__runtime_dependencies):
- if dep._unique_id not in visited[0] and dep._unique_id not in visited[1]:
- yield from visit(dep, Scope.ALL, visited)
-
- yield element
- elif scope == Scope.BUILD:
- visited[0].add(element._unique_id)
-
- for dep in element.__build_dependencies:
- if dep._unique_id not in visited[1]:
- yield from visit(dep, Scope.RUN, visited)
-
- elif scope == Scope.RUN:
- visited[1].add(element._unique_id)
-
- for dep in element.__runtime_dependencies:
- if dep._unique_id not in visited[1]:
- yield from visit(dep, Scope.RUN, visited)
-
- yield element
- else:
- yield element
-
if visited is None:
# Visited is of the form (Visited for Scope.BUILD, Visited for Scope.RUN)
visited = (BitMap(), BitMap())
@@ -457,7 +430,16 @@ class Element(Plugin):
if scope in (Scope.RUN, Scope.ALL) and self._unique_id in visited[1]:
return
- yield from visit(self, scope, visited)
+ if scope == Scope.ALL:
+ scope = DepScope.ALL
+ elif scope == Scope.BUILD:
+ scope = DepScope.BUILD
+ elif scope == Scope.RUN:
+ scope = DepScope.RUN
+ else:
+ scope = DepScope.NONE
+
+ yield from deps_visit(self, scope, visited)
def search(self, scope, name):
"""Search for a dependency by name