Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion Sources/CoreCommands/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,9 @@ public struct BuildOptions: ParsableArguments {
}

/// The compilation destination’s target triple.
@Option(name: .customLong("triple"), transform: Triple.init)
@Option(name: .customLong("triple"),
help: "Filter for selecting the target triple from a Swift SDK bundle to build with.",
transform: Triple.init)
public var customCompileTriple: Triple?

/// Path to the compilation destination’s SDK.
Expand Down
12 changes: 9 additions & 3 deletions Sources/PackageModel/SwiftSDKs/SwiftSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,16 @@ public struct SwiftSDK: Equatable {
let targetSwiftSDK = SwiftSDK.defaultSwiftSDK(for: targetTriple, hostSDK: hostSwiftSDK)
{
swiftSDK = targetSwiftSDK
} else if let swiftSDKSelector {
} else if swiftSDKSelector != nil || customCompileTriple != nil {
do {
var ID: String
(ID, swiftSDK) = try store.selectBundle(matching: swiftSDKSelector, hostTriple: hostTriple, targetTriple: customCompileTriple)
if let swiftSDKSelector {
(ID, swiftSDK) = try store.selectBundle(matching: swiftSDKSelector, hostTriple: hostTriple, targetTriple: customCompileTriple)
} else if let customCompileTriple {
(ID, swiftSDK) = try store.selectBundle(matching: customCompileTriple.tripleString, hostTriple: hostTriple)
} else {
fatalError("Neither an SDK nor a triple matched somehow.")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should never hit, but just putting it in as a guard rail.

}

// Override with user's manual config
do {
Expand All @@ -806,7 +812,7 @@ public struct SwiftSDK: Equatable {
} catch {
// If a user-installed bundle for the selector doesn't exist, check if the
// selector is recognized as a default SDK.
if let targetTriple = try? Triple(swiftSDKSelector),
if let targetTriple = try? customCompileTriple ?? Triple(swiftSDKSelector!),
let defaultSDK = SwiftSDK.defaultSwiftSDK(for: targetTriple, hostSDK: hostSwiftSDK) {
swiftSDK = defaultSDK
} else {
Expand Down
Loading