Skip to content

Commit d2fefb4

Browse files
committed
precompute supported scanner-prefix-map option type before initializing ExplicitDependencyBuildPlanner
1 parent fa89499 commit d2fefb4

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
6363
/// Does this compile support `.explicitInterfaceModuleBuild`
6464
private let supportsExplicitInterfaceBuild: Bool
6565

66+
/// status of the scanner prefix mapping option supported by the frontend
67+
private let supportsScannerPrefixMapPaths: Bool
68+
6669
/// Cached command-line additions for all main module compile jobs
6770
private struct ResolvedModuleDependenciesCommandLineComponents {
6871
let inputs: [TypedVirtualPath]
@@ -89,14 +92,16 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
8992
supportsExplicitInterfaceBuild: Bool = false,
9093
cas: SwiftScanCAS? = nil,
9194
prefixMap: [(AbsolutePath, AbsolutePath)] = [],
92-
supportsBridgingHeaderPCHCommand: Bool = false) throws {
95+
supportsBridgingHeaderPCHCommand: Bool = false,
96+
supportsScannerPrefixMapPaths: Bool = false) throws {
9397
self.dependencyGraph = dependencyGraph
9498
self.toolchain = toolchain
9599
self.integratedDriver = integratedDriver
96100
self.mainModuleName = dependencyGraph.mainModuleName
97101
self.reachabilityMap = try dependencyGraph.computeTransitiveClosure()
98102
self.supportsExplicitInterfaceBuild = supportsExplicitInterfaceBuild
99103
self.supportsBridgingHeaderPCHCommand = supportsBridgingHeaderPCHCommand
104+
self.supportsScannerPrefixMapPaths = supportsScannerPrefixMapPaths
100105
self.cas = cas
101106
self.prefixMap = prefixMap
102107
let mainModuleId: ModuleDependencyId = .swift(dependencyGraph.mainModuleName)
@@ -217,7 +222,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
217222
// Add prefix mapping. The option is cache invariant so it can be added without affecting cache key.
218223
for (key, value) in prefixMap {
219224
commandLine.appendFlag("-cache-replay-prefix-map")
220-
if driver.isFrontendArgSupported(Option.scannerPrefixMapPaths) {
225+
if supportsScannerPrefixMapPaths {
221226
commandLine.appendFlag(value.pathString)
222227
commandLine.appendFlag(key.pathString)
223228
} else {
@@ -283,7 +288,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
283288
// Add prefix mapping. The option is cache invariant so it can be added without affecting cache key.
284289
for (key, value) in prefixMap {
285290
commandLine.appendFlag("-cache-replay-prefix-map")
286-
if driver.isFrontendArgSupported(Option.scannerPrefixMapPaths) {
291+
if supportsScannerPrefixMapPaths {
287292
commandLine.appendFlag(value.pathString)
288293
commandLine.appendFlag(key.pathString)
289294
} else {

Sources/SwiftDriver/Jobs/Planning.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ extension Driver {
122122
cas: cas,
123123
prefixMap: prefixMapping,
124124
supportsBridgingHeaderPCHCommand:
125-
interModuleDependencyOracle.supportsBridgingHeaderPCHCommand)
125+
interModuleDependencyOracle.supportsBridgingHeaderPCHCommand,
126+
supportsScannerPrefixMapPaths:
127+
isFrontendArgSupported(.scannerPrefixMapPaths))
126128
} else {
127129
return nil
128130
}

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
174174
from: ModuleDependenciesInputs.fastDependencyScannerOutput.data(using: .utf8)!)
175175
var explicitDependencyBuildPlanner =
176176
try ExplicitDependencyBuildPlanner(dependencyGraph: moduleDependencyGraph,
177-
toolchain: driver.toolchain)
177+
toolchain: driver.toolchain,
178+
supportsScannerPrefixMapPaths: driver.isFrontendArgSupported(.scannerPrefixMapPaths))
178179
let modulePrebuildJobs =
179180
try explicitDependencyBuildPlanner.generateExplicitModuleDependenciesBuildJobs(driver: driver)
180181
XCTAssertEqual(modulePrebuildJobs.count, 4)

0 commit comments

Comments
 (0)