Skip to content

Commit 6861080

Browse files
authored
Merge pull request #576 from artemcm/WhoDebugTheDebugger
Set dsym-job's output to be the primary output file + `.dSYM`
2 parents 0304c80 + f31c86a commit 6861080

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

Sources/SwiftDriver/Jobs/GenerateDSYMJob.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
extension Driver {
14-
func generateDSYMJob(inputs: [TypedVirtualPath]) throws -> Job {
14+
mutating func generateDSYMJob(inputs: [TypedVirtualPath]) throws -> Job {
1515
assert(inputs.count == 1)
1616
let input = inputs[0]
17-
let outputPath = input.file.replacingExtension(with: .dSYM)
17+
18+
// Output is final output file + `.dSYM`
19+
let outputFile: VirtualPath
20+
if let output = parsedOptions.getLastArgument(.o) {
21+
outputFile = try VirtualPath(path: output.asSingle)
22+
} else {
23+
outputFile = outputFileForImage
24+
}
25+
let outputPath = try VirtualPath(path: outputFile.description.appendingFileTypeExtension(.dSYM))
1826

1927
var commandLine = [Job.ArgTemplate]()
2028
commandLine.appendPath(input.file)

Sources/SwiftDriver/Jobs/LinkJob.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import TSCBasic
1313

1414
extension Driver {
15-
private var relativeOutputFileForImage: RelativePath {
15+
internal var relativeOutputFileForImage: RelativePath {
1616
if inputFiles.count == 1 && moduleOutputInfo.nameIsFallback && inputFiles[0].file != .standardInput {
1717
return RelativePath(inputFiles[0].file.basenameWithoutExt)
1818
}
@@ -24,7 +24,7 @@ extension Driver {
2424
}
2525

2626
/// Compute the output file for an image output.
27-
private var outputFileForImage: VirtualPath {
27+
internal var outputFileForImage: VirtualPath {
2828
return useWorkingDirectory(relativeOutputFileForImage)
2929
}
3030

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,6 +2859,17 @@ final class SwiftDriverTests: XCTestCase {
28592859

28602860
XCTAssertTrue(cmd.contains(.path(try VirtualPath(path: "Test"))))
28612861
}
2862+
2863+
do {
2864+
// dSYM generation (-g) with specified output file name with an extension
2865+
var driver = try Driver(args: commonArgs + ["-g", "-o", "a.out"])
2866+
let plannedJobs = try driver.planBuild()
2867+
let generateDSYMJob = plannedJobs.last!
2868+
if driver.targetTriple.isDarwin {
2869+
XCTAssertEqual(plannedJobs.count, 5)
2870+
XCTAssertEqual(generateDSYMJob.outputs.last?.file, try VirtualPath(path: "a.out.dSYM"))
2871+
}
2872+
}
28622873
}
28632874

28642875
func testEmitModuleTrace() throws {

0 commit comments

Comments
 (0)