Skip to content

Commit ff7fa0c

Browse files
Always use rawValue when using OS enum as string
Certain enum cases, such as `freeBSD`, contain capital letters. However, target triples must be entirely in lower case. The enum case's raw value reflects this, but our custom initializer for the Triple structure does not use it, resulting in an invalid target triple. This makes the generated SDK unusable if the user passed only the desired architecture instead of a complete triple. To address this problem, the initializer should always request the rawValue explicitly.
1 parent ab16fe7 commit ff7fa0c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Sources/SwiftSDKGenerator/PlatformModels/Triple.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ extension Triple: @unchecked Sendable {}
1818

1919
extension Triple {
2020
public init(arch: Arch, vendor: Vendor?, os: OS, environment: Environment) {
21+
let os = os.rawValue
2122
self.init("\(arch)-\(vendor?.rawValue ?? "unknown")-\(os)-\(environment)", normalizing: true)
2223
}
2324

2425
public init(arch: Arch, vendor: Vendor?, os: OS) {
26+
let os = os.rawValue
2527
self.init("\(arch)-\(vendor?.rawValue ?? "unknown")-\(os)", normalizing: true)
2628
}
2729
}

0 commit comments

Comments
 (0)