File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -838,6 +838,9 @@ public class SwiftTool {
838
838
// Create custom toolchain if present.
839
839
if let customDestination = self . options. customCompileDestination {
840
840
destination = try Destination ( fromFile: customDestination)
841
+ } else if let target = self . options. customCompileTriple,
842
+ let targetDestination = Destination . defaultDestination ( for: target, host: hostDestination) {
843
+ destination = targetDestination
841
844
} else {
842
845
// Otherwise use the host toolchain.
843
846
destination = hostDestination
@@ -854,18 +857,6 @@ public class SwiftTool {
854
857
}
855
858
if let sdk = self . options. customCompileSDK {
856
859
destination. sdk = sdk
857
- } else if let target = destination. target, target. isWASI ( ) {
858
- // Set default SDK path when target is WASI whose SDK is embeded
859
- // in Swift toolchain
860
- do {
861
- let compilers = try UserToolchain . determineSwiftCompilers ( binDir: destination. binDir)
862
- destination. sdk = compilers. compile
863
- . parentDirectory // bin
864
- . parentDirectory // usr
865
- . appending ( components: " share " , " wasi-sysroot " )
866
- } catch {
867
- return . failure( error)
868
- }
869
860
}
870
861
destination. archs = options. archs
871
862
Original file line number Diff line number Diff line change @@ -178,6 +178,24 @@ public struct Destination: Encodable, Equatable {
178
178
}
179
179
/// Cache storage for sdk platform path.
180
180
private static var _sdkPlatformFrameworkPath : ( fwk: AbsolutePath , lib: AbsolutePath ) ? = nil
181
+
182
+ /// Returns a default destination of a given target environment
183
+ public static func defaultDestination( for triple: Triple , host: Destination ) -> Destination ? {
184
+ if triple. isWASI ( ) {
185
+ let wasiSysroot = host. binDir
186
+ . parentDirectory // usr
187
+ . appending ( components: " share " , " wasi-sysroot " )
188
+ return Destination (
189
+ target: triple,
190
+ sdk: wasiSysroot,
191
+ binDir: host. binDir,
192
+ extraCCFlags: [ ] ,
193
+ extraSwiftCFlags: [ ] ,
194
+ extraCPPFlags: [ ]
195
+ )
196
+ }
197
+ return nil
198
+ }
181
199
}
182
200
183
201
extension Destination {
You can’t perform that action at this time.
0 commit comments