@@ -53,6 +53,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
53
53
private let mainModuleName : String ?
54
54
private let cas : SwiftScanCAS ?
55
55
private let swiftScanOracle : InterModuleDependencyOracle
56
+ private let prefixMap : [ ( AbsolutePath , AbsolutePath ) ]
56
57
57
58
/// Clang PCM names contain a hash of the command-line arguments that were used to build them.
58
59
/// We avoid re-running the hash computation with the use of this cache
@@ -73,7 +74,8 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
73
74
dependencyOracle: InterModuleDependencyOracle ,
74
75
integratedDriver: Bool = true ,
75
76
supportsExplicitInterfaceBuild: Bool = false ,
76
- cas: SwiftScanCAS ? = nil ) throws {
77
+ cas: SwiftScanCAS ? = nil ,
78
+ prefixMap: [ ( AbsolutePath , AbsolutePath ) ] = [ ] ) throws {
77
79
self . dependencyGraph = dependencyGraph
78
80
self . toolchain = toolchain
79
81
self . swiftScanOracle = dependencyOracle
@@ -82,6 +84,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
82
84
self . reachabilityMap = try dependencyGraph. computeTransitiveClosure ( )
83
85
self . supportsExplicitInterfaceBuild = supportsExplicitInterfaceBuild
84
86
self . cas = cas
87
+ self . prefixMap = prefixMap
85
88
}
86
89
87
90
/// Supports resolving bridging header pch command from swiftScan.
@@ -185,6 +188,12 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
185
188
}
186
189
}
187
190
191
+ // Add prefix mapping. The option is cache invariant so it can be added without affecting cache key.
192
+ for (key, value) in prefixMap {
193
+ commandLine. appendFlag ( " -cache-replay-prefix-map " )
194
+ commandLine. appendFlag ( value. pathString + " = " + key. pathString)
195
+ }
196
+
188
197
jobs. append ( Job (
189
198
moduleName: moduleId. moduleName,
190
199
kind: . compileModuleFromInterface,
@@ -238,6 +247,12 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
238
247
cacheKeys = [ : ]
239
248
}
240
249
250
+ // Add prefix mapping. The option is cache invariant so it can be added without affecting cache key.
251
+ for (key, value) in prefixMap {
252
+ commandLine. appendFlag ( " -cache-replay-prefix-map " )
253
+ commandLine. appendFlag ( value. pathString + " = " + key. pathString)
254
+ }
255
+
241
256
jobs. append ( Job (
242
257
moduleName: moduleId. moduleName,
243
258
kind: . generatePCM,
0 commit comments