@@ -825,8 +825,9 @@ extension Driver {
825825 }
826826
827827 if jobs. contains ( where: { $0. requiresInPlaceExecution } )
828- // Only one job and no cleanup required
829- || ( jobs. count == 1 && !parsedOptions. hasArgument ( . parseableOutput) ) {
828+ // Only one job and no cleanup required, e.g. not writing build record
829+ || ( jobs. count == 1 && !parsedOptions. hasArgument ( . parseableOutput) &&
830+ buildRecordInfo == nil ) {
830831 assert ( jobs. count == 1 , " Cannot execute in place for multi-job build plans " )
831832 var job = jobs [ 0 ]
832833 // Require in-place execution for all single job plans.
@@ -837,17 +838,11 @@ extension Driver {
837838 return
838839 }
839840
840- // Create and use the tool execution delegate if one is not provided explicitly.
841- let executorDelegate = createToolExecutionDelegate ( )
842-
843- // Perform the build
844- try executor. execute ( jobs: jobs,
845- delegate: executorDelegate,
846- numParallelJobs: numParallelJobs ?? 1 ,
847- forceResponseFiles: forceResponseFiles,
848- recordedInputModificationDates: recordedInputModificationDates)
841+ try performTheBuild ( allJobs: jobs, forceResponseFiles: forceResponseFiles)
849842
850- buildRecordInfo? . writeBuildRecord ( jobs, nil )
843+ buildRecordInfo? . writeBuildRecord (
844+ jobs,
845+ incrementalCompilationState? . skippedCompilationInputs)
851846
852847 // If requested, warn for options that weren't used by the driver after the build is finished.
853848 if parsedOptions. hasArgument ( . driverWarnUnusedOptions) {
@@ -875,6 +870,35 @@ extension Driver {
875870 diagnosticEngine: diagnosticEngine)
876871 }
877872
873+ private mutating func performTheBuild(
874+ allJobs: [ Job ] ,
875+ forceResponseFiles: Bool
876+ ) throws {
877+ // Create and use the tool execution delegate if one is not provided explicitly.
878+ let executorDelegate = createToolExecutionDelegate ( )
879+
880+ func execute( jobs: [ Job ] ) throws {
881+ try executor. execute ( jobs: jobs,
882+ delegate: executorDelegate,
883+ numParallelJobs: numParallelJobs ?? 1 ,
884+ forceResponseFiles: forceResponseFiles,
885+ recordedInputModificationDates: recordedInputModificationDates)
886+ }
887+
888+ guard let incrementalCompilationState = incrementalCompilationState else {
889+ try execute ( jobs: allJobs)
890+ return
891+ }
892+ while let jobs = incrementalCompilationState. preOrCompileJobs. removeAll ( ) {
893+ try execute ( jobs: formBatchedJobs ( jobs, forIncremental: true ) )
894+ }
895+ guard let postCompileJobs = incrementalCompilationState. postCompileJobs
896+ else {
897+ fatalError ( " planning must have finished by now " )
898+ }
899+ try execute ( jobs: postCompileJobs)
900+ }
901+
878902 private func printBindings( _ job: Job ) {
879903 stdoutStream <<< #"# ""# <<< targetTriple. triple
880904 stdoutStream <<< #"" - ""# <<< job. tool. basename
0 commit comments