Skip to content

Commit 1f57193

Browse files
author
Richard Howell
committed
add toolchain interface to BuildServer
1 parent f6045fc commit 1f57193

File tree

8 files changed

+18
-4
lines changed

8 files changed

+18
-4
lines changed

Sources/SKCore/BuildSystem.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ public protocol BuildSystem {
3232
/// Returns the settings for the given url and language mode, if known.
3333
func settings(for: URL, _ language: Language) -> FileBuildSettings?
3434

35+
/// Returns the toolchain to use to compile this file
36+
func toolchain(for: URL, _ language: Language) -> Toolchain?
37+
3538
// TODO: notifications when settings change.
3639
}

Sources/SKCore/BuildSystemList.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ extension BuildSystemList: BuildSystem {
3838
}
3939
return nil
4040
}
41+
42+
public func toolchain(for url: URL, _ language: Language) -> Toolchain? {
43+
return providers.first?.toolchain(for: url, language)
44+
}
4145
}

Sources/SKCore/CompilationDatabaseBuildSystem.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ extension CompilationDatabaseBuildSystem: BuildSystem {
4848
)
4949
}
5050

51+
public func toolchain(for: URL, _ language: Language) -> Toolchain? { return nil }
52+
5153
func database(for url: URL) -> CompilationDatabase? {
5254
if let path = try? AbsolutePath(validating: url.path) {
5355
return database(for: path)

Sources/SKCore/FallbackBuildSystem.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public final class FallbackBuildSystem: BuildSystem {
5050
}
5151
}
5252

53+
public func toolchain(for: URL, _ language: Language) -> Toolchain? { return nil }
54+
5355
func settingsSwift(_ path: AbsolutePath) -> FileBuildSettings {
5456
var args: [String] = []
5557
if let sdkpath = sdkpath {

Sources/SKSupport/Logging.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public final class Logger {
107107
}
108108

109109
public func setLogLevel(environmentVariable: String) {
110-
if let string = Process.env[environmentVariable],
110+
if let string = ProcessEnv.vars[environmentVariable],
111111
let level = try? LogLevel(argument: string)
112112
{
113113
currentLevel = level

Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ extension SwiftPMWorkspace: BuildSystem {
214214
return nil
215215
}
216216

217+
public func toolchain(for: LanguageServerProtocol.URL, _ language: Language) -> SKCore.Toolchain? {
218+
return nil
219+
220+
}
221+
217222
/// Returns the resolved target description for the given file, if one is known.
218223
func targetDescription(for file: AbsolutePath) -> TargetBuildDescription? {
219224
if let td = fileToTarget[file] {

Sources/SourceKit/SourceKitServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public final class SourceKitServer: LanguageServer {
134134
}
135135

136136
func toolchain(for url: URL, _ language: Language) -> Toolchain? {
137-
if let toolchain = workspace?.buildSettings.settings(for: url, language)?.preferredToolchain {
137+
if let toolchain = workspace?.buildSettings.toolchain(for: url, language) {
138138
return toolchain
139139
}
140140

Tests/SKCoreTests/FallbackBuildSystemTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ final class FallbackBuildSystemTests: XCTestCase {
2828
XCTAssertNil(bs.indexDatabasePath)
2929

3030
let settings = bs.settings(for: source.asURL, .swift)!
31-
XCTAssertNil(settings.preferredToolchain)
3231
XCTAssertNil(settings.workingDirectory)
3332

3433
let args = settings.compilerArguments
@@ -53,7 +52,6 @@ final class FallbackBuildSystemTests: XCTestCase {
5352
bs.sdkpath = sdk
5453

5554
let settings = bs.settings(for: source.asURL, .cpp)!
56-
XCTAssertNil(settings.preferredToolchain)
5755
XCTAssertNil(settings.workingDirectory)
5856

5957
let args = settings.compilerArguments

0 commit comments

Comments
 (0)