Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/GeneratorCLI/GeneratorCLI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,12 @@ extension GeneratorCLI {
)
var freeBSDVersion: String

func deriveTargetTriple(hostTriples: [Triple]) throws -> Triple {
func deriveTargetTriple(hostTriples: [Triple], freebsdVersion: String) throws -> Triple {
if let target = generatorOptions.target, target.os == .freeBSD {
return target
}
if let arch = generatorOptions.targetArch {
let target = Triple(arch: arch, vendor: nil, os: .freeBSD)
let target = Triple(arch: arch, vendor: nil, os: .freeBSD, version: freebsdVersion)
appLogger.warning(
"""
Using `--target-arch \(arch)` defaults to `\(target.triple)`. \
Expand All @@ -375,7 +375,7 @@ extension GeneratorCLI {
}

let hostTriples = try self.generatorOptions.deriveHostTriples()
let targetTriple = try self.deriveTargetTriple(hostTriples: hostTriples)
let targetTriple = try self.deriveTargetTriple(hostTriples: hostTriples, freebsdVersion: self.freeBSDVersion)

let sourceSwiftToolchain: FilePath?
if let fromSwiftToolchain {
Expand Down
7 changes: 7 additions & 0 deletions Sources/SwiftSDKGenerator/PlatformModels/Triple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ extension Triple: @unchecked Sendable {}

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

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

public init(arch: Arch, vendor: Vendor?, os: OS, version: String) {
let os = os.rawValue
self.init("\(arch)-\(vendor?.rawValue ?? "unknown")-\(os)\(version)", normalizing: true)
}
}

extension Triple.Arch {
Expand Down