@@ -59,16 +59,7 @@ import protocol TSCBasic.FileSystem
59
59
extension InterModuleDependencyGraph {
60
60
var topologicalSorting : [ ModuleDependencyId ] {
61
61
get throws {
62
- try topologicalSort ( Array ( modules. keys) ,
63
- successors: {
64
- var dependencies : [ ModuleDependencyId ] = [ ]
65
- let moduleInfo = try moduleInfo ( of: $0)
66
- dependencies. append ( contentsOf: moduleInfo. directDependencies ?? [ ] )
67
- if case . swift( let swiftModuleDetails) = moduleInfo. details {
68
- dependencies. append ( contentsOf: swiftModuleDetails. swiftOverlayDependencies ?? [ ] )
69
- }
70
- return dependencies
71
- } )
62
+ try topologicalSort ( Array ( modules. keys) , successors: { try Array ( moduleInfo ( of: $0) . allDependencies) } )
72
63
}
73
64
}
74
65
@@ -91,22 +82,9 @@ extension InterModuleDependencyGraph {
91
82
}
92
83
// Traverse the set of modules in reverse topological order, assimilating transitive closures
93
84
for moduleId in topologicalIdList. reversed ( ) {
94
- let moduleInfo = try moduleInfo ( of: moduleId)
95
- for dependencyId in moduleInfo. directDependencies! {
85
+ for dependencyId in try moduleInfo ( of: moduleId) . allDependencies {
96
86
transitiveClosureMap [ moduleId] !. formUnion ( transitiveClosureMap [ dependencyId] !)
97
87
}
98
- // For Swift dependencies, their corresponding Swift Overlay dependencies
99
- // and bridging header dependencies are equivalent to direct dependencies.
100
- if case . swift( let swiftModuleDetails) = moduleInfo. details {
101
- let swiftOverlayDependencies = swiftModuleDetails. swiftOverlayDependencies ?? [ ]
102
- for dependencyId in swiftOverlayDependencies {
103
- transitiveClosureMap [ moduleId] !. formUnion ( transitiveClosureMap [ dependencyId] !)
104
- }
105
- let bridgingHeaderDependencies = swiftModuleDetails. bridgingHeaderDependencies ?? [ ]
106
- for dependencyId in bridgingHeaderDependencies {
107
- transitiveClosureMap [ moduleId] !. formUnion ( transitiveClosureMap [ dependencyId] !)
108
- }
109
- }
110
88
}
111
89
// For ease of use down-the-line, remove the node's self from its set of reachable nodes
112
90
for (key, _) in transitiveClosureMap {
@@ -167,7 +145,7 @@ internal extension InterModuleDependencyGraph {
167
145
var visited : Set < ModuleDependencyId > = [ ]
168
146
// Scan from the main module's dependencies to avoid reporting
169
147
// the main module itself in the results.
170
- for dependencyId in mainModuleInfo. directDependencies ?? [ ] {
148
+ for dependencyId in mainModuleInfo. allDependencies {
171
149
try outOfDateModuleScan ( from: dependencyId, visited: & visited,
172
150
modulesRequiringRebuild: & modulesRequiringRebuild,
173
151
fileSystem: fileSystem, cas: cas, forRebuild: forRebuild,
@@ -225,7 +203,7 @@ internal extension InterModuleDependencyGraph {
225
203
let sourceModuleInfo = try moduleInfo ( of: sourceModuleId)
226
204
// Visit the module's dependencies
227
205
var hasOutOfDateModuleDependency = false
228
- for dependencyId in sourceModuleInfo. directDependencies ?? [ ] {
206
+ for dependencyId in sourceModuleInfo. allDependencies {
229
207
// If we have not already visited this module, recurse.
230
208
if !visited. contains ( dependencyId) {
231
209
try outOfDateModuleScan ( from: dependencyId, visited: & visited,
@@ -319,7 +297,7 @@ internal extension InterModuleDependencyGraph {
319
297
}
320
298
321
299
// Check if a dependency of this module has a newer output than this module
322
- for dependencyId in checkedModuleInfo. directDependencies ?? [ ] {
300
+ for dependencyId in checkedModuleInfo. allDependencies {
323
301
let dependencyInfo = try moduleInfo ( of: dependencyId)
324
302
if !verifyInputOlderThanOutputModTime( moduleID. moduleName,
325
303
VirtualPath . lookup ( dependencyInfo. modulePath. path) ,
@@ -409,21 +387,14 @@ internal extension InterModuleDependencyGraph {
409
387
// depends on a corresponding Clang module with the same name.
410
388
// If it does, add it to the path as well.
411
389
var completePath = pathSoFar
412
- if let dependencies = sourceInfo. directDependencies,
413
- dependencies. contains ( . clang( source. moduleName) ) {
390
+ if sourceInfo. allDependencies. contains ( . clang( source. moduleName) ) {
414
391
completePath. append ( . clang( source. moduleName) )
415
392
}
416
393
result = completePath
417
394
return true
418
395
}
419
396
420
- var allDependencies = sourceInfo. directDependencies ?? [ ]
421
- if case . swift( let swiftModuleDetails) = sourceInfo. details,
422
- let overlayDependencies = swiftModuleDetails. swiftOverlayDependencies {
423
- allDependencies. append ( contentsOf: overlayDependencies)
424
- }
425
-
426
- for dependency in allDependencies {
397
+ for dependency in sourceInfo. allDependencies {
427
398
if !visited. contains ( dependency) ,
428
399
try findAPath ( source: dependency,
429
400
pathSoFar: pathSoFar + [ dependency] ,
@@ -446,20 +417,14 @@ internal extension InterModuleDependencyGraph {
446
417
// depends on a corresponding Clang module with the same name.
447
418
// If it does, add it to the path as well.
448
419
var completePath = pathSoFar
449
- if let dependencies = sourceInfo. directDependencies,
450
- dependencies. contains ( . clang( source. moduleName) ) {
420
+ if sourceInfo. allDependencies. contains ( . clang( source. moduleName) ) {
451
421
completePath. append ( . clang( source. moduleName) )
452
422
}
453
423
results. insert ( completePath)
454
424
return
455
425
}
456
426
457
- var allDependencies = sourceInfo. directDependencies ?? [ ]
458
- if case . swift( let swiftModuleDetails) = sourceInfo. details,
459
- let overlayDependencies = swiftModuleDetails. swiftOverlayDependencies {
460
- allDependencies. append ( contentsOf: overlayDependencies)
461
- }
462
- for dependency in allDependencies {
427
+ for dependency in sourceInfo. allDependencies {
463
428
try findAllPaths ( source: dependency,
464
429
pathSoFar: pathSoFar + [ dependency] ,
465
430
results: & results,
0 commit comments