File tree Expand file tree Collapse file tree 1 file changed +34
-2
lines changed
Sources/SwiftDriver/IncrementalCompilation Expand file tree Collapse file tree 1 file changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -202,9 +202,41 @@ extension IncrementalCompilationState.FirstWaveComputer {
202202 return false
203203 }
204204
205- // Ensure that no output is older than any of the inputs
205+ // If all the modules are older than the outputs, we can skip
206206 let oldestOutputModTime : TimePoint = try emitModuleJob. outputs. map { try fileSystem. lastModificationTime ( for: $0. file) } . min ( ) ?? . distantPast
207- return try emitModuleJob. inputs. swiftSourceFiles. allSatisfy ( { try fileSystem. lastModificationTime ( for: $0. typedFile. file) < oldestOutputModTime } )
207+ let areModulesOlderThanOutput = try emitModuleJob. inputs. swiftSourceFiles. allSatisfy ( { try fileSystem. lastModificationTime ( for: $0. typedFile. file) < oldestOutputModTime } )
208+ guard !areModulesOlderThanOutput else {
209+ return true
210+ }
211+ // If we are not using hashes, we cannot skip
212+ guard useHashes else {
213+ return false
214+ }
215+ let inputs : [ TypedVirtualPath ] = emitModuleJob. inputs
216+ for input : TypedVirtualPath in inputs {
217+ guard let currentDate: FileMetadata = buildRecordInfo. compilationInputModificationDates [ input] else {
218+ reporter? . report ( " Missing file metadata for: \( input) " )
219+ return false
220+ }
221+
222+ guard let currentHash: String = currentDate. hash else {
223+ reporter? . report ( " Missing file hash data for: \( input) " )
224+ return false
225+ }
226+
227+ let inputInfos : [ VirtualPath : InputInfo ] = buildRecord. inputInfos
228+ guard let inputInfo: InputInfo = inputInfos [ input. file] else {
229+ reporter? . report ( " Missing incremental info for: \( input) " )
230+ return false
231+ }
232+
233+ if currentHash != inputInfo. hash {
234+ reporter? . report ( " Changed hash for: \( input) " )
235+ return false
236+ }
237+ }
238+ return true
239+
208240 }
209241
210242 /// Figure out which compilation inputs are *not* mandatory at the start
You can’t perform that action at this time.
0 commit comments