Skip to content

Commit a23ca93

Browse files
authored
[BuildPlan] Switch build plan construction to use graph traversal (#7854)
### Motivation: This way we can compute destinations as we go instead of relying on `buildTriple` computed during graph construction. ### Modifications: - Adds a new static method on `BuildPlan` to traverse modules graph and compute destinations for each product and module. - Switches `BuildPlan.init` from using `allProducts` and `allModules` flat lists over the new incremental destination computation. ### Result: Removes one of the last places were `buildTriple` is required.
1 parent 1284494 commit a23ca93

File tree

2 files changed

+279
-132
lines changed

2 files changed

+279
-132
lines changed

Sources/Basics/Graph/GraphAlgorithms.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import struct OrderedCollections.OrderedSet
2828
public func depthFirstSearch<T: Hashable>(
2929
_ nodes: [T],
3030
successors: (T) throws -> [T],
31-
onUnique: (T) -> Void,
31+
onUnique: (T) throws -> Void,
3232
onDuplicate: (T, T) -> Void
3333
) rethrows {
3434
var stack = OrderedSet<T>()
@@ -43,7 +43,7 @@ public func depthFirstSearch<T: Hashable>(
4343

4444
let visitResult = visited.insert(curr)
4545
if visitResult.inserted {
46-
onUnique(curr)
46+
try onUnique(curr)
4747
} else {
4848
onDuplicate(visitResult.memberAfterInsert, curr)
4949
continue

0 commit comments

Comments
 (0)