@@ -100,8 +100,7 @@ extension ModuleDependencyGraph {
100100 return Set < TypedVirtualPath > ( )
101101 }
102102 return collectInputsRequiringCompilationAfterProcessing (
103- dependencySource: getSource ( for: input) ,
104- includeAddedExternals: false )
103+ dependencySource: getSource ( for: input) )
105104 }
106105}
107106
@@ -110,8 +109,7 @@ extension ModuleDependencyGraph {
110109 func collectNodesInvalidatedByChangedOrAddedExternals( ) -> Set < Node > {
111110 fingerprintedExternalDependencies. reduce ( into: Set ( ) ) { invalidatedNodes, fed in
112111 invalidatedNodes. formUnion (
113- self . collectNodesInvalidatedByProcessing ( fingerprintedExternalDependency: fed,
114- includeAddedExternals: true ) )
112+ self . collectNodesInvalidatedByProcessing ( fingerprintedExternalDependency: fed) )
115113 }
116114 }
117115}
@@ -180,8 +178,7 @@ extension ModuleDependencyGraph {
180178 precondition ( input. type == . swift)
181179 let dependencySource = getSource ( for: input)
182180 return collectInputsRequiringCompilationAfterProcessing (
183- dependencySource: dependencySource,
184- includeAddedExternals: true )
181+ dependencySource: dependencySource)
185182 }
186183}
187184
@@ -237,15 +234,9 @@ extension ModuleDependencyGraph {
237234
238235 /// Find all the inputs known to need recompilation as a consequence of reading a swiftdeps or swiftmodule
239236 /// `dependencySource` - The file to read containing dependency information
240- /// `includeAddedExternals` - If `true` external dependencies read from the dependencySource cause inputs to be invalidated,
241- /// even if the external file has not changed since the last build.
242- /// (`false` when building a graph from swiftdeps, `true` when building a graph from rereading the result of a compilation,
243- /// because in that case the added external is assumed to be caused by an `import` added to the source file.)
244- /// `invalidatedOnlyByExternals` - Only return inputs invalidated because of external dependencies, vs invalidated by any dependency
245237 /// Returns `nil` on error
246238 private func collectInputsRequiringCompilationAfterProcessing(
247- dependencySource: DependencySource ,
248- includeAddedExternals: Bool
239+ dependencySource: DependencySource
249240 ) -> Set < TypedVirtualPath > ? {
250241 guard let sourceGraph = dependencySource. read ( in: info. fileSystem,
251242 reporter: info. reporter)
@@ -256,16 +247,12 @@ extension ModuleDependencyGraph {
256247 because: " malformed dependencies file ' \( dependencySource. typedFile) ' " ) )
257248 return nil
258249 }
259- let results = Integrator . integrate ( from: sourceGraph,
260- into: self ,
261- includeAddedExternals: includeAddedExternals)
262-
263- /// When reading from a swiftdeps file ( includeAddedExternals is false), any changed input files are
264- /// computed separately. (TODO: fix this? by finding changed inputs in a callee?),
265- /// so the only invalidates that matter are the ones caused by
266- /// changed external dependencies.
267- /// When reading a swiftdeps file after compiling, any invalidated node matters.
268- let invalidatedNodes = includeAddedExternals
250+ let results = Integrator . integrate ( from: sourceGraph, into: self )
251+
252+ /// If reading for the first time, the driver is compiling all outdated source files anyway, so only
253+ /// nodes invalidated by external dependencies matter.
254+ /// But when updating, all invalidations matter.
255+ let invalidatedNodes = phase. isUpdating
269256 ? results. allInvalidatedNodes
270257 : results. nodesInvalidatedByUsingSomeExternal
271258
@@ -288,12 +275,9 @@ extension ModuleDependencyGraph {
288275
289276 /// Process a possibly-fingerprinted external dependency by reading and integrating, if applicable.
290277 /// Return the nodes thus invalidated.
291- /// includeAddedExternals - return the changes arising merely because the external was new to the graph,
292- /// as opposed to changes from changed externals.
293278 /// But always integrate, in order to detect future changes.
294279 func collectNodesInvalidatedByProcessing(
295- fingerprintedExternalDependency fed: FingerprintedExternalDependency ,
296- includeAddedExternals: Bool )
280+ fingerprintedExternalDependency fed: FingerprintedExternalDependency )
297281 -> Set < Node > {
298282
299283 let isNewToTheGraph = fingerprintedExternalDependencies. insert ( fed) . inserted
@@ -308,11 +292,10 @@ extension ModuleDependencyGraph {
308292 ( isNewToTheGraph || lazyModTimer. hasExternalFileChanged)
309293
310294 let invalidatedNodesFromIncrementalExternal = shouldTryToProcess
311- ? collectNodesInvalidatedByAttemptingToProcess (
312- fed, info, includeAddedExternals: includeAddedExternals)
295+ ? collectNodesInvalidatedByAttemptingToProcess ( fed, info)
313296 : nil
314297
315- let callerWantsTheseChanges = ( includeAddedExternals && isNewToTheGraph) ||
298+ let callerWantsTheseChanges = ( phase . isUpdating && isNewToTheGraph) ||
316299 lazyModTimer. hasExternalFileChanged
317300
318301 return !callerWantsTheseChanges
@@ -330,17 +313,12 @@ extension ModuleDependencyGraph {
330313
331314 private func collectNodesInvalidatedByAttemptingToProcess(
332315 _ fed: FingerprintedExternalDependency ,
333- _ info: IncrementalCompilationState . InitialStateComputer ,
334- includeAddedExternals: Bool
335- ) -> Set < Node > ? {
316+ _ info: IncrementalCompilationState . InitialStateComputer ) -> Set < Node > ? {
336317 fed. incrementalDependencySource?
337318 . read ( in: info. fileSystem, reporter: info. reporter)
338319 . map { unserializedDepGraph in
339320 info. reporter? . report ( " Integrating changes from: \( fed. externalDependency) " )
340- return Integrator . integrate (
341- from: unserializedDepGraph,
342- into: self ,
343- includeAddedExternals: includeAddedExternals)
321+ return Integrator . integrate ( from: unserializedDepGraph, into: self )
344322 . allInvalidatedNodes
345323 }
346324 }
0 commit comments