Skip to content

Commit 30f2a83

Browse files
authored
Merge pull request #405 from nkcsgexi/72181925
Honor -emit-module-path for installAPI tasks
2 parents db5cb94 + 21f72bf commit 30f2a83

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Sources/SwiftDriver/Jobs/CompileJob.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ extension Driver {
3838
return TypedVirtualPath(file: baseOutputPath, type: outputType)
3939
} else if compilerOutputType?.isTextual == true {
4040
return TypedVirtualPath(file: .standardOutput, type: outputType)
41+
} else if outputType == .swiftModule, let moduleOutput = moduleOutputInfo.output {
42+
return TypedVirtualPath(file: moduleOutput.outputPath, type: outputType)
4143
}
4244
}
4345

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,6 +1813,21 @@ final class SwiftDriverTests: XCTestCase {
18131813
}
18141814
}
18151815

1816+
func testInstallAPI() throws {
1817+
let modulePath = "/tmp/FooMod.swiftmodule"
1818+
var driver = try Driver(args: ["swiftc", "foo.swift", "-whole-module-optimization",
1819+
"-module-name", "FooMod",
1820+
"-emit-tbd", "-emit-tbd-path", "/tmp/FooMod.tbd",
1821+
"-emit-module", "-emit-module-path", modulePath])
1822+
let plannedJobs = try driver.planBuild()
1823+
XCTAssertEqual(plannedJobs.count, 1)
1824+
XCTAssertEqual(plannedJobs[0].kind, .compile)
1825+
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-frontend")))
1826+
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-emit-module")))
1827+
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-o")))
1828+
XCTAssertTrue(plannedJobs[0].commandLine.contains(.path(try VirtualPath(path: modulePath))))
1829+
}
1830+
18161831
func testImmediateMode() throws {
18171832
do {
18181833
var driver = try Driver(args: ["swift", "foo.swift"])

0 commit comments

Comments
 (0)