Skip to content

Commit c93aa44

Browse files
committed
Use renamed async versions of the new methods
1 parent 8bac989 commit c93aa44

File tree

23 files changed

+592
-124
lines changed

23 files changed

+592
-124
lines changed

Examples/package-info/Sources/package-info/example.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct Example {
2020

2121
let observability = ObservabilitySystem({ print("\($0): \($1)") })
2222

23-
let workspace = try await Workspace(forRootPackage: packagePath)
23+
let workspace = try await Workspace.create(forRootPackage: packagePath)
2424

2525
let manifest = try await workspace.loadRootManifest(at: packagePath, observabilityScope: observability.topScope)
2626

Sources/Commands/PackageCommands/APIDiff.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ struct APIDiff: AsyncSwiftCommand {
284284
try workingCopy.checkout(revision: baselineRevision)
285285

286286
// Create the workspace for this package.
287-
let workspace = try await Workspace(
287+
let workspace = try await Workspace.create(
288288
forRootPackage: baselinePackageRoot,
289289
cancellator: swiftCommandState.cancellator
290290
)

Sources/Commands/Utilities/APIDigester.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ struct APIDigesterBaselineDumper {
114114
try workingCopy.checkout(revision: baselineRevision)
115115

116116
// Create the workspace for this package.
117-
let workspace = try await Workspace(
117+
let workspace = try await Workspace.create(
118118
forRootPackage: baselinePackageRoot,
119119
cancellator: swiftCommandState.cancellator
120120
)

Sources/CoreCommands/SwiftCommandState.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ public final class SwiftCommandState {
491491
self.observabilityHandler.progress,
492492
self.observabilityHandler.prompt
493493
)
494-
let workspace = try await Workspace(
494+
let workspace = try await Workspace.create(
495495
fileSystem: self.fileSystem,
496496
location: .init(
497497
scratchDirectory: self.scratchDirectory,
@@ -831,7 +831,7 @@ public final class SwiftCommandState {
831831
outputHandler: { print($0.description) }
832832
)
833833

834-
swiftSDK = try await SwiftSDK.deriveTargetSwiftSDK(
834+
swiftSDK = try await SwiftSDK.deriveTargetSwiftSDKAsync(
835835
hostSwiftSDK: hostSwiftSDK,
836836
hostTriple: hostToolchain.targetTriple,
837837
customToolsets: self.options.locations.toolsetPaths,
@@ -851,17 +851,17 @@ public final class SwiftCommandState {
851851
return hostToolchain
852852
}
853853

854-
return try await UserToolchain(swiftSDK: swiftSDK, environment: self.environment, fileSystem: self.fileSystem)
854+
return try await UserToolchain.create(swiftSDK: swiftSDK, environment: self.environment, fileSystem: self.fileSystem)
855855
}
856856

857857
public func getHostToolchain() async throws -> UserToolchain {
858-
var hostSwiftSDK = try await SwiftSDK.hostSwiftSDK(
858+
var hostSwiftSDK = try await SwiftSDK.hostSwiftSDKAsync(
859859
environment: self.environment,
860860
observabilityScope: self.observabilityScope
861861
)
862862
hostSwiftSDK.targetTriple = self.hostTriple
863863

864-
return try await UserToolchain(
864+
return try await UserToolchain.create(
865865
swiftSDK: hostSwiftSDK,
866866
environment: self.environment,
867867
customTargetInfo: targetInfo,

Sources/PackageModel/SwiftSDKs/SwiftSDK.swift

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import TSCBasic
1616

1717
import class Basics.AsyncProcess
1818

19+
1920
import struct TSCUtility.Version
2021

2122
/// Errors related to Swift SDKs.
@@ -520,17 +521,16 @@ public struct SwiftSDK: Equatable {
520521
}
521522

522523
/// The Swift SDK describing the host platform.
523-
@available(*, deprecated, renamed: "hostSwiftSDK")
524+
@available(*, deprecated, renamed: "hostSwiftSDKAsync")
524525
public static func hostDestination(
525526
_ binDir: Basics.AbsolutePath? = nil,
526527
originalWorkingDirectory: Basics.AbsolutePath? = nil,
527528
environment: Environment
528529
) async throws -> SwiftSDK {
529-
try await self.hostSwiftSDK(binDir, environment: environment)
530+
try await self.hostSwiftSDKAsync(binDir, environment: environment)
530531
}
531532

532-
/// The Swift SDK for the host platform.
533-
@available(*, deprecated, message: "Use the async alternative")
533+
/// The Swift SDK for the host platform (synchronous version).
534534
public static func hostSwiftSDK(
535535
_ binDir: Basics.AbsolutePath? = nil,
536536
environment: Environment = .current,
@@ -545,8 +545,8 @@ public struct SwiftSDK: Equatable {
545545
)
546546
}
547547

548-
/// The Swift SDK for the host platform.
549-
public static func hostSwiftSDK(
548+
/// The Swift SDK for the host platform (asynchronous version).
549+
public static func hostSwiftSDKAsync(
550550
_ binDir: Basics.AbsolutePath? = nil,
551551
environment: Environment = .current,
552552
observabilityScope: ObservabilityScope? = nil,
@@ -624,7 +624,7 @@ public struct SwiftSDK: Equatable {
624624
)
625625
}
626626

627-
/// Helper to get the SDK path for a Darwin platform (async version).
627+
/// Helper to get the SDK path for a Darwin platform (sync version).
628628
private static func getSDKPath(
629629
for darwinPlatform: DarwinPlatform,
630630
environment: Environment
@@ -847,7 +847,7 @@ public struct SwiftSDK: Equatable {
847847
return nil
848848
}
849849

850-
/// Computes the target Swift SDK for the given options.
850+
/// Computes the target Swift SDK for the given options (synchronous version).
851851
public static func deriveTargetSwiftSDK(
852852
hostSwiftSDK: SwiftSDK,
853853
hostTriple: Triple,
@@ -861,6 +861,51 @@ public struct SwiftSDK: Equatable {
861861
store: SwiftSDKBundleStore,
862862
observabilityScope: ObservabilityScope,
863863
fileSystem: FileSystem
864+
) throws -> SwiftSDK {
865+
let semaphore = DispatchSemaphore(value: 0)
866+
var result: Result<SwiftSDK, Error>!
867+
868+
Task {
869+
do {
870+
let sdk = try await deriveTargetSwiftSDKAsync(
871+
hostSwiftSDK: hostSwiftSDK,
872+
hostTriple: hostTriple,
873+
customToolsets: customToolsets,
874+
customCompileDestination: customCompileDestination,
875+
customCompileTriple: customCompileTriple,
876+
customCompileToolchain: customCompileToolchain,
877+
customCompileSDK: customCompileSDK,
878+
swiftSDKSelector: swiftSDKSelector,
879+
architectures: architectures,
880+
store: store,
881+
observabilityScope: observabilityScope,
882+
fileSystem: fileSystem
883+
)
884+
result = .success(sdk)
885+
} catch {
886+
result = .failure(error)
887+
}
888+
semaphore.signal()
889+
}
890+
891+
semaphore.wait()
892+
return try result.get()
893+
}
894+
895+
/// Computes the target Swift SDK for the given options (async version).
896+
public static func deriveTargetSwiftSDKAsync(
897+
hostSwiftSDK: SwiftSDK,
898+
hostTriple: Triple,
899+
customToolsets: [Basics.AbsolutePath] = [],
900+
customCompileDestination: Basics.AbsolutePath? = nil,
901+
customCompileTriple: Triple? = nil,
902+
customCompileToolchain: Basics.AbsolutePath? = nil,
903+
customCompileSDK: Basics.AbsolutePath? = nil,
904+
swiftSDKSelector: String? = nil,
905+
architectures: [String] = [],
906+
store: SwiftSDKBundleStore,
907+
observabilityScope: ObservabilityScope,
908+
fileSystem: FileSystem
864909
) async throws -> SwiftSDK {
865910
var swiftSDK: SwiftSDK
866911
var isBasedOnHostSDK: Bool = false

0 commit comments

Comments
 (0)