@@ -90,16 +90,18 @@ extension Driver {
9090 incrementalCompilationState = nil
9191 }
9292
93- return try (
94- // For compatibility with swiftpm, the driver produces batched jobs
95- // for every job, even when run in incremental mode, so that all jobs
96- // can be returned from `planBuild`.
97- // But in that case, don't emit lifecycle messages.
98- formBatchedJobs ( jobsInPhases. allJobs,
99- showJobLifecycle: showJobLifecycle && incrementalCompilationState == nil ,
100- jobCreatingPch: jobsInPhases. allJobs. first ( where: { $0. kind == . generatePCH} ) ) ,
101- incrementalCompilationState
102- )
93+ let batchedJobs : [ Job ]
94+ // If the jobs are batched during the incremental build, reuse the computation rather than computing the batches again.
95+ if let incrementalState = incrementalCompilationState {
96+ // For compatibility reasons, all the jobs planned will be returned, even the incremental state suggests the job is not mandatory.
97+ batchedJobs = incrementalState. skippedJobs + incrementalState. mandatoryJobsInOrder + incrementalState. jobsAfterCompiles
98+ } else {
99+ batchedJobs = try formBatchedJobs ( jobsInPhases. allJobs,
100+ showJobLifecycle: showJobLifecycle,
101+ jobCreatingPch: jobsInPhases. allJobs. first ( where: { $0. kind == . generatePCH} ) )
102+ }
103+
104+ return ( batchedJobs, incrementalCompilationState)
103105 }
104106
105107 /// If performing an explicit module build, compute an inter-module dependency graph.
0 commit comments