Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/buildstream/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ def subsandbox(self, sandbox: "Sandbox") -> Iterator["Sandbox"]:
# Yields:
# (Element): The dependencies in `scope`, in deterministic staging order
#
def _dependencies(self, scope: _Scope, *, recurse=True, visited=None):
def _dependencies(self, scope: _Scope, *, recurse=True, visited=None) -> Iterator["Element"]:

# The format of visited is (BitMap(), BitMap()), with the first BitMap
# containing element that have been visited for the `_Scope.BUILD` case
Expand All @@ -883,8 +883,8 @@ def _dependencies(self, scope: _Scope, *, recurse=True, visited=None):
yield dep
else:

def visit(element, scope, visited):
if scope == _Scope.ALL:
def visit(element: Element, scope: _Scope, visited: tuple[BitMap, BitMap]) -> Iterator[Element]:
if scope == _Scope.ALL: # The element, its runtime and build dependencies
visited[0].add(element._unique_id)
visited[1].add(element._unique_id)

Expand All @@ -893,22 +893,22 @@ def visit(element, scope, visited):
yield from visit(dep, _Scope.ALL, visited)

yield element
elif scope == _Scope.BUILD:
elif scope == _Scope.BUILD: # The element's build dependencies only
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:
# _Scope.BUILD intentionally excludes yielding the element itself.
elif scope == _Scope.RUN: # The element and its runtime dependencies
visited[1].add(element._unique_id)
Comment thread
nathanwilliams-ct marked this conversation as resolved.

for dep in element.__runtime_dependencies:
if dep._unique_id not in visited[1]:
yield from visit(dep, _Scope.RUN, visited)

yield element
else:
else: # _Scope.NONE: Only the element
yield element

if visited is None:
Expand Down