@@ -51,11 +51,12 @@ extension IncrementalCompilationState {
51
51
52
52
public func compute( batchJobFormer: inout Driver ) throws -> FirstWave {
53
53
return try blockingConcurrentAccessOrMutation {
54
- let ( initiallySkippedCompileJobs, mandatoryJobsInOrder) =
54
+ let ( initiallySkippedCompileJobs, mandatoryJobsInOrder, afterCompiles ) =
55
55
try computeInputsAndGroups ( batchJobFormer: & batchJobFormer)
56
56
return FirstWave (
57
57
initiallySkippedCompileJobs: initiallySkippedCompileJobs,
58
- mandatoryJobsInOrder: mandatoryJobsInOrder)
58
+ mandatoryJobsInOrder: mandatoryJobsInOrder,
59
+ jobsAfterCompiles: afterCompiles)
59
60
}
60
61
}
61
62
}
@@ -74,34 +75,39 @@ extension IncrementalCompilationState.FirstWaveComputer {
74
75
/// listed in fingerprintExternalDependencies.
75
76
private func computeInputsAndGroups( batchJobFormer: inout Driver )
76
77
throws -> ( initiallySkippedCompileJobs: [ TypedVirtualPath : Job ] ,
77
- mandatoryJobsInOrder: [ Job ] )
78
+ mandatoryJobsInOrder: [ Job ] ,
79
+ jobsAfterCompiles: [ Job ] )
78
80
{
79
81
let compileJobs =
80
82
Dictionary ( uniqueKeysWithValues:
81
83
jobsInPhases. compileJobs. map { ( $0. primaryInputs [ 0 ] , $0) } )
82
84
let buildRecord = self . moduleDependencyGraph. buildRecord
83
- let jobCreatingPch = jobsInPhases. beforeCompiles. first ( where: { $0. kind == . generatePCH} )
84
- guard !buildRecord. inputInfos. isEmpty else {
85
- func everythingIsMandatory( )
86
- throws -> ( initiallySkippedCompileJobs: [ TypedVirtualPath : Job ] ,
87
- mandatoryJobsInOrder: [ Job ] )
88
- {
89
- let mandatoryCompileJobsInOrder = self . inputFiles. swiftSourceFiles. compactMap {
90
- input -> Job ? in
91
- compileJobs [ input. typedFile]
92
- }
85
+ let jobCreatingPch = jobsInPhases. beforeCompiles. first { $0. kind == . generatePCH }
86
+
87
+ func everythingIsMandatory( )
88
+ throws -> ( initiallySkippedCompileJobs: [ TypedVirtualPath : Job ] ,
89
+ mandatoryJobsInOrder: [ Job ] ,
90
+ jobsAfterCompiles: [ Job ] )
91
+ {
92
+ let mandatoryCompileJobsInOrder = self . inputFiles. swiftSourceFiles. compactMap {
93
+ input -> Job ? in
94
+ compileJobs [ input. typedFile]
95
+ }
93
96
94
- let mandatoryJobsInOrder = try
95
- jobsInPhases. beforeCompiles +
96
- batchJobFormer. formBatchedJobs (
97
- mandatoryCompileJobsInOrder,
98
- showJobLifecycle: showJobLifecycle,
99
- jobCreatingPch: jobCreatingPch)
97
+ let mandatoryJobsInOrder = try
98
+ jobsInPhases. beforeCompiles +
99
+ batchJobFormer. formBatchedJobs (
100
+ mandatoryCompileJobsInOrder,
101
+ showJobLifecycle: showJobLifecycle,
102
+ jobCreatingPch: jobCreatingPch)
103
+
104
+ moduleDependencyGraph. setPhase ( to: . buildingAfterEachCompilation)
105
+ return ( initiallySkippedCompileJobs: [ : ] ,
106
+ mandatoryJobsInOrder: mandatoryJobsInOrder,
107
+ jobsAfterCompiles: jobsInPhases. afterCompiles)
108
+ }
100
109
101
- moduleDependencyGraph. setPhase ( to: . buildingAfterEachCompilation)
102
- return ( initiallySkippedCompileJobs: [ : ] ,
103
- mandatoryJobsInOrder: mandatoryJobsInOrder)
104
- }
110
+ guard !buildRecord. inputInfos. isEmpty else {
105
111
return try everythingIsMandatory ( )
106
112
}
107
113
moduleDependencyGraph. setPhase ( to: . updatingAfterCompilation)
@@ -115,9 +121,7 @@ extension IncrementalCompilationState.FirstWaveComputer {
115
121
116
122
let mandatoryCompileJobsInOrder = inputFiles. compactMap {
117
123
input -> Job ? in
118
- initiallySkippedInputs. contains ( input)
119
- ? nil
120
- : compileJobs [ input]
124
+ return initiallySkippedInputs. contains ( input) ? nil : compileJobs [ input]
121
125
}
122
126
123
127
let batchedCompilationJobs = try batchJobFormer. formBatchedJobs (
@@ -129,9 +133,16 @@ extension IncrementalCompilationState.FirstWaveComputer {
129
133
// we can skip running `beforeCompiles` jobs if we also ensure that none of the `afterCompiles` jobs
130
134
// have any dependencies on them.
131
135
let skipAllJobs = batchedCompilationJobs. isEmpty ? !nonVerifyAfterCompileJobsDependOnBeforeCompileJobs( ) : false
132
- let mandatoryJobsInOrder = skipAllJobs ? [ ] : jobsInPhases. beforeCompiles + batchedCompilationJobs
136
+
137
+ // Schedule emitModule job together with verify module interface job.
138
+ let beforeCompileJobs = skipAllJobs ? [ ] : jobsInPhases. beforeCompiles
139
+ let afterCompileJobs = jobsInPhases. afterCompiles. compactMap { job in
140
+ skipAllJobs && job. kind == . verifyModuleInterface ? nil : job
141
+ }
142
+ let mandatoryJobsInOrder = beforeCompileJobs + batchedCompilationJobs
133
143
return ( initiallySkippedCompileJobs: initiallySkippedCompileJobs,
134
- mandatoryJobsInOrder: mandatoryJobsInOrder)
144
+ mandatoryJobsInOrder: mandatoryJobsInOrder,
145
+ jobsAfterCompiles: afterCompileJobs)
135
146
}
136
147
137
148
/// Determine if any of the jobs in the `afterCompiles` group depend on outputs produced by jobs in
0 commit comments