Skip to content

Commit 074e049

Browse files
committed
Allow "macos" when parsing triples
LLVM target triples support either "macosx" or "macos", so our parsing code should also support both spellings.
1 parent d67baa2 commit 074e049

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Sources/TSCUtility/Triple.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ public struct Triple: Encodable, Equatable {
108108
return candidate
109109
}
110110

111+
// LLVM target triples support this alternate spelling as well.
112+
if string.hasPrefix("macos") {
113+
return .macOS
114+
}
115+
111116
return nil
112117
}
113118

Tests/TSCUtilityTests/TripleTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class TripleTests : XCTestCase {
2424
let newVersion = "10.12"
2525
let tripleString = macos!.tripleString(forPlatformVersion: newVersion)
2626
XCTAssertEqual(tripleString, "x86_64-apple-macosx10.12")
27+
let macosNoX = try? Triple("x86_64-apple-macos12.2")
28+
XCTAssertNotNil(macosNoX!)
29+
XCTAssertEqual(macosNoX!.os, .macOS)
30+
XCTAssertEqual(macosNoX!.osVersion, "12.2")
2731

2832
let android = try? Triple("aarch64-unknown-linux-android24")
2933
XCTAssertNotNil(android)

0 commit comments

Comments
 (0)