Skip to content

Commit 12c58ec

Browse files
committed
On non-Darwin platforms, infer the default toolchain when there is only one
1 parent 718bcb5 commit 12c58ec

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Sources/SWBCore/ToolchainRegistry.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,16 @@ public final class ToolchainRegistry: @unchecked Sendable {
507507
/// Look up the toolchain with the given identifier.
508508
public func lookup(_ identifier: String) -> Toolchain? {
509509
let lowercasedIdentifier = identifier.lowercased()
510-
let identifier = ["default", "xcode"].contains(lowercasedIdentifier) ? ToolchainRegistry.defaultToolchainIdentifier : identifier
511-
return toolchainsByIdentifier[identifier] ?? toolchainsByAlias[lowercasedIdentifier]
510+
if ["default", "xcode"].contains(lowercasedIdentifier) {
511+
#if canImport(Darwin)
512+
return toolchainsByIdentifier[ToolchainRegistry.defaultToolchainIdentifier] ?? toolchainsByAlias[lowercasedIdentifier]
513+
#else
514+
// On non-Darwin, assume if there is only one registered toolchain, it is the default.
515+
return toolchainsByIdentifier[ToolchainRegistry.defaultToolchainIdentifier] ?? toolchainsByAlias[lowercasedIdentifier] ?? toolchainsByIdentifier.values.only
516+
#endif
517+
} else {
518+
return toolchainsByIdentifier[identifier] ?? toolchainsByAlias[lowercasedIdentifier]
519+
}
512520
}
513521

514522
public var defaultToolchain: Toolchain? {

0 commit comments

Comments
 (0)