Skip to content

Allow specifying toolsets for SwiftPM projects #2058

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
merged 1 commit into from
Mar 12, 2025
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
1 change: 1 addition & 0 deletions Documentation/Configuration File.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The structure of the file is currently not guaranteed to be stable. Options may
- `swiftSDKsDirectory: string`: Equivalent to SwiftPM's `--swift-sdks-path` option.
- `swiftSDK: string`: Equivalent to SwiftPM's `--swift-sdk` option.
- `triple: string`: Equivalent to SwiftPM's `--triple` option.
- `toolsets: string[]`: Equivalent to SwiftPM's `--toolset` option.
- `traits: string[]`: Traits to enable for the package. Equivalent to SwiftPM's `--traits` option.
- `cCompilerFlags: string[]`: Extra arguments passed to the compiler for C files. Equivalent to SwiftPM's `-Xcc` option.
- `cxxCompilerFlags: string[]`: Extra arguments passed to the compiler for C++ files. Equivalent to SwiftPM's `-Xcxx` option.
Expand Down
1 change: 1 addition & 0 deletions Sources/BuildSystemIntegration/SwiftPMBuildSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ package actor SwiftPMBuildSystem: BuiltInBuildSystem {
let destinationSDK = try SwiftSDK.deriveTargetSwiftSDK(
hostSwiftSDK: hostSDK,
hostTriple: hostSwiftPMToolchain.targetTriple,
customToolsets: options.swiftPMOrDefault.toolsets?.map { try AbsolutePath(validating: $0) } ?? [],
customCompileTriple: options.swiftPMOrDefault.triple.map { try Triple($0) },
swiftSDKSelector: options.swiftPMOrDefault.swiftSDK,
store: SwiftSDKBundleStore(
Expand Down
6 changes: 6 additions & 0 deletions Sources/SKOptions/SourceKitLSPOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
/// Equivalent to SwiftPM's `--triple` option.
public var triple: String?

/// Equivalent to SwiftPM's `--toolset` option.
public var toolsets: [String]?

/// Traits to enable for the package. Equivalent to SwiftPM's `--traits` option.
public var traits: [String]?

Expand Down Expand Up @@ -79,6 +82,7 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
swiftSDKsDirectory: String? = nil,
swiftSDK: String? = nil,
triple: String? = nil,
toolsets: [String]? = nil,
traits: [String]? = nil,
cCompilerFlags: [String]? = nil,
cxxCompilerFlags: [String]? = nil,
Expand All @@ -93,6 +97,7 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
self.swiftSDKsDirectory = swiftSDKsDirectory
self.swiftSDK = swiftSDK
self.triple = triple
self.toolsets = toolsets
self.traits = traits
self.cCompilerFlags = cCompilerFlags
self.cxxCompilerFlags = cxxCompilerFlags
Expand All @@ -109,6 +114,7 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
swiftSDKsDirectory: override?.swiftSDKsDirectory ?? base.swiftSDKsDirectory,
swiftSDK: override?.swiftSDK ?? base.swiftSDK,
triple: override?.triple ?? base.triple,
toolsets: override?.toolsets ?? base.toolsets,
traits: override?.traits ?? base.traits,
cCompilerFlags: override?.cCompilerFlags ?? base.cCompilerFlags,
cxxCompilerFlags: override?.cxxCompilerFlags ?? base.cxxCompilerFlags,
Expand Down
8 changes: 8 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@
"markdownDescription" : "Equivalent to SwiftPM's `--swift-sdks-path` option.",
"type" : "string"
},
"toolsets" : {
"description" : "Equivalent to SwiftPM's `--toolset` option.",
"items" : {
"type" : "string"
},
"markdownDescription" : "Equivalent to SwiftPM's `--toolset` option.",
"type" : "array"
},
"traits" : {
"description" : "Traits to enable for the package. Equivalent to SwiftPM's `--traits` option.",
"items" : {
Expand Down