Skip to content

6.2 merge main #8607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ func swiftSyntaxDependencies(_ names: [String]) -> [Target.Dependency] {
// this right now.

/// When not using local dependencies, the branch to use for llbuild and TSC repositories.
let relatedDependenciesBranch = "main"
let relatedDependenciesBranch = "release/6.2"

if ProcessInfo.processInfo.environment["SWIFTPM_LLBUILD_FWK"] == nil {
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
Expand Down
47 changes: 47 additions & 0 deletions Sources/Basics/Graph/GraphAlgorithms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,50 @@ public func depthFirstSearch<T: Hashable>(
}
}
}

/// Implements a pre-order depth-first search that traverses the whole graph and
/// doesn't distinguish between unique and duplicate nodes. The visitor can abort
/// a path as needed to prune the tree.
/// The method expects the graph to be acyclic but doesn't check that.
///
/// - Parameters:
/// - nodes: The list of input nodes to sort.
/// - successors: A closure for fetching the successors of a particular node.
/// - onNext: A callback to indicate the node currently being processed
/// including its parent (if any) and its depth. Returns whether to
/// continue down the current path.
///
/// - Complexity: O(v + e) where (v, e) are the number of vertices and edges
/// reachable from the input nodes via the relation.
public enum DepthFirstContinue {
case `continue`
case abort
}

public func depthFirstSearch<T: Hashable>(
_ nodes: [T],
successors: (T) throws -> [T],
visitNext: (T, _ parent: T?) throws -> DepthFirstContinue
) rethrows {
var stack = OrderedSet<TraversalNode<T>>()

for node in nodes {
precondition(stack.isEmpty)
stack.append(TraversalNode(parent: nil, curr: node))

while !stack.isEmpty {
let node = stack.removeLast()

if try visitNext(node.curr, node.parent) == .continue {
for succ in try successors(node.curr) {
stack.append(
TraversalNode(
parent: node.curr,
curr: succ
)
)
}
}
}
}
}
22 changes: 22 additions & 0 deletions Sources/Build/BuildDescription/ModuleBuildDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,30 @@ extension ModuleBuildDescription {
var dependencies: [Dependency] = []
plan.traverseDependencies(of: self) { product, _, description in
dependencies.append(.product(product, description))
return .continue
} onModule: { module, _, description in
dependencies.append(.module(module, description))
return .continue
}
return dependencies
}

package func recursiveLinkDependencies(using plan: BuildPlan) -> [Dependency] {
var dependencies: [Dependency] = []
plan.traverseDependencies(of: self) { product, _, description in
guard product.type != .macro && product.type != .plugin else {
return .abort
}

dependencies.append(.product(product, description))
return .continue
} onModule: { module, _, description in
guard module.type != .macro && module.type != .plugin else {
return .abort
}

dependencies.append(.module(module, description))
return .continue
}
return dependencies
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/Build/BuildPlan/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,8 @@ extension BuildPlan {

package func traverseDependencies(
of description: ModuleBuildDescription,
onProduct: (ResolvedProduct, BuildParameters.Destination, ProductBuildDescription?) -> Void,
onModule: (ResolvedModule, BuildParameters.Destination, ModuleBuildDescription?) -> Void
onProduct: (ResolvedProduct, BuildParameters.Destination, ProductBuildDescription?) -> DepthFirstContinue,
onModule: (ResolvedModule, BuildParameters.Destination, ModuleBuildDescription?) -> DepthFirstContinue
) {
var visited = Set<TraversalNode>()
func successors(
Expand Down Expand Up @@ -1217,16 +1217,16 @@ extension BuildPlan {
case .package:
[]
}
} onNext: { module, _ in
} visitNext: { module, _ in
switch module {
case .package:
break
return .continue

case .product(let product, let destination):
onProduct(product, destination, self.description(for: product, context: destination))
return onProduct(product, destination, self.description(for: product, context: destination))

case .module(let module, let destination):
onModule(module, destination, self.description(for: module, context: destination))
return onModule(module, destination, self.description(for: module, context: destination))
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions Sources/_InternalTestSupport/XCTAssertHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ public func XCTRequires(
}
}

public func XCTSkipIfWindowsCI(file: StaticString = #filePath, line: UInt = #line) throws {
#if os(Windows)
if ProcessInfo.processInfo.environment["SWIFTCI_IS_SELF_HOSTED"] != nil {
throw XCTSkip("Skipping because the test is being run on CI", file: file, line: line)
}
#endif
}

/// An `async`-friendly replacement for `XCTAssertThrowsError`.
public func XCTAssertAsyncThrowsError<T>(
_ expression: @autoclosure () async throws -> T,
Expand Down
2 changes: 2 additions & 0 deletions Tests/BuildTests/BuildPlanTraversalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ final class BuildPlanTraversalTests: XCTestCase {
XCTAssertEqual(product.name, "SwiftSyntax")
XCTAssertEqual(destination, .host)
XCTAssertNil(description)
return .continue
} onModule: { module, destination, description in
moduleDependencies.append((module, destination, description))
return .continue
}

XCTAssertEqual(moduleDependencies.count, 2)
Expand Down
1 change: 1 addition & 0 deletions Utilities/build-using-self
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def filterNone(items: t.Iterable) -> t.Iterable:

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