@@ -46,7 +46,7 @@ public struct Driver {
46
46
case subcommandPassedToDriver
47
47
case relativeFrontendPath( String )
48
48
}
49
-
49
+
50
50
/// The set of environment variables that are visible to the driver and
51
51
/// processes it launches. This is a hook for testing; in actual use
52
52
/// it should be identical to the real environment.
@@ -233,10 +233,10 @@ public struct Driver {
233
233
}
234
234
235
235
// Compute the working directory.
236
+ let cwd = localFileSystem. currentWorkingDirectory
236
237
workingDirectory = try parsedOptions. getLastArgument ( . workingDirectory) . map { workingDirectoryArg in
237
- let cwd = localFileSystem. currentWorkingDirectory
238
- return try cwd. map { AbsolutePath ( workingDirectoryArg. asSingle, relativeTo: $0) } ?? AbsolutePath ( validating: workingDirectoryArg. asSingle)
239
- }
238
+ try cwd. map { AbsolutePath ( workingDirectoryArg. asSingle, relativeTo: $0) } ?? AbsolutePath ( validating: workingDirectoryArg. asSingle)
239
+ } ?? cwd
240
240
241
241
// Apply the working directory to the parsed options.
242
242
if let workingDirectory = self . workingDirectory {
@@ -247,15 +247,22 @@ public struct Driver {
247
247
let inputFiles = try Self . collectInputFiles ( & self . parsedOptions)
248
248
self . inputFiles = inputFiles
249
249
250
+ let outputFileMap : OutputFileMap ?
250
251
// Initialize an empty output file map, which will be populated when we start creating jobs.
251
252
if let outputFileMapArg = parsedOptions. getLastArgument ( . outputFileMap) ? . asSingle {
252
253
let path = try AbsolutePath ( validating: outputFileMapArg)
253
- self . outputFileMap = try . load( file: path, diagnosticEngine: diagnosticEngine)
254
+ outputFileMap = try . load( file: path, diagnosticEngine: diagnosticEngine)
255
+ } else {
256
+ outputFileMap = nil
254
257
}
255
- else {
256
- self . outputFileMap = nil
258
+
259
+ if let workingDirectory = self . workingDirectory {
260
+ self . outputFileMap = outputFileMap? . resolveRelativePaths ( relativeTo: workingDirectory)
261
+ } else {
262
+ self . outputFileMap = outputFileMap
257
263
}
258
264
265
+
259
266
// Determine the compilation mode.
260
267
self . compilerMode = Self . computeCompilerMode ( & parsedOptions, driverKind: driverKind, diagnosticsEngine: diagnosticEngine)
261
268
@@ -440,7 +447,7 @@ extension Driver {
440
447
var isEscaping = false
441
448
// Indicates if we are currently parsing quoted text.
442
449
var quoted = false
443
-
450
+
444
451
for char in line {
445
452
// Backslash escapes to the next character.
446
453
if char == #"\"# , !isEscaping {
@@ -479,7 +486,7 @@ extension Driver {
479
486
return content. split { $0 == " \n " || $0 == " \r \n " }
480
487
. flatMap { tokenizeResponseFileLine ( $0) }
481
488
}
482
-
489
+
483
490
/// Recursively expands the response files.
484
491
/// - Parameter visitedResponseFiles: Set containing visited response files to detect recursive parsing.
485
492
private static func expandResponseFiles(
@@ -1250,7 +1257,7 @@ extension Driver {
1250
1257
// This value will fail the isSwiftIdentifier test below.
1251
1258
moduleName = " "
1252
1259
}
1253
-
1260
+
1254
1261
func fallbackOrDiagnose( _ error: Diagnostic . Message ) {
1255
1262
// FIXME: Current driver notes that this is a "fallback module name".
1256
1263
if compilerOutputType == nil || maybeBuildingExecutable ( & parsedOptions, linkerOutputType: linkerOutputType) {
@@ -1329,7 +1336,7 @@ extension Driver {
1329
1336
sdkPath = try ? toolchain. defaultSDKPath ( ) ? . pathString
1330
1337
}
1331
1338
}
1332
-
1339
+
1333
1340
// An empty string explicitly clears the SDK.
1334
1341
if sdkPath == " " {
1335
1342
sdkPath = nil
@@ -1442,7 +1449,7 @@ extension Driver {
1442
1449
#else
1443
1450
static let defaultToolchainType : Toolchain . Type = GenericUnixToolchain . self
1444
1451
#endif
1445
-
1452
+
1446
1453
static func computeToolchain(
1447
1454
_ explicitTarget: Triple ? ,
1448
1455
diagnosticsEngine: DiagnosticsEngine ,
0 commit comments