|
13 | 13 | import OrderedCollections
|
14 | 14 | import PackageLoading
|
15 | 15 | import PackageModel
|
16 |
| -import TSCBasic |
17 | 16 |
|
18 | 17 | import protocol Basics.FileSystem
|
19 | 18 | import class Basics.ObservabilityScope
|
@@ -270,7 +269,7 @@ public struct ModulesGraph {
|
270 | 269 |
|
271 | 270 | for module in rootModules where module.type == .executable {
|
272 | 271 | // Find all dependencies of this module within its package. Note that we do not traverse plugin usages.
|
273 |
| - let dependencies = try topologicalSortIdentifiable(module.dependencies, successors: { |
| 272 | + let dependencies = try topologicalSort(module.dependencies, successors: { |
274 | 273 | $0.dependencies.compactMap{ $0.module }.filter{ $0.type != .plugin }.map{ .module($0, conditions: []) }
|
275 | 274 | }).compactMap({ $0.module })
|
276 | 275 |
|
@@ -403,7 +402,7 @@ enum GraphError: Error {
|
403 | 402 | ///
|
404 | 403 | /// - Complexity: O(v + e) where (v, e) are the number of vertices and edges
|
405 | 404 | /// reachable from the input nodes via the relation.
|
406 |
| -func topologicalSortIdentifiable<T: Identifiable>( |
| 405 | +fileprivate func topologicalSort<T: Identifiable>( |
407 | 406 | _ nodes: [T], successors: (T) throws -> [T]
|
408 | 407 | ) throws -> [T] {
|
409 | 408 | // Implements a topological sort via recursion and reverse postorder DFS.
|
@@ -497,3 +496,12 @@ public func loadModulesGraph(
|
497 | 496 | modulesFilter: nil
|
498 | 497 | )
|
499 | 498 | }
|
| 499 | + |
| 500 | +fileprivate extension Array { |
| 501 | + /// Create a dictionary with given sequence of elements. |
| 502 | + func spm_createDictionary<Key: Hashable, Value>( |
| 503 | + _ uniqueKeysWithValues: (Element) -> (Key, Value) |
| 504 | + ) -> [Key: Value] { |
| 505 | + return Dictionary(uniqueKeysWithValues: self.map(uniqueKeysWithValues)) |
| 506 | + } |
| 507 | +} |
0 commit comments