@@ -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,
@@ -113,15 +114,15 @@ fileprivate extension InterModuleDependencyGraph {
113
114
let swiftPrebuiltModuleId = ModuleDependencyId . swiftPrebuiltExternal ( placeholderId. moduleName)
114
115
115
116
let externalModuleId : ModuleDependencyId
116
- if externalModuleInfoMap [ swiftModuleId] != nil {
117
+ if dependencyOracle . getModuleInfo ( of : swiftModuleId) != nil {
117
118
externalModuleId = swiftModuleId
118
- } else if externalModuleInfoMap [ swiftPrebuiltModuleId] != nil {
119
+ } else if dependencyOracle . getModuleInfo ( of : swiftPrebuiltModuleId) != nil {
119
120
externalModuleId = swiftPrebuiltModuleId
120
121
} else {
121
122
throw Driver . Error. missingExternalDependency ( placeholderId. moduleName)
122
123
}
123
124
124
- let externalModuleInfo = externalModuleInfoMap [ externalModuleId] !
125
+ let externalModuleInfo = dependencyOracle . getModuleInfo ( of : externalModuleId) !
125
126
let newExternalModuleDetails =
126
127
SwiftPrebuiltExternalModuleDetails ( compiledModulePath: placeholderPath. description)
127
128
let newInfo = ModuleInfo ( modulePath: placeholderPath. description,
@@ -134,13 +135,14 @@ fileprivate extension InterModuleDependencyGraph {
134
135
135
136
// Traverse and add all of this external target's dependencies to the current graph.
136
137
try resolvePlaceholderModuleDependencies ( moduleId: externalModuleId,
137
- externalModuleInfoMap : externalModuleInfoMap )
138
+ dependencyOracle : dependencyOracle )
138
139
}
139
140
140
141
/// Resolve all dependencies of a placeholder module (direct and transitive), but merging them into the current graph.
141
142
mutating func resolvePlaceholderModuleDependencies( moduleId: ModuleDependencyId ,
142
- externalModuleInfoMap: ModuleInfoMap ) throws {
143
- guard let resolvingModuleInfo = externalModuleInfoMap [ moduleId] else {
143
+ dependencyOracle: InterModuleDependencyOracle )
144
+ throws {
145
+ guard let resolvingModuleInfo = dependencyOracle. getModuleInfo ( of: moduleId) else {
144
146
throw Driver . Error. missingExternalDependency ( moduleId. moduleName)
145
147
}
146
148
@@ -151,7 +153,7 @@ fileprivate extension InterModuleDependencyGraph {
151
153
while let currentId = toVisit [ currentIndex... ] . first {
152
154
currentIndex += 1
153
155
visited. insert ( currentId)
154
- guard let currentInfo = externalModuleInfoMap [ currentId] else {
156
+ guard let currentInfo = dependencyOracle . getModuleInfo ( of : currentId) else {
155
157
throw Driver . Error. missingExternalDependency ( currentId. moduleName)
156
158
}
157
159
0 commit comments