Skip to content

Commit 2cd9d77

Browse files
committed
Fix two small issues with handling of plugin triples
- We were not stringently using version-less triples in all comparisons - We were not merging the supported triples of all executable info entries into the final `toolNamesToTriples` which could lead to incorrect errors about unsupported platforms rdar://101096803
1 parent a89e99b commit 2cd9d77

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Sources/SPMBuildCore/BinaryTarget+Extensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ extension BinaryTarget {
7474
// Filter supported triples with versionLessTriple and pass into
7575
// ExecutableInfo; empty if non matching triples found.
7676
try entry.value.variants.map{
77-
ExecutableInfo(name: entry.key, executablePath: try AbsolutePath(validating: $0.path, relativeTo: self.artifactPath), supportedTriples: $0.supportedTriples.filter({$0 == versionLessTriple}))
77+
return ExecutableInfo(name: entry.key, executablePath: try AbsolutePath(validating: $0.path, relativeTo: self.artifactPath), supportedTriples: try $0.supportedTriples.filter({try $0.withoutVersion() == versionLessTriple}))
7878
}
7979
}
8080
}
8181
}
8282

83-
fileprivate extension Triple {
83+
extension Triple {
8484
func withoutVersion() throws -> Triple {
8585
if isDarwin() {
8686
let stringWithoutVersion = tripleString(forPlatformVersion: "")

Sources/SPMBuildCore/PluginInvocation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ extension PackageGraph {
373373
let toolNamesToTriples = accessibleTools.reduce(into: [String: [String]](), { dict, tool in
374374
switch tool {
375375
case .vendedTool(let name, _, let triple):
376-
dict[name] = triple
376+
dict[name, default: []].append(contentsOf: triple)
377377
default: break
378378
}
379379
})
@@ -533,7 +533,7 @@ public extension PluginTarget {
533533
if let target = executableOrBinaryTarget as? BinaryTarget {
534534
// TODO: Memoize this result for the host triple
535535
let execInfos = try target.parseArtifactArchives(for: hostTriple, fileSystem: fileSystem)
536-
return execInfos.map{ .vendedTool(name: $0.name, path: $0.executablePath, supportedTriples: $0.supportedTriples.map{$0.tripleString}) }
536+
return try execInfos.map{ .vendedTool(name: $0.name, path: $0.executablePath, supportedTriples: try $0.supportedTriples.map{ try $0.withoutVersion().tripleString }) }
537537
}
538538
// For an executable target we create a `builtTool`.
539539
else if executableOrBinaryTarget.type == .executable {

0 commit comments

Comments
 (0)