@@ -33,15 +33,15 @@ package import BuildServerProtocol
33
33
package import Foundation
34
34
package import LanguageServerProtocol
35
35
package import SKOptions
36
- package import SourceKitLSPAPI
36
+ @ preconcurrency package import SourceKitLSPAPI
37
37
package import ToolchainRegistry
38
38
package import class ToolchainRegistry. Toolchain
39
39
#else
40
40
import BuildServerProtocol
41
41
import Foundation
42
42
import LanguageServerProtocol
43
43
import SKOptions
44
- import SourceKitLSPAPI
44
+ @ preconcurrency import SourceKitLSPAPI
45
45
import ToolchainRegistry
46
46
import class ToolchainRegistry. Toolchain
47
47
#endif
@@ -131,6 +131,8 @@ package actor SwiftPMBuildSystem: BuiltInBuildSystem {
131
131
private let toolchain : Toolchain
132
132
private let swiftPMWorkspace : Workspace
133
133
134
+ private let pluginConfiguration : PluginConfiguration
135
+
134
136
/// A `ObservabilitySystem` from `SwiftPM` that logs.
135
137
private let observabilitySystem : ObservabilitySystem
136
138
@@ -291,6 +293,19 @@ package actor SwiftPMBuildSystem: BuiltInBuildSystem {
291
293
prepareForIndexing: options. backgroundPreparationModeOrDefault. toSwiftPMPreparation
292
294
)
293
295
296
+ let pluginScriptRunner = DefaultPluginScriptRunner (
297
+ fileSystem: localFileSystem,
298
+ cacheDir: location. pluginWorkingDirectory. appending ( " cache " ) ,
299
+ toolchain: hostSwiftPMToolchain,
300
+ extraPluginSwiftCFlags: [ ] ,
301
+ enableSandbox: !( options. swiftPMOrDefault. disableSandbox ?? false )
302
+ )
303
+ self . pluginConfiguration = PluginConfiguration (
304
+ scriptRunner: pluginScriptRunner,
305
+ workDirectory: location. pluginWorkingDirectory,
306
+ disableSandbox: options. swiftPMOrDefault. disableSandbox ?? false
307
+ )
308
+
294
309
packageLoadingQueue. async {
295
310
await orLog ( " Initial package loading " ) {
296
311
// Schedule an initial generation of the build graph. Once the build graph is loaded, the build system will send
@@ -326,27 +341,30 @@ package actor SwiftPMBuildSystem: BuiltInBuildSystem {
326
341
}
327
342
}
328
343
329
- let modulesGraph = try await self . swiftPMWorkspace . loadPackageGraph (
330
- rootInput : PackageGraphRootInput ( packages : [ AbsolutePath ( validating : projectRoot . filePath ) ] ) ,
331
- forceResolvedVersions : !isForIndexBuild ,
332
- observabilityScope : observabilitySystem . topScope . makeChildScope ( description : " Load package graph " )
333
- )
334
-
335
- signposter . emitEvent ( " Finished loading modules graph " , id : signpostID )
336
-
337
- let plan = try await BuildPlan (
344
+ nonisolated ( unsafe ) let packageLoader = {
345
+ return try await self . swiftPMWorkspace . loadPackageGraph (
346
+ rootInput : PackageGraphRootInput ( packages : [ try AbsolutePath ( validating : self . projectRoot . filePath ) ] ) ,
347
+ forceResolvedVersions : ! self . isForIndexBuild ,
348
+ observabilityScope : self . observabilitySystem . topScope . makeChildScope ( description : " Load package graph " )
349
+ )
350
+ }
351
+ let loaded = try await BuildDescription . load (
352
+ location : swiftPMWorkspace . location ,
338
353
destinationBuildParameters: destinationBuildParameters,
339
354
toolsBuildParameters: toolsBuildParameters,
340
- graph: modulesGraph,
355
+ packageGraphLoader: packageLoader,
356
+ pluginConfiguration: pluginConfiguration,
341
357
disableSandbox: options. swiftPMOrDefault. disableSandbox ?? false ,
342
358
fileSystem: localFileSystem,
343
- observabilityScope: observabilitySystem. topScope. makeChildScope ( description: " Create SwiftPM build plan " )
359
+ observabilityScope: observabilitySystem. topScope. makeChildScope ( description: " Create SwiftPM build description " )
344
360
)
361
+ if !loaded. errors. isEmpty {
362
+ logger. error ( " Loading SwiftPM description had errors: \( loaded. errors) " )
363
+ }
345
364
346
- signposter . emitEvent ( " Finished generating build plan " , id : signpostID )
365
+ self . buildDescription = loaded . description
347
366
348
- let buildDescription = BuildDescription ( buildPlan: plan)
349
- self . buildDescription = buildDescription
367
+ signposter. emitEvent ( " Finished generating build description " , id: signpostID)
350
368
351
369
/// Make sure to execute any throwing statements before setting any
352
370
/// properties because otherwise we might end up in an inconsistent state
@@ -355,7 +373,7 @@ package actor SwiftPMBuildSystem: BuiltInBuildSystem {
355
373
self . swiftPMTargets = [ : ]
356
374
self . targetDependencies = [ : ]
357
375
358
- buildDescription . traverseModules { buildTarget, parent in
376
+ loaded . description . traverseModules { buildTarget, parent in
359
377
let targetIdentifier = orLog ( " Getting build target identifier " ) { try BuildTargetIdentifier ( buildTarget) }
360
378
guard let targetIdentifier else {
361
379
return
0 commit comments