Skip to content

Commit 339020a

Browse files
committed
Check OutputFileMap
1 parent b6a7f10 commit 339020a

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ public struct Driver {
292292
self.sdkPath = Self.computeSDKPath(&parsedOptions, compilerMode: compilerMode, toolchain: toolchain, diagnosticsEngine: diagnosticEngine, env: env)
293293

294294
self.importedObjCHeader = try Self.computeImportedObjCHeader(&parsedOptions, compilerMode: compilerMode, diagnosticEngine: diagnosticEngine)
295-
self.bridgingPrecompiledHeader = try Self.computeBridgingPrecompiledHeader(&parsedOptions, importedObjCHeader: importedObjCHeader)
295+
self.bridgingPrecompiledHeader = try Self.computeBridgingPrecompiledHeader(&parsedOptions,
296+
importedObjCHeader: importedObjCHeader,
297+
outputFileMap: outputFileMap)
296298

297299
self.enabledSanitizers = try Self.parseSanitizerArgValues(&parsedOptions, diagnosticEngine: diagnosticEngine, toolchain: toolchain, targetTriple: targetTriple)
298300

@@ -1340,12 +1342,17 @@ extension Driver {
13401342
}
13411343

13421344
/// Compute the path of the generated bridging PCH for the Objective-C header.
1343-
static func computeBridgingPrecompiledHeader(_ parsedOptions: inout ParsedOptions, importedObjCHeader: VirtualPath?) throws -> VirtualPath? {
1345+
static func computeBridgingPrecompiledHeader(_ parsedOptions: inout ParsedOptions,
1346+
importedObjCHeader: VirtualPath?,
1347+
outputFileMap: OutputFileMap?) throws -> VirtualPath? {
13441348
guard let input = importedObjCHeader,
13451349
parsedOptions.hasFlag(positive: .enableBridgingPch, negative: .disableBridgingPch, default: true) else {
13461350
return nil
13471351
}
1348-
// FIXME: Check OutputFileMap?
1352+
1353+
if let outputPath = outputFileMap?.existingOutput(inputFile: input, outputType: .pch) {
1354+
return outputPath
1355+
}
13491356

13501357
// FIXME: should have '-.*' at the end of the filename, similar to llvm::sys::fs::createTemporaryFile
13511358
let pchFileName = input.basenameWithoutExt.appendingFileTypeExtension(.pch)

Sources/SwiftDriver/Jobs/GeneratePCHJob.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ extension Driver {
2929
try addCommonFrontendOptions(commandLine: &commandLine, requestPrecompiledObjCHeader: false)
3030

3131
try commandLine.appendLast(.indexStorePath, from: &parsedOptions)
32-
33-
// TODO: Move this to Driver and check OutputFileMap
32+
3433
// TODO: Should this just be pch output with extension changed?
3534
if parsedOptions.hasArgument(.serializeDiagnostics), let outputDirectory = parsedOptions.getLastArgument(.pchOutputDir)?.asSingle {
3635
commandLine.appendFlag(.serializeDiagnosticsPath)
3736
let path: VirtualPath
38-
if let modulePath = parsedOptions.getLastArgument(.emitModulePath) {
37+
if let outputPath = outputFileMap?.existingOutput(inputFile: input.file, outputType: .diagnostics) {
38+
path = outputPath
39+
} else if let modulePath = parsedOptions.getLastArgument(.emitModulePath) {
3940
// TODO: does this hash need to be persistent?
4041
let code = UInt(bitPattern: modulePath.asSingle.hashValue)
4142
let outputName = input.file.basenameWithoutExt + "-" + String(code, radix: 36)

0 commit comments

Comments
 (0)