@@ -41,10 +41,11 @@ import Foundation
41
41
// which the driver will then resolve using B's full dependency graph provided by the client.
42
42
43
43
/// Resolve all placeholder dependencies using external dependency information provided by the client
44
- mutating func resolvePlaceholderDependencies( using externalBuildArtifacts: ExternalBuildArtifacts )
44
+ mutating func resolvePlaceholderDependencies( for externalBuildArtifacts: ExternalBuildArtifacts ,
45
+ using dependencyOracle: InterModuleDependencyOracle )
45
46
throws {
46
47
let externalTargetModulePathMap = externalBuildArtifacts. 0
47
- let externalModuleInfoMap = externalBuildArtifacts. 1
48
+ // let externalModuleInfoMap = externalBuildArtifacts.1
48
49
let placeholderFilter : ( ModuleDependencyId ) -> Bool = {
49
50
if case . swiftPlaceholder( _) = $0 {
50
51
return true
@@ -61,7 +62,7 @@ import Foundation
61
62
}
62
63
try resolveTargetPlaceholder ( placeholderId: moduleId,
63
64
placeholderPath: placeholderModulePath,
64
- externalModuleInfoMap : externalModuleInfoMap )
65
+ dependencyOracle : dependencyOracle )
65
66
}
66
67
67
68
// Process remaining placeholders until there are none left
@@ -70,17 +71,17 @@ import Foundation
70
71
let moduleId = placeholderModules. first!
71
72
let swiftModuleId = ModuleDependencyId . swift ( moduleId. moduleName)
72
73
73
- guard externalModuleInfoMap [ swiftModuleId] != nil else {
74
+ guard dependencyOracle . getModuleInfo ( of : swiftModuleId) != nil else {
74
75
throw Driver . Error. missingExternalDependency ( moduleId. moduleName)
75
76
}
76
- let moduleInfo = externalModuleInfoMap [ swiftModuleId] !
77
+ let moduleInfo = dependencyOracle . getModuleInfo ( of : swiftModuleId) !
77
78
78
79
// Insert the resolved module, replacing the placeholder.
79
80
try Self . mergeModule ( swiftModuleId, moduleInfo, into: & modules)
80
81
81
82
// Traverse and add all of this external module's dependencies to the current graph.
82
83
try resolvePlaceholderModuleDependencies ( moduleId: swiftModuleId,
83
- externalModuleInfoMap : externalModuleInfoMap )
84
+ dependencyOracle : dependencyOracle )
84
85
85
86
// Update the set of remaining placeholders to resolve
86
87
placeholderModules = modules. keys. filter ( placeholderFilter)
@@ -92,7 +93,7 @@ fileprivate extension InterModuleDependencyGraph {
92
93
/// Resolve a placeholder dependency that is an external target.
93
94
mutating func resolveTargetPlaceholder( placeholderId: ModuleDependencyId ,
94
95
placeholderPath: AbsolutePath ,
95
- externalModuleInfoMap : ModuleInfoMap )
96
+ dependencyOracle : InterModuleDependencyOracle )
96
97
throws {
97
98
// For this placeholder dependency, generate a new module info containing only the pre-compiled
98
99
// module path, and insert it into the current module's dependency graph,
@@ -119,15 +120,15 @@ fileprivate extension InterModuleDependencyGraph {
119
120
let swiftPrebuiltModuleId = ModuleDependencyId . swiftPrebuiltExternal ( placeholderId. moduleName)
120
121
121
122
let externalModuleId : ModuleDependencyId
122
- if externalModuleInfoMap [ swiftModuleId] != nil {
123
+ if dependencyOracle . getModuleInfo ( of : swiftModuleId) != nil {
123
124
externalModuleId = swiftModuleId
124
- } else if externalModuleInfoMap [ swiftPrebuiltModuleId] != nil {
125
+ } else if dependencyOracle . getModuleInfo ( of : swiftPrebuiltModuleId) != nil {
125
126
externalModuleId = swiftPrebuiltModuleId
126
127
} else {
127
128
throw Driver . Error. missingExternalDependency ( placeholderId. moduleName)
128
129
}
129
130
130
- let externalModuleInfo = externalModuleInfoMap [ externalModuleId] !
131
+ let externalModuleInfo = dependencyOracle . getModuleInfo ( of : externalModuleId) !
131
132
let newExternalModuleDetails =
132
133
SwiftPrebuiltExternalModuleDetails ( compiledModulePath: placeholderPath. description)
133
134
let newInfo = ModuleInfo ( modulePath: placeholderPath. description,
@@ -140,13 +141,14 @@ fileprivate extension InterModuleDependencyGraph {
140
141
141
142
// Traverse and add all of this external target's dependencies to the current graph.
142
143
try resolvePlaceholderModuleDependencies ( moduleId: externalModuleId,
143
- externalModuleInfoMap : externalModuleInfoMap )
144
+ dependencyOracle : dependencyOracle )
144
145
}
145
146
146
147
/// Resolve all dependencies of a placeholder module (direct and transitive), but merging them into the current graph.
147
148
mutating func resolvePlaceholderModuleDependencies( moduleId: ModuleDependencyId ,
148
- externalModuleInfoMap: ModuleInfoMap ) throws {
149
- guard let resolvingModuleInfo = externalModuleInfoMap [ moduleId] else {
149
+ dependencyOracle: InterModuleDependencyOracle )
150
+ throws {
151
+ guard let resolvingModuleInfo = dependencyOracle. getModuleInfo ( of: moduleId) else {
150
152
throw Driver . Error. missingExternalDependency ( moduleId. moduleName)
151
153
}
152
154
@@ -157,7 +159,7 @@ fileprivate extension InterModuleDependencyGraph {
157
159
while let currentId = toVisit [ currentIndex... ] . first {
158
160
currentIndex += 1
159
161
visited. insert ( currentId)
160
- guard let currentInfo = externalModuleInfoMap [ currentId] else {
162
+ guard let currentInfo = dependencyOracle . getModuleInfo ( of : currentId) else {
161
163
throw Driver . Error. missingExternalDependency ( currentId. moduleName)
162
164
}
163
165
0 commit comments