Skip to content

[SourceKitLSP] Start using SwiftPM independent BuildDestination typ… #7884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
16 changes: 9 additions & 7 deletions Sources/SourceKitLSPAPI/BuildDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import class Build.ClangModuleBuildDescription
import class Build.SwiftModuleBuildDescription
import struct PackageGraph.ResolvedModule
import struct PackageGraph.ModulesGraph
import enum PackageGraph.BuildTriple
internal import class PackageModel.UserToolchain

public typealias BuildTriple = PackageGraph.BuildTriple
public enum BuildDestination {
case host
case target
}

public protocol BuildTarget {
/// Source files in the target
Expand All @@ -38,7 +40,7 @@ public protocol BuildTarget {
/// The name of the target. It should be possible to build a target by passing this name to `swift build --target`
var name: String { get }

var buildTriple: BuildTriple { get }
var destination: BuildDestination { get }

/// Whether the target is part of the root package that the user opened or if it's part of a package dependency.
var isPartOfRootPackage: Bool { get }
Expand Down Expand Up @@ -70,8 +72,8 @@ private struct WrappedClangTargetBuildDescription: BuildTarget {
return description.clangTarget.name
}

public var buildTriple: BuildTriple {
return description.target.buildTriple
public var destination: BuildDestination {
return description.destination == .host ? .host : .target
}

public func compileArguments(for fileURL: URL) throws -> [String] {
Expand All @@ -95,8 +97,8 @@ private struct WrappedSwiftTargetBuildDescription: BuildTarget {
return description.target.name
}

public var buildTriple: BuildTriple {
return description.target.buildTriple
public var destination: BuildDestination {
return description.destination == .host ? .host : .target
}

var sources: [URL] {
Expand Down
6 changes: 3 additions & 3 deletions Sources/SourceKitLSPAPI/PluginTargetBuildDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import struct PackageGraph.ResolvedModule
private import class PackageLoading.ManifestLoader
internal import struct PackageModel.ToolsVersion
internal import protocol PackageModel.Toolchain
import enum PackageGraph.BuildTriple

struct PluginTargetBuildDescription: BuildTarget {
private let target: ResolvedModule
Expand All @@ -45,8 +44,9 @@ struct PluginTargetBuildDescription: BuildTarget {
return target.name
}

var buildTriple: BuildTriple {
return target.buildTriple
var destination: BuildDestination {
// Plugins are always built for the host.
.host
}

func compileArguments(for fileURL: URL) throws -> [String] {
Expand Down