File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public struct Triple: Encodable, Equatable {
36
36
case unknownOS( os: String )
37
37
}
38
38
39
- public enum Arch : String , Encodable {
39
+ public enum Arch : String , Encodable , CaseIterable {
40
40
case x86_64
41
41
case x86_64h
42
42
case i686
@@ -135,6 +135,11 @@ public struct Triple: Encodable, Equatable {
135
135
self . abiVersion = abiVersion
136
136
}
137
137
138
+ fileprivate static func parseArch( _ string: String ) -> Arch ? {
139
+ var candidates = Arch . allCases. map { ( name: $0. rawValue, value: $0) }
140
+ return candidates. first ( where: { string. hasPrefix ( $0. name) } ) ? . value
141
+ }
142
+
138
143
fileprivate static func parseOS( _ string: String ) -> OS ? {
139
144
var candidates = OS . allCases. map { ( name: $0. rawValue, value: $0) }
140
145
// LLVM target triples support this alternate spelling as well.
@@ -201,6 +206,7 @@ public struct Triple: Encodable, Equatable {
201
206
fatalError ( " Failed to get target info ( \( error) ) " )
202
207
#endif
203
208
}
209
+
204
210
// Parse the compiler's JSON output.
205
211
let parsedTargetInfo : JSON
206
212
do {
Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ class TripleTests : XCTestCase {
40
40
let linuxWithABIVersion = try ? Triple ( " x86_64-unknown-linux-gnu42 " )
41
41
XCTAssertEqual ( linuxWithABIVersion!. abi, . other( name: " gnu " ) )
42
42
XCTAssertEqual ( linuxWithABIVersion!. abiVersion, " 42 " )
43
+
44
+ let androidArm = try ? Triple ( " armv7a-unknown-linux-androideabi " )
45
+ XCTAssertEqual ( androidArm!. arch, . armv7)
43
46
}
44
47
45
48
func testEquality( ) throws {
You can’t perform that action at this time.
0 commit comments