Skip to content

Commit 4ee6cd1

Browse files
authored
[Build] Use a separate scope while constructing a build plan (#7865)
### Motivation: We need to use a separate inner scope to capture any problems during build plan construction and make a decision to stop based on that. The current logic checks the scope that is passed in which tracks errors emitted elsewhere. ### Modifications: - Passes an child scope called "Planning" to the `computeDestinations` functions that is used to construct the plan. ### Result: sourcekit-lsp no longer fails if there is no Package.resolved - swiftlang/sourcekit-lsp#1618
1 parent 392a2a9 commit 4ee6cd1

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Sources/Build/BuildPlan/BuildPlan.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
300300
var pluginDescriptions = [PluginBuildDescription]()
301301
var shouldGenerateTestObservation = true
302302

303+
let planningObservabilityScope = observabilityScope.makeChildScope(description: "Planning")
303304
try await Self.computeDestinations(
304305
graph: graph,
305306
onProduct: { product, destination in
@@ -317,7 +318,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
317318
toolsVersion: package.manifest.toolsVersion,
318319
buildParameters: destination == .host ? toolsBuildParameters : destinationBuildParameters,
319320
fileSystem: fileSystem,
320-
observabilityScope: observabilityScope
321+
observabilityScope: planningObservabilityScope
321322
))
322323
},
323324
onModule: { module, destination in
@@ -341,7 +342,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
341342
product: product,
342343
forTarget: module,
343344
buildEnvironment: buildParameters.buildEnvironment,
344-
observabilityScope: observabilityScope
345+
observabilityScope: planningObservabilityScope
345346
.makeChildScope(description: "Validate Deployment of Dependency")
346347
)
347348
}
@@ -358,7 +359,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
358359
additionalFileRules: additionalFileRules,
359360
pkgConfigDirectories: pkgConfigDirectories,
360361
fileSystem: fileSystem,
361-
observabilityScope: observabilityScope,
362+
observabilityScope: planningObservabilityScope,
362363
surfaceDiagnostics: true
363364
)
364365

@@ -371,7 +372,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
371372
using: pluginConfiguration,
372373
for: pluginInvocationResults,
373374
fileSystem: fileSystem,
374-
observabilityScope: observabilityScope
375+
observabilityScope: planningObservabilityScope
375376
)
376377
}
377378

@@ -396,7 +397,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
396397
shouldGenerateTestObservation: generateTestObservation,
397398
shouldDisableSandbox: disableSandbox,
398399
fileSystem: fileSystem,
399-
observabilityScope: observabilityScope
400+
observabilityScope: planningObservabilityScope
400401
)
401402
)
402403
case is ClangModule:
@@ -410,7 +411,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
410411
buildToolPluginInvocationResults: buildToolPluginInvocationResults[module.id] ?? [],
411412
prebuildCommandResults: prebuildCommandResults[module.id] ?? [],
412413
fileSystem: fileSystem,
413-
observabilityScope: observabilityScope
414+
observabilityScope: planningObservabilityScope
414415
)
415416
)
416417
case is PluginModule:
@@ -434,7 +435,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
434435
toolsVersion: package.manifest.toolsVersion,
435436
buildParameters: toolsBuildParameters,
436437
fileSystem: fileSystem,
437-
observabilityScope: observabilityScope
438+
observabilityScope: planningObservabilityScope
438439
))
439440
}
440441

@@ -459,7 +460,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
459460
}
460461

461462
// Abort now if we have any diagnostics at this point.
462-
guard !observabilityScope.errorsReported else {
463+
guard !planningObservabilityScope.errorsReported else {
463464
throw Diagnostics.fatalError
464465
}
465466

0 commit comments

Comments
 (0)