Skip to content

Commit fd971ab

Browse files
authored
Merge pull request #326 from nkcsgexi/70584224
Derive supplementary output paths using the full basename of .swiftmodule
2 parents 3bbb8a5 + 6c5f9d8 commit fd971ab

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,7 @@ extension Driver {
21792179
parentPath = moduleOutputPath.parentDirectory
21802180
}
21812181

2182-
return parentPath.appending(component: moduleName).replacingExtension(with: type)
2182+
return parentPath.appending(component: moduleOutputPath.basename).replacingExtension(with: type)
21832183
}
21842184

21852185
// If the output option was not provided, don't produce this output at all.

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,6 +2529,21 @@ final class SwiftDriverTests: XCTestCase {
25292529
}
25302530
}
25312531

2532+
func testDeriveSwiftDocPath() throws {
2533+
var driver = try Driver(args: [
2534+
"swiftc", "-emit-module", "/tmp/main.swift", "-emit-module-path", "test-ios-macabi.swiftmodule"
2535+
])
2536+
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
2537+
XCTAssertEqual(plannedJobs.count, 2)
2538+
XCTAssertTrue(plannedJobs[1].kind == .mergeModule)
2539+
XCTAssertTrue(plannedJobs[1].commandLine.contains(.flag("-o")))
2540+
XCTAssertTrue(plannedJobs[1].commandLine.contains(.path(try VirtualPath(path: "test-ios-macabi.swiftmodule"))))
2541+
XCTAssertTrue(plannedJobs[1].commandLine.contains(.flag("-emit-module-doc-path")))
2542+
XCTAssertTrue(plannedJobs[1].commandLine.contains(.path(try VirtualPath(path: "test-ios-macabi.swiftdoc"))))
2543+
XCTAssertTrue(plannedJobs[1].commandLine.contains(.flag("-emit-module-source-info-path")))
2544+
XCTAssertTrue(plannedJobs[1].commandLine.contains(.path(try VirtualPath(path: "test-ios-macabi.swiftsourceinfo"))))
2545+
}
2546+
25322547
func testToolchainClangPath() throws {
25332548
// Overriding the swift executable to a specific location breaks this.
25342549
guard ProcessEnv.vars["SWIFT_DRIVER_SWIFT_EXEC"] == nil,

0 commit comments

Comments
 (0)