@@ -233,35 +233,22 @@ public struct SDKPrebuiltModuleInputsCollector {
233
233
234
234
// Returns a target triple that's proper to use with the given SDK path.
235
235
public var targetTriple : String {
236
- let canonicalName = sdkInfo. canonicalName
237
- func extractVersion( _ platform: String ) -> Substring ? {
238
- if canonicalName. starts ( with: platform) {
239
- let versionStartIndex = canonicalName. index ( canonicalName. startIndex,
240
- offsetBy: platform. count)
241
- let delimiterRange = canonicalName. range ( of: " internal " , options: . backwards)
242
- let versionEndIndex = delimiterRange == nil ? canonicalName. endIndex : delimiterRange!. lowerBound
243
- return canonicalName [ versionStartIndex..< versionEndIndex]
244
- }
245
- return nil
246
- }
247
-
248
- if let version = extractVersion ( " macosx " ) {
236
+ let version = sdkInfo. versionString
237
+ switch sdkInfo. platformKind {
238
+ case . macosx:
249
239
return " arm64-apple-macosx \( version) "
250
- } else if let version = extractVersion ( " iphoneos " ) {
240
+ case . iphoneos:
251
241
return " arm64-apple-ios \( version) "
252
- } else if let version = extractVersion ( " iphonesimulator " ) {
242
+ case . iphonesimulator:
253
243
return " arm64-apple-ios \( version) -simulator "
254
- } else if let version = extractVersion ( " watchos " ) {
244
+ case . watchos:
255
245
return " armv7k-apple-watchos \( version) "
256
- } else if let version = extractVersion ( " watchsimulator " ) {
246
+ case . watchsimulator:
257
247
return " arm64-apple-watchos \( version) -simulator "
258
- } else if let version = extractVersion ( " appletvos " ) {
248
+ case . appletvos:
259
249
return " arm64-apple-tvos \( version) "
260
- } else if let version = extractVersion ( " appletvsimulator " ) {
250
+ case . appletvsimulator:
261
251
return " arm64-apple-tvos \( version) -simulator "
262
- } else {
263
- diagEngine. emit ( error: " unhandled platform name: \( canonicalName) " )
264
- return " "
265
252
}
266
253
}
267
254
0 commit comments