@@ -142,8 +142,7 @@ private enum BuildSystemAdapter {
142
142
}
143
143
144
144
private extension BuildSystemSpec {
145
- private static func createBuiltInBuildSystemAdapter(
146
- projectRoot: URL ,
145
+ private func createBuiltInBuildSystemAdapter(
147
146
messagesToSourceKitLSPHandler: any MessageHandler ,
148
147
buildSystemHooks: BuildSystemHooks ,
149
148
_ createBuildSystem: @Sendable ( _ connectionToSourceKitLSP: any Connection ) async throws -> BuiltInBuildSystem ?
@@ -186,6 +185,7 @@ private extension BuildSystemSpec {
186
185
let buildSystem = await orLog ( " Creating external build system " ) {
187
186
try await ExternalBuildSystemAdapter (
188
187
projectRoot: projectRoot,
188
+ configPath: configPath,
189
189
messagesToSourceKitLSPHandler: messagesToSourceKitLSPHandler
190
190
)
191
191
}
@@ -196,23 +196,18 @@ private extension BuildSystemSpec {
196
196
logger. log ( " Created external build server at \( projectRoot) " )
197
197
return . external( buildSystem)
198
198
case . compilationDatabase:
199
- return await Self . createBuiltInBuildSystemAdapter (
200
- projectRoot: projectRoot,
199
+ return await createBuiltInBuildSystemAdapter (
201
200
messagesToSourceKitLSPHandler: messagesToSourceKitLSPHandler,
202
201
buildSystemHooks: buildSystemHooks
203
202
) { connectionToSourceKitLSP in
204
- CompilationDatabaseBuildSystem (
205
- projectRoot: projectRoot,
206
- searchPaths: ( options. compilationDatabaseOrDefault. searchPaths ?? [ ] ) . compactMap {
207
- try ? RelativePath ( validating: $0)
208
- } ,
203
+ try CompilationDatabaseBuildSystem (
204
+ configPath: configPath,
209
205
connectionToSourceKitLSP: connectionToSourceKitLSP
210
206
)
211
207
}
212
208
case . swiftPM:
213
209
#if canImport(PackageModel)
214
- return await Self . createBuiltInBuildSystemAdapter (
215
- projectRoot: projectRoot,
210
+ return await createBuiltInBuildSystemAdapter (
216
211
messagesToSourceKitLSPHandler: messagesToSourceKitLSPHandler,
217
212
buildSystemHooks: buildSystemHooks
218
213
) { connectionToSourceKitLSP in
@@ -228,8 +223,7 @@ private extension BuildSystemSpec {
228
223
return nil
229
224
#endif
230
225
case . injected( let injector) :
231
- return await Self . createBuiltInBuildSystemAdapter (
232
- projectRoot: projectRoot,
226
+ return await createBuiltInBuildSystemAdapter (
233
227
messagesToSourceKitLSPHandler: messagesToSourceKitLSPHandler,
234
228
buildSystemHooks: buildSystemHooks
235
229
) { connectionToSourceKitLSP in
@@ -248,13 +242,14 @@ package actor BuildSystemManager: QueueBasedMessageHandler {
248
242
249
243
package let messageHandlingQueue = AsyncQueue < BuildSystemMessageDependencyTracker > ( )
250
244
251
- /// The root of the project that this build system manages.
245
+ /// The path to the main configuration file (or directory) that this build system manages.
252
246
///
253
- /// For example, in SwiftPM packages this is the folder containing Package.swift.
254
- /// For compilation databases it is the root folder based on which the compilation database was found.
247
+ /// Some examples:
248
+ /// - The path to `Package.swift` for SwiftPM packages
249
+ /// - The path to `compile_commands.json` for a JSON compilation database
255
250
///
256
251
/// `nil` if the `BuildSystemManager` does not have an underlying build system.
257
- package let projectRoot : URL ?
252
+ package let configPath : URL ?
258
253
259
254
/// The files for which the delegate has requested change notifications, ie. the files for which the delegate wants to
260
255
/// get `fileBuildSettingsChanged` and `filesDependenciesUpdated` callbacks.
@@ -359,7 +354,7 @@ package actor BuildSystemManager: QueueBasedMessageHandler {
359
354
self . toolchainRegistry = toolchainRegistry
360
355
self . options = options
361
356
self . connectionToClient = connectionToClient
362
- self . projectRoot = buildSystemSpec? . projectRoot
357
+ self . configPath = buildSystemSpec? . configPath
363
358
self . buildSystemAdapter = await buildSystemSpec? . createBuildSystemAdapter (
364
359
toolchainRegistry: toolchainRegistry,
365
360
options: options,
@@ -413,6 +408,7 @@ package actor BuildSystemManager: QueueBasedMessageHandler {
413
408
logger. log ( " Launched a legacy BSP server. Using push-based build settings model. " )
414
409
let legacyBuildServer = await LegacyBuildServerBuildSystem (
415
410
projectRoot: buildSystemSpec. projectRoot,
411
+ configPath: buildSystemSpec. configPath,
416
412
initializationData: initializeResponse,
417
413
externalBuildSystemAdapter
418
414
)
@@ -679,8 +675,8 @@ package actor BuildSystemManager: QueueBasedMessageHandler {
679
675
result. formUnion ( targets)
680
676
}
681
677
if !filesAndDirectories. directories. isEmpty, let documentPathComponents = document. fileURL? . pathComponents {
682
- for (directory , ( directoryPathComponents, info) ) in filesAndDirectories. directories {
683
- guard let directoryPathComponents, let directoryPath = directory . fileURL else {
678
+ for (_ , ( directoryPathComponents, info) ) in filesAndDirectories. directories {
679
+ guard let directoryPathComponents else {
684
680
continue
685
681
}
686
682
if isDescendant ( documentPathComponents, of: directoryPathComponents) {
0 commit comments