@@ -284,16 +284,70 @@ public struct Driver {
284
284
self . enabledSanitizers = try Self . parseSanitizerArgValues ( & parsedOptions, diagnosticEngine: diagnosticEngine, toolchain: toolchain, targetTriple: targetTriple)
285
285
286
286
// Supplemental outputs.
287
- self . dependenciesFilePath = try Self . computeSupplementaryOutputPath ( & parsedOptions, type: . dependencies, isOutput: . emitDependencies, outputPath: . emitDependenciesPath, compilerOutputType: compilerOutputType, moduleName: moduleName)
288
- self . referenceDependenciesFilePath = try Self . computeSupplementaryOutputPath ( & parsedOptions, type: . swiftDeps, isOutput: . emitReferenceDependencies, outputPath: . emitReferenceDependenciesPath, compilerOutputType: compilerOutputType, moduleName: moduleName)
289
- self . serializedDiagnosticsFilePath = try Self . computeSupplementaryOutputPath ( & parsedOptions, type: . diagnostics, isOutput: . serializeDiagnostics, outputPath: . serializeDiagnosticsPath, compilerOutputType: compilerOutputType, moduleName: moduleName)
287
+ self . dependenciesFilePath = try Self . computeSupplementaryOutputPath (
288
+ & parsedOptions, type: . dependencies, isOutput: . emitDependencies,
289
+ outputPath: . emitDependenciesPath,
290
+ compilerOutputType: compilerOutputType,
291
+ compilerMode: compilerMode,
292
+ outputFileMap: self . outputFileMap,
293
+ moduleName: moduleName)
294
+ self . referenceDependenciesFilePath = try Self . computeSupplementaryOutputPath (
295
+ & parsedOptions, type: . swiftDeps, isOutput: . emitReferenceDependencies,
296
+ outputPath: . emitReferenceDependenciesPath,
297
+ compilerOutputType: compilerOutputType,
298
+ compilerMode: compilerMode,
299
+ outputFileMap: self . outputFileMap,
300
+ moduleName: moduleName)
301
+ self . serializedDiagnosticsFilePath = try Self . computeSupplementaryOutputPath (
302
+ & parsedOptions, type: . diagnostics, isOutput: . serializeDiagnostics,
303
+ outputPath: . serializeDiagnosticsPath,
304
+ compilerOutputType: compilerOutputType,
305
+ compilerMode: compilerMode,
306
+ outputFileMap: self . outputFileMap,
307
+ moduleName: moduleName)
290
308
// FIXME: -fixits-output-path
291
- self . objcGeneratedHeaderPath = try Self . computeSupplementaryOutputPath ( & parsedOptions, type: . objcHeader, isOutput: . emitObjcHeader, outputPath: . emitObjcHeaderPath, compilerOutputType: compilerOutputType, moduleName: moduleName)
292
- self . loadedModuleTracePath = try Self . computeSupplementaryOutputPath ( & parsedOptions, type: . moduleTrace, isOutput: . emitLoadedModuleTrace, outputPath: . emitLoadedModuleTracePath, compilerOutputType: compilerOutputType, moduleName: moduleName)
293
- self . tbdPath = try Self . computeSupplementaryOutputPath ( & parsedOptions, type: . tbd, isOutput: . emitTbd, outputPath: . emitTbdPath, compilerOutputType: compilerOutputType, moduleName: moduleName)
294
- self . moduleDocOutputPath = try Self . computeModuleDocOutputPath ( & parsedOptions, moduleOutputPath: self . moduleOutput? . outputPath, compilerOutputType: compilerOutputType, moduleName: moduleName)
295
- self . swiftInterfacePath = try Self . computeSupplementaryOutputPath ( & parsedOptions, type: . swiftInterface, isOutput: . emitModuleInterface, outputPath: . emitModuleInterfacePath, compilerOutputType: compilerOutputType, moduleName: moduleName)
296
- self . optimizationRecordPath = try Self . computeSupplementaryOutputPath ( & parsedOptions, type: . optimizationRecord, isOutput: . saveOptimizationRecord, outputPath: . saveOptimizationRecordPath, compilerOutputType: compilerOutputType, moduleName: moduleName)
309
+ self . objcGeneratedHeaderPath = try Self . computeSupplementaryOutputPath (
310
+ & parsedOptions, type: . objcHeader, isOutput: . emitObjcHeader,
311
+ outputPath: . emitObjcHeaderPath,
312
+ compilerOutputType: compilerOutputType,
313
+ compilerMode: compilerMode,
314
+ outputFileMap: self . outputFileMap,
315
+ moduleName: moduleName)
316
+ self . loadedModuleTracePath = try Self . computeSupplementaryOutputPath (
317
+ & parsedOptions, type: . moduleTrace, isOutput: . emitLoadedModuleTrace,
318
+ outputPath: . emitLoadedModuleTracePath,
319
+ compilerOutputType: compilerOutputType,
320
+ compilerMode: compilerMode,
321
+ outputFileMap: self . outputFileMap,
322
+ moduleName: moduleName)
323
+ self . tbdPath = try Self . computeSupplementaryOutputPath (
324
+ & parsedOptions, type: . tbd, isOutput: . emitTbd,
325
+ outputPath: . emitTbdPath,
326
+ compilerOutputType: compilerOutputType,
327
+ compilerMode: compilerMode,
328
+ outputFileMap: self . outputFileMap,
329
+ moduleName: moduleName)
330
+ self . moduleDocOutputPath = try Self . computeModuleDocOutputPath (
331
+ & parsedOptions, moduleOutputPath: self . moduleOutput? . outputPath,
332
+ compilerOutputType: compilerOutputType,
333
+ compilerMode: compilerMode,
334
+ outputFileMap: self . outputFileMap,
335
+ moduleName: moduleName)
336
+ self . swiftInterfacePath = try Self . computeSupplementaryOutputPath (
337
+ & parsedOptions, type: . swiftInterface, isOutput: . emitModuleInterface,
338
+ outputPath: . emitModuleInterfacePath,
339
+ compilerOutputType: compilerOutputType,
340
+ compilerMode: compilerMode,
341
+ outputFileMap: self . outputFileMap,
342
+ moduleName: moduleName)
343
+ self . optimizationRecordPath = try Self . computeSupplementaryOutputPath (
344
+ & parsedOptions, type: . optimizationRecord,
345
+ isOutput: . saveOptimizationRecord,
346
+ outputPath: . saveOptimizationRecordPath,
347
+ compilerOutputType: compilerOutputType,
348
+ compilerMode: compilerMode,
349
+ outputFileMap: self . outputFileMap,
350
+ moduleName: moduleName)
297
351
}
298
352
}
299
353
@@ -1249,11 +1303,11 @@ extension Driver {
1249
1303
isOutput: Option ? ,
1250
1304
outputPath: Option ,
1251
1305
compilerOutputType: FileType ? ,
1306
+ compilerMode: CompilerMode ,
1307
+ outputFileMap: OutputFileMap ? ,
1252
1308
moduleName: String ,
1253
1309
patternOutputFile: VirtualPath ? = nil
1254
1310
) throws -> VirtualPath ? {
1255
- // FIXME: Do we need to check the output file map?
1256
-
1257
1311
// If there is an explicit argument for the output path, use that
1258
1312
if let outputPathArg = parsedOptions. getLastArgument ( outputPath) {
1259
1313
// Consume the isOutput argument
@@ -1268,6 +1322,14 @@ extension Driver {
1268
1322
return nil
1269
1323
}
1270
1324
1325
+ // If this is a single-file compile and there is an entry in the
1326
+ // output file map, use that.
1327
+ if compilerMode. isSingleCompilation,
1328
+ let singleOutputPath = outputFileMap? . existingOutputForSingleInput (
1329
+ outputType: type) {
1330
+ return singleOutputPath
1331
+ }
1332
+
1271
1333
// If there is an output argument, derive the name from there.
1272
1334
if let outputPathArg = parsedOptions. getLastArgument ( . o) {
1273
1335
let path = try VirtualPath ( path: outputPathArg. asSingle)
@@ -1288,10 +1350,10 @@ extension Driver {
1288
1350
_ parsedOptions: inout ParsedOptions ,
1289
1351
moduleOutputPath: VirtualPath ? ,
1290
1352
compilerOutputType: FileType ? ,
1353
+ compilerMode: CompilerMode ,
1354
+ outputFileMap: OutputFileMap ? ,
1291
1355
moduleName: String
1292
1356
) throws -> VirtualPath ? {
1293
- // FIXME: Do we need to check the output file map?
1294
-
1295
1357
// If there is an explicit argument for the output path, use that
1296
1358
if let outputPathArg = parsedOptions. getLastArgument ( . emitModuleDocPath) {
1297
1359
// Consume -emit-module-doc if it's there.
@@ -1300,6 +1362,14 @@ extension Driver {
1300
1362
return try VirtualPath ( path: outputPathArg. asSingle)
1301
1363
}
1302
1364
1365
+ // If this is a single-file compile and there is an entry in the
1366
+ // output file map, use that.
1367
+ if compilerMode. isSingleCompilation,
1368
+ let singleOutputPath = outputFileMap? . existingOutputForSingleInput (
1369
+ outputType: . swiftDocumentation) {
1370
+ return singleOutputPath
1371
+ }
1372
+
1303
1373
// If there's a known module output path, put the .swiftdoc file next
1304
1374
// to it.
1305
1375
if let moduleOutputPath = moduleOutputPath {
0 commit comments