File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed
Explicit Module Builds/Inter Module Dependencies Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 1414 /// An API to allow clients to accumulate InterModuleDependencyGraphs across mutiple main modules/targets
1515 /// into a single collection of discovered modules.
1616 func mergeModules( from dependencyGraph: InterModuleDependencyGraph ) throws {
17- for (moduleId, moduleInfo) in dependencyGraph. modules {
18- try InterModuleDependencyGraph . mergeModule ( moduleId, moduleInfo, into: & modules)
17+ try self . lock. withLock {
18+ for (moduleId, moduleInfo) in dependencyGraph. modules {
19+ try InterModuleDependencyGraph . mergeModule ( moduleId, moduleInfo, into: & modules)
20+ }
1921 }
2022 }
2123
2224 // This is a backwards-compatibility shim to handle existing ModuleInfoMap-based API
2325 // used by SwiftPM
2426 func mergeModules( from moduleInfoMap: ModuleInfoMap ) throws {
25- for (moduleId, moduleInfo) in moduleInfoMap {
26- try InterModuleDependencyGraph . mergeModule ( moduleId, moduleInfo, into: & modules)
27+ try self . lock. withLock {
28+ for (moduleId, moduleInfo) in moduleInfoMap {
29+ try InterModuleDependencyGraph . mergeModule ( moduleId, moduleInfo, into: & modules)
30+ }
2731 }
2832 }
2933}
Original file line number Diff line number Diff line change 1010//
1111//===----------------------------------------------------------------------===//
1212
13+ import TSCBasic
14+
1315// An inter-module dependency oracle, responsible for responding to queries about
1416// dependencies of a given module, caching already-discovered dependencies along the way.
1517//
2628public class InterModuleDependencyOracle {
2729 /// Query the ModuleInfo of a module with a given ID
2830 @_spi ( Testing) public func getModuleInfo( of moduleId: ModuleDependencyId ) -> ModuleInfo ? {
29- return modules [ moduleId]
31+ self . lock. withLock {
32+ return modules [ moduleId]
33+ }
3034 }
3135
3236 /// Query the direct dependencies of a module with a given ID
3337 @_spi ( Testing) public func getDependencies( of moduleId: ModuleDependencyId )
3438 -> [ ModuleDependencyId ] ? {
35- return modules [ moduleId] ? . directDependencies
39+ return getModuleInfo ( of : moduleId) ? . directDependencies
3640 }
3741
3842 // TODO: This will require a SwiftDriver entry-point for scanning a module given
@@ -44,6 +48,8 @@ public class InterModuleDependencyOracle {
4448 // commandLine: [Job.ArgTemplate]) -> InterModuleDependencyGraph {}
4549 //
4650
51+ internal let lock = Lock ( )
52+
4753 /// The complete set of modules discovered so far, spanning potentially multiple targets
4854 internal var modules : ModuleInfoMap = [ : ]
4955
Original file line number Diff line number Diff line change @@ -407,6 +407,7 @@ extension Driver {
407407 }
408408
409409 // Re-scan Clang modules at all the targets they will be built against.
410+ // TODO: Should be deprecated once switched over to libSwiftScan
410411 try resolveVersionedClangDependencies ( dependencyGraph: & dependencyGraph)
411412
412413 // Set dependency modules' paths to be saved in the module cache.
You can’t perform that action at this time.
0 commit comments