@@ -16,6 +16,7 @@ import TSCBasic
1616
1717import class Basics. AsyncProcess
1818
19+
1920import 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