Skip to content

Commit 1974b4e

Browse files
committed
Expose the build triple of a BuildTarget in SourceKitLSPAPI
1 parent 9183b7c commit 1974b4e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Sources/SourceKitLSPAPI/BuildDescription.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ import class Build.ClangTargetBuildDescription
2323
import class Build.SwiftTargetBuildDescription
2424
import struct PackageGraph.ResolvedModule
2525
import struct PackageGraph.ModulesGraph
26+
import enum PackageGraph.BuildTriple
2627

2728
public protocol BuildTarget {
2829
var sources: [URL] { get }
2930

3031
/// The name of the target. It should be possible to build a target by passing this name to `swift build --target`
3132
var name: String { get }
3233

34+
var buildTriple: BuildTriple { get }
35+
3336
/// Whether the target is part of the root package that the user opened or if it's part of a package dependency.
3437
var isPartOfRootPackage: Bool { get }
3538

@@ -53,6 +56,10 @@ private struct WrappedClangTargetBuildDescription: BuildTarget {
5356
return description.clangTarget.name
5457
}
5558

59+
public var buildTriple: BuildTriple {
60+
return description.target.buildTriple
61+
}
62+
5663
public func compileArguments(for fileURL: URL) throws -> [String] {
5764
let filePath = try resolveSymlinks(try AbsolutePath(validating: fileURL.path))
5865
let commandLine = try description.emitCommandLine(for: filePath)
@@ -74,6 +81,10 @@ private struct WrappedSwiftTargetBuildDescription: BuildTarget {
7481
return description.target.name
7582
}
7683

84+
public var buildTriple: BuildTriple {
85+
return description.target.buildTriple
86+
}
87+
7788
var sources: [URL] {
7889
return description.sources.map { URL(fileURLWithPath: $0.pathString) }
7990
}

Sources/SourceKitLSPAPI/PluginTargetBuildDescription.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import struct PackageGraph.ResolvedModule
1717
private import class PackageLoading.ManifestLoader
1818
internal import struct PackageModel.ToolsVersion
1919
private import class PackageModel.UserToolchain
20+
import enum PackageGraph.BuildTriple
2021

2122
struct PluginTargetBuildDescription: BuildTarget {
2223
private let target: ResolvedModule
@@ -38,6 +39,10 @@ struct PluginTargetBuildDescription: BuildTarget {
3839
return target.name
3940
}
4041

42+
var buildTriple: BuildTriple {
43+
return target.buildTriple
44+
}
45+
4146
func compileArguments(for fileURL: URL) throws -> [String] {
4247
// FIXME: This is very odd and we should clean this up by merging `ManifestLoader` and `DefaultPluginScriptRunner` again.
4348
let loader = ManifestLoader(toolchain: try UserToolchain(swiftSDK: .hostSwiftSDK()))

0 commit comments

Comments
 (0)