Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,11 @@ extension Driver {
// TODO: Should we support -fcoverage-compilation-dir?
commandLine.appendFlag(.fileCompilationDir)
if let compilationDir = parsedOptions.getLastArgument(.fileCompilationDir)?.asSingle {
commandLine.appendFlag(compilationDir)
let compDirPath = try VirtualPath.intern(path: compilationDir)
try addPathArgument(VirtualPath.lookup(compDirPath), to:&commandLine, remap: jobNeedPathRemap)
} else if let cwd = workingDirectory ?? fileSystem.currentWorkingDirectory {
commandLine.appendFlag(cwd.pathString)
let compDirPath = VirtualPath.absolute(cwd)
try addPathArgument(compDirPath, to:&commandLine, remap: jobNeedPathRemap)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftDriverTests/CachingBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ final class CachingBuildTests: XCTestCase {
var driver = try Driver(args: ["swiftc",
"-I", cHeadersPath.nativePathString(escaped: true),
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
"/tmp/Foo.o", "-v",
"/tmp/Foo.o", "-v", "-g",
"-explicit-module-build",
"-cache-compile-job", "-cas-path", casPath.nativePathString(escaped: true),
"-working-directory", path.nativePathString(escaped: true),
Expand Down
6 changes: 4 additions & 2 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -594,14 +594,16 @@ final class SwiftDriverTests: XCTestCase {

try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-g", "-c", "-file-compilation-dir", ".") { driver in
let jobs = try driver.planBuild()
let path = try VirtualPath.intern(path: ".")
XCTAssertTrue(jobs[0].commandLine.contains(.flag("-file-compilation-dir")))
XCTAssertTrue(jobs[0].commandLine.contains(.flag(".")))
XCTAssertTrue(jobs[0].commandLine.contains(.path(VirtualPath.lookup(path))))
}

try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-g", "-c", "-working-directory", "/tmp") { driver in
let jobs = try driver.planBuild()
let path = try VirtualPath.intern(path: "/tmp")
XCTAssertTrue(jobs[0].commandLine.contains(.flag("-file-compilation-dir")))
XCTAssertTrue(jobs[0].commandLine.contains(.flag("/tmp")))
XCTAssertTrue(jobs[0].commandLine.contains(.path(VirtualPath.lookup(path))))
}

try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-g", "-c") { driver in
Expand Down