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 14
14
/// An API to allow clients to accumulate InterModuleDependencyGraphs across mutiple main modules/targets
15
15
/// into a single collection of discovered modules.
16
16
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
+ }
19
21
}
20
22
}
21
23
22
24
// This is a backwards-compatibility shim to handle existing ModuleInfoMap-based API
23
25
// used by SwiftPM
24
26
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
+ }
27
31
}
28
32
}
29
33
}
Original file line number Diff line number Diff line change 10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
13
+ import TSCBasic
14
+
13
15
// An inter-module dependency oracle, responsible for responding to queries about
14
16
// dependencies of a given module, caching already-discovered dependencies along the way.
15
17
//
26
28
public class InterModuleDependencyOracle {
27
29
/// Query the ModuleInfo of a module with a given ID
28
30
@_spi ( Testing) public func getModuleInfo( of moduleId: ModuleDependencyId ) -> ModuleInfo ? {
29
- return modules [ moduleId]
31
+ self . lock. withLock {
32
+ return modules [ moduleId]
33
+ }
30
34
}
31
35
32
36
/// Query the direct dependencies of a module with a given ID
33
37
@_spi ( Testing) public func getDependencies( of moduleId: ModuleDependencyId )
34
38
-> [ ModuleDependencyId ] ? {
35
- return modules [ moduleId] ? . directDependencies
39
+ return getModuleInfo ( of : moduleId) ? . directDependencies
36
40
}
37
41
38
42
// TODO: This will require a SwiftDriver entry-point for scanning a module given
@@ -44,6 +48,8 @@ public class InterModuleDependencyOracle {
44
48
// commandLine: [Job.ArgTemplate]) -> InterModuleDependencyGraph {}
45
49
//
46
50
51
+ internal let lock = Lock ( )
52
+
47
53
/// The complete set of modules discovered so far, spanning potentially multiple targets
48
54
internal var modules : ModuleInfoMap = [ : ]
49
55
Original file line number Diff line number Diff line change @@ -407,6 +407,7 @@ extension Driver {
407
407
}
408
408
409
409
// Re-scan Clang modules at all the targets they will be built against.
410
+ // TODO: Should be deprecated once switched over to libSwiftScan
410
411
try resolveVersionedClangDependencies ( dependencyGraph: & dependencyGraph)
411
412
412
413
// Set dependency modules' paths to be saved in the module cache.
You can’t perform that action at this time.
0 commit comments