Skip to content

Commit a475c4e

Browse files
authored
Revert "Avoid using temp_await on loadRootPackage (#7009)"
This reverts commit 6bed023.
1 parent 81526cf commit a475c4e

File tree

10 files changed

+108
-110
lines changed

10 files changed

+108
-110
lines changed

.swiftpm/xcode/xcshareddata/xcschemes/SwiftPM-Package.xcscheme

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -839,16 +839,6 @@
839839
ReferencedContainer = "container:">
840840
</BuildableReference>
841841
</TestableReference>
842-
<TestableReference
843-
skipped = "NO">
844-
<BuildableReference
845-
BuildableIdentifier = "primary"
846-
BlueprintIdentifier = "SourceKitLSPAPITests"
847-
BuildableName = "SourceKitLSPAPITests"
848-
BlueprintName = "SourceKitLSPAPITests"
849-
ReferencedContainer = "container:">
850-
</BuildableReference>
851-
</TestableReference>
852842
</Testables>
853843
</TestAction>
854844
<LaunchAction

Sources/Commands/PackageTools/Describe.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import PackageModel
1919
import struct TSCBasic.StringError
2020

2121
extension SwiftPackageTool {
22-
struct Describe: AsyncSwiftCommand {
22+
struct Describe: SwiftCommand {
2323
static let configuration = CommandConfiguration(
2424
abstract: "Describe the current package")
2525

@@ -29,18 +29,21 @@ extension SwiftPackageTool {
2929
@Option(help: "json | text")
3030
var type: DescribeMode = .text
3131

32-
func run(_ swiftTool: SwiftTool) async throws {
32+
func run(_ swiftTool: SwiftTool) throws {
3333
let workspace = try swiftTool.getActiveWorkspace()
3434

3535
guard let packagePath = try swiftTool.getWorkspaceRoot().packages.first else {
3636
throw StringError("unknown package")
3737
}
3838

39-
let package = try await workspace.loadRootPackage(
40-
at: packagePath,
41-
observabilityScope: swiftTool.observabilityScope
42-
)
43-
39+
let package = try temp_await {
40+
workspace.loadRootPackage(
41+
at: packagePath,
42+
observabilityScope: swiftTool.observabilityScope,
43+
completion: $0
44+
)
45+
}
46+
4447
try self.describe(package, in: type)
4548
}
4649

Sources/Commands/PackageTools/DumpCommands.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,24 @@ enum ExtensionBlockSymbolBehavior: String, EnumerableFlag {
9797
case omitExtensionBlockSymbols
9898
}
9999

100-
struct DumpPackage: AsyncSwiftCommand {
100+
struct DumpPackage: SwiftCommand {
101101
static let configuration = CommandConfiguration(
102102
abstract: "Print parsed Package.swift as JSON")
103103

104104
@OptionGroup(visibility: .hidden)
105105
var globalOptions: GlobalOptions
106106

107-
func run(_ swiftTool: SwiftTool) async throws {
107+
func run(_ swiftTool: SwiftTool) throws {
108108
let workspace = try swiftTool.getActiveWorkspace()
109109
let root = try swiftTool.getWorkspaceRoot()
110110

111-
let rootManifests = try await workspace.loadRootManifests(
112-
packages: root.packages,
113-
observabilityScope: swiftTool.observabilityScope
114-
)
111+
let rootManifests = try temp_await {
112+
workspace.loadRootManifests(
113+
packages: root.packages,
114+
observabilityScope: swiftTool.observabilityScope,
115+
completion: $0
116+
)
117+
}
115118
guard let rootManifest = rootManifests.values.first else {
116119
throw StringError("invalid manifests at \(root.packages)")
117120
}

Sources/Commands/PackageTools/Format.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import enum TSCBasic.ProcessEnv
2121
import enum TSCUtility.Diagnostics
2222

2323
extension SwiftPackageTool {
24-
struct Format: AsyncSwiftCommand {
24+
struct Format: SwiftCommand {
2525
static let configuration = CommandConfiguration(
2626
commandName: "_format", shouldDisplay: false)
2727

@@ -32,7 +32,7 @@ extension SwiftPackageTool {
3232
help: "Pass flag through to the swift-format tool")
3333
var swiftFormatFlags: [String] = []
3434

35-
func run(_ swiftTool: SwiftTool) async throws {
35+
func run(_ swiftTool: SwiftTool) throws {
3636
// Look for swift-format binary.
3737
// FIXME: This should be moved to user toolchain.
3838
let swiftFormatInEnv = lookupExecutablePath(filename: ProcessEnv.vars["SWIFT_FORMAT"])
@@ -48,11 +48,13 @@ extension SwiftPackageTool {
4848
throw StringError("unknown package")
4949
}
5050

51-
let package = try await workspace.loadRootPackage(
52-
at: packagePath,
53-
observabilityScope: swiftTool.observabilityScope
54-
)
55-
51+
let package = try temp_await {
52+
workspace.loadRootPackage(
53+
at: packagePath,
54+
observabilityScope: swiftTool.observabilityScope,
55+
completion: $0
56+
)
57+
}
5658

5759
// Use the user provided flags or default to formatting mode.
5860
let formatOptions = swiftFormatFlags.isEmpty
@@ -69,7 +71,7 @@ extension SwiftPackageTool {
6971
let args = [swiftFormat.pathString] + formatOptions + [packagePath.pathString] + paths
7072
print("Running:", args.map{ $0.spm_shellEscaped() }.joined(separator: " "))
7173

72-
let result = try await TSCBasic.Process.popen(arguments: args)
74+
let result = try TSCBasic.Process.popen(arguments: args)
7375
let output = try (result.utf8Output() + result.utf8stderrOutput())
7476

7577
if result.exitStatus != .terminated(code: 0) {

Sources/Commands/PackageTools/SwiftPackageTool.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import XCBuildSupport
2525
import enum TSCUtility.Diagnostics
2626

2727
/// swift-package tool namespace
28-
public struct SwiftPackageTool: AsyncParsableCommand {
28+
public struct SwiftPackageTool: ParsableCommand {
2929
public static var configuration = CommandConfiguration(
3030
commandName: "package",
3131
_superCommandName: "swift",

Sources/SPMTestSupport/MockWorkspace.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -510,16 +510,13 @@ public final class MockWorkspace {
510510
public let diagnostics: [Basics.Diagnostic]
511511
}
512512

513-
public func checkPrecomputeResolution() async throws -> ResolutionPrecomputationResult {
513+
public func checkPrecomputeResolution(_ check: (ResolutionPrecomputationResult) -> Void) throws {
514514
let observability = ObservabilitySystem.makeForTesting()
515515
let workspace = try self.getOrCreateWorkspace()
516516
let pinsStore = try workspace.pinsStore.load()
517517

518518
let rootInput = PackageGraphRootInput(packages: try rootPaths(for: roots.map { $0.name }), dependencies: [])
519-
let rootManifests = try await workspace.loadRootManifests(
520-
packages: rootInput.packages,
521-
observabilityScope: observability.topScope
522-
)
519+
let rootManifests = try temp_await { workspace.loadRootManifests(packages: rootInput.packages, observabilityScope: observability.topScope, completion: $0) }
523520
let root = PackageGraphRoot(input: rootInput, manifests: rootManifests, observabilityScope: observability.topScope)
524521

525522
let dependencyManifests = try workspace.loadDependencyManifests(root: root, observabilityScope: observability.topScope)
@@ -532,7 +529,7 @@ public final class MockWorkspace {
532529
observabilityScope: observability.topScope
533530
)
534531

535-
return ResolutionPrecomputationResult(result: result, diagnostics: observability.diagnostics)
532+
check(ResolutionPrecomputationResult(result: result, diagnostics: observability.diagnostics))
536533
}
537534

538535
public func set(

Sources/swift-package-manager/SwiftPM.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct SwiftPM {
2525
static func main() async {
2626
switch execName {
2727
case "swift-package":
28-
await SwiftPackageTool.main()
28+
SwiftPackageTool.main()
2929
case "swift-build":
3030
SwiftBuildTool.main()
3131
case "swift-experimental-sdk":

Sources/swift-package/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
add_executable(swift-package
10-
Entrypoint.swift)
10+
main.swift)
1111
target_link_libraries(swift-package PRIVATE
1212
Commands
1313
TSCBasic)
1414

15-
target_compile_options(swift-package PRIVATE
16-
-parse-as-library)
17-
1815
install(TARGETS swift-package
1916
RUNTIME DESTINATION bin)

Sources/swift-package/Entrypoint.swift renamed to Sources/swift-package/main.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,4 @@
1212

1313
import Commands
1414

15-
@main
16-
struct Entrypoint {
17-
static func main() async {
18-
await SwiftPackageTool.main()
19-
}
20-
}
15+
SwiftPackageTool.main()

0 commit comments

Comments
 (0)