@@ -55,11 +55,9 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
55
55
/// The path to scratch space (.build) directory.
56
56
let scratchDirectory : AbsolutePath
57
57
58
- /// The llbuild build delegate reference.
59
- private var progressTracker : LLBuildProgressTracker ?
60
-
61
- /// The llbuild build system reference.
62
- private var buildSystem : SPMLLBuild . BuildSystem ?
58
+ /// The llbuild build system reference previously created
59
+ /// via \c createBuildSystem call.
60
+ private var current : ( buildSystem: SPMLLBuild . BuildSystem , tracker: LLBuildProgressTracker ) ?
63
61
64
62
/// If build manifest caching should be enabled.
65
63
public let cacheBuildManifest : Bool
@@ -194,7 +192,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
194
192
195
193
/// Cancel the active build operation.
196
194
public func cancel( deadline: DispatchTime ) throws {
197
- buildSystem ? . cancel ( )
195
+ current ? . buildSystem . cancel ( )
198
196
}
199
197
200
198
// Emit a warning if a target imports another target in this build
@@ -355,8 +353,10 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
355
353
try verifyTargetImports ( in: buildDescription)
356
354
357
355
// Create the build system.
358
- let buildSystem = try self . createBuildSystem ( buildDescription: buildDescription)
359
- self . buildSystem = buildSystem
356
+ let ( buildSystem, progressTracker) = try self . createBuildSystem (
357
+ buildDescription: buildDescription
358
+ )
359
+ self . current = ( buildSystem, progressTracker)
360
360
361
361
// If any plugins are part of the build set, compile them now to surface
362
362
// any errors up-front. Returns true if we should proceed with the build
@@ -366,7 +366,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
366
366
}
367
367
368
368
// delegate is only available after createBuildSystem is called
369
- self . progressTracker? . buildStart ( configuration: self . productsBuildParameters. configuration)
369
+ progressTracker. buildStart ( configuration: self . productsBuildParameters. configuration)
370
370
371
371
// Perform the build.
372
372
let llbuildTarget = try computeLLBuildTargetName ( for: subset)
@@ -386,7 +386,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
386
386
subsetDescriptor = nil
387
387
}
388
388
389
- self . progressTracker? . buildComplete (
389
+ progressTracker. buildComplete (
390
390
success: success,
391
391
duration: duration,
392
392
subsetDescriptor: subsetDescriptor
@@ -496,7 +496,10 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
496
496
self . progressTracker? . preparationStepFinished ( preparationStepName, result: ( cachedResult. succeeded ? . succeeded : . failed) )
497
497
}
498
498
}
499
- let delegate = Delegate ( preparationStepName: " Compiling plugin \( plugin. targetName) " , progressTracker: self . progressTracker)
499
+ let delegate = Delegate (
500
+ preparationStepName: " Compiling plugin \( plugin. targetName) " ,
501
+ progressTracker: self . current? . tracker
502
+ )
500
503
let result = try temp_await {
501
504
pluginConfiguration. scriptRunner. compilePluginScript (
502
505
sourceFiles: plugin. sources. paths,
@@ -745,8 +748,10 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
745
748
746
749
/// Build the package structure target.
747
750
private func buildPackageStructure( ) throws -> Bool {
748
- let buildSystem = try self . createBuildSystem ( buildDescription: . none)
749
- self . buildSystem = buildSystem
751
+ let ( buildSystem, tracker) = try self . createBuildSystem (
752
+ buildDescription: . none
753
+ )
754
+ self . current = ( buildSystem, tracker)
750
755
751
756
// Build the package structure target which will re-generate the llbuild manifest, if necessary.
752
757
return buildSystem. build ( target: " PackageStructure " )
@@ -756,7 +761,9 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
756
761
///
757
762
/// The build description should only be omitted when creating the build system for
758
763
/// building the package structure target.
759
- private func createBuildSystem( buildDescription: BuildDescription ? ) throws -> SPMLLBuild . BuildSystem {
764
+ private func createBuildSystem(
765
+ buildDescription: BuildDescription ?
766
+ ) throws -> ( buildSystem: SPMLLBuild . BuildSystem , tracker: LLBuildProgressTracker ) {
760
767
// Figure out which progress bar we have to use during the build.
761
768
let progressAnimation = ProgressAnimation . ninja (
762
769
stream: self . outputStream,
@@ -782,16 +789,17 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
782
789
observabilityScope: self . observabilityScope,
783
790
delegate: self . delegate
784
791
)
785
- self . progressTracker = progressTracker
786
792
787
793
let databasePath = self . scratchDirectory. appending ( " build.db " ) . pathString
788
794
789
- return SPMLLBuild . BuildSystem (
795
+ let llbuildSystem = SPMLLBuild . BuildSystem (
790
796
buildFile: self . productsBuildParameters. llbuildManifest. pathString,
791
797
databaseFile: databasePath,
792
798
delegate: progressTracker,
793
799
schedulerLanes: self . productsBuildParameters. workers
794
800
)
801
+
802
+ return ( buildSystem: llbuildSystem, tracker: progressTracker)
795
803
}
796
804
797
805
/// Runs any prebuild commands associated with the given list of plugin invocation results, in order, and returns the
0 commit comments