Skip to content

Commit a3b578f

Browse files
committed
Remove differences with main from prebuilts feature
1 parent eb26f4c commit a3b578f

File tree

7 files changed

+17
-79
lines changed

7 files changed

+17
-79
lines changed

Sources/Basics/Graph/GraphAlgorithms.swift

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -131,50 +131,3 @@ public func depthFirstSearch<T: Hashable>(
131131
}
132132
}
133133
}
134-
135-
/// Implements a pre-order depth-first search that traverses the whole graph and
136-
/// doesn't distinguish between unique and duplicate nodes. The visitor can abort
137-
/// a path as needed to prune the tree.
138-
/// The method expects the graph to be acyclic but doesn't check that.
139-
///
140-
/// - Parameters:
141-
/// - nodes: The list of input nodes to sort.
142-
/// - successors: A closure for fetching the successors of a particular node.
143-
/// - onNext: A callback to indicate the node currently being processed
144-
/// including its parent (if any) and its depth. Returns whether to
145-
/// continue down the current path.
146-
///
147-
/// - Complexity: O(v + e) where (v, e) are the number of vertices and edges
148-
/// reachable from the input nodes via the relation.
149-
public enum DepthFirstContinue {
150-
case `continue`
151-
case abort
152-
}
153-
154-
public func depthFirstSearch<T: Hashable>(
155-
_ nodes: [T],
156-
successors: (T) throws -> [T],
157-
visitNext: (T, _ parent: T?) throws -> DepthFirstContinue
158-
) rethrows {
159-
var stack = OrderedSet<TraversalNode<T>>()
160-
161-
for node in nodes {
162-
precondition(stack.isEmpty)
163-
stack.append(TraversalNode(parent: nil, curr: node))
164-
165-
while !stack.isEmpty {
166-
let node = stack.removeLast()
167-
168-
if try visitNext(node.curr, node.parent) == .continue {
169-
for succ in try successors(node.curr) {
170-
stack.append(
171-
TraversalNode(
172-
parent: node.curr,
173-
curr: succ
174-
)
175-
)
176-
}
177-
}
178-
}
179-
}
180-
}

Sources/Build/BuildDescription/ModuleBuildDescription.swift

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -195,30 +195,8 @@ extension ModuleBuildDescription {
195195
var dependencies: [Dependency] = []
196196
plan.traverseDependencies(of: self) { product, _, description in
197197
dependencies.append(.product(product, description))
198-
return .continue
199198
} onModule: { module, _, description in
200199
dependencies.append(.module(module, description))
201-
return .continue
202-
}
203-
return dependencies
204-
}
205-
206-
package func recursiveLinkDependencies(using plan: BuildPlan) -> [Dependency] {
207-
var dependencies: [Dependency] = []
208-
plan.traverseDependencies(of: self) { product, _, description in
209-
guard product.type != .macro && product.type != .plugin else {
210-
return .abort
211-
}
212-
213-
dependencies.append(.product(product, description))
214-
return .continue
215-
} onModule: { module, _, description in
216-
guard module.type != .macro && module.type != .plugin else {
217-
return .abort
218-
}
219-
220-
dependencies.append(.module(module, description))
221-
return .continue
222200
}
223201
return dependencies
224202
}

Sources/Build/BuildPlan/BuildPlan.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,8 +1175,8 @@ extension BuildPlan {
11751175

11761176
package func traverseDependencies(
11771177
of description: ModuleBuildDescription,
1178-
onProduct: (ResolvedProduct, BuildParameters.Destination, ProductBuildDescription?) -> DepthFirstContinue,
1179-
onModule: (ResolvedModule, BuildParameters.Destination, ModuleBuildDescription?) -> DepthFirstContinue
1178+
onProduct: (ResolvedProduct, BuildParameters.Destination, ProductBuildDescription?) -> Void,
1179+
onModule: (ResolvedModule, BuildParameters.Destination, ModuleBuildDescription?) -> Void
11801180
) {
11811181
var visited = Set<TraversalNode>()
11821182
func successors(
@@ -1217,16 +1217,16 @@ extension BuildPlan {
12171217
case .package:
12181218
[]
12191219
}
1220-
} visitNext: { module, _ in
1220+
} onNext: { module, _ in
12211221
switch module {
12221222
case .package:
1223-
return .continue
1223+
break
12241224

12251225
case .product(let product, let destination):
1226-
return onProduct(product, destination, self.description(for: product, context: destination))
1226+
onProduct(product, destination, self.description(for: product, context: destination))
12271227

12281228
case .module(let module, let destination):
1229-
return onModule(module, destination, self.description(for: module, context: destination))
1229+
onModule(module, destination, self.description(for: module, context: destination))
12301230
}
12311231
}
12321232
}

Sources/Workspace/ManagedPrebuilt.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import struct TSCBasic.StringError
1515

1616
import Basics
1717
import PackageModel
18-
import TSCBasic
1918

2019
extension Workspace {
2120
/// A downloaded prebuilt managed by the workspace.
@@ -30,7 +29,7 @@ extension Workspace {
3029
public let libraryName: String
3130

3231
/// The path to the extracted prebuilt artifacts
33-
public let path: Basics.AbsolutePath
32+
public let path: AbsolutePath
3433

3534
/// The products in the library
3635
public let products: [String]

Tests/BuildTests/BuildPlanTraversalTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ struct BuildPlanTraversalTests {
152152
#expect(description == nil)
153153
} onModule: { module, destination, description in
154154
moduleDependencies.append((module, destination, description))
155-
return .continue
156155
}
157156

158157
#expect(moduleDependencies.count == 2)

Tests/WorkspaceTests/PrebuiltsTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,3 +890,13 @@ final class PrebuiltsTests: XCTestCase {
890890
}
891891
}
892892
}
893+
894+
extension String {
895+
var fixwin: String {
896+
#if os(Windows)
897+
return self.replacingOccurrences(of: "/", with: "\\")
898+
#else
899+
return self
900+
#endif
901+
}
902+
}

Utilities/build-using-self

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ def filterNone(items: t.Iterable) -> t.Iterable:
163163

164164
def main() -> None:
165165
args = get_arguments()
166-
ignore = "-Xlinker /ignore:4217" if os.name == "nt" else ""
167166
logging.getLogger().setLevel(logging.DEBUG if args.is_verbose else logging.INFO)
168167
logging.debug("Args: %r", args)
169168
ignore_args = ["-Xlinker", "/ignore:4217"] if os.name == "nt" else []

0 commit comments

Comments
 (0)