Skip to content

Commit

Permalink
Pass along the symbol-graph flags with emit-module
Browse files Browse the repository at this point in the history
  • Loading branch information
xymus committed Sep 9, 2021
1 parent b12b94e commit 582e81a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Sources/SwiftDriver/Jobs/EmitModuleJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ extension Driver {

addCommonModuleOptions(commandLine: &commandLine, outputs: &outputs, isMergeModule: false)

try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)
try commandLine.appendLast(.emitSymbolGraphDir, from: &parsedOptions)

if parsedOptions.hasArgument(.parseAsLibrary, .emitLibrary) {
commandLine.appendFlag(.parseAsLibrary)
}
Expand Down
7 changes: 5 additions & 2 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,7 @@ final class SwiftDriverTests: XCTestCase {

func testEmitModuleSeparately() throws {
do {
var driver = try Driver(args: ["swiftc", "foo.swift", "bar.swift", "-module-name", "Test", "-emit-module-path", "/foo/bar/Test.swiftmodule", "-experimental-emit-module-separately", "-emit-library", "-target", "x86_64-apple-macosx10.15"])
var driver = try Driver(args: ["swiftc", "foo.swift", "bar.swift", "-module-name", "Test", "-emit-module-path", "/foo/bar/Test.swiftmodule", "-emit-symbol-graph", "-emit-symbol-graph-dir", "/foo/bar/", "-experimental-emit-module-separately", "-emit-library", "-target", "x86_64-apple-macosx10.15"])
let plannedJobs = try driver.planBuild()
XCTAssertEqual(plannedJobs.count, 4)
XCTAssertEqual(Set(plannedJobs.map { $0.kind }), Set([.compile, .emitModule, .link]))
Expand All @@ -2220,6 +2220,9 @@ final class SwiftDriverTests: XCTestCase {
XCTAssertEqual(plannedJobs[0].outputs[0].file, .absolute(AbsolutePath("/foo/bar/Test.swiftmodule")))
XCTAssertEqual(plannedJobs[0].outputs[1].file, .absolute(AbsolutePath("/foo/bar/Test.swiftdoc")))
XCTAssertEqual(plannedJobs[0].outputs[2].file, .absolute(AbsolutePath("/foo/bar/Test.swiftsourceinfo")))

// We don't know the output file of the symbol graph, just make sure the flag is passed along.
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-emit-symbol-graph-dir")))
}

do {
Expand Down Expand Up @@ -2262,7 +2265,7 @@ final class SwiftDriverTests: XCTestCase {
}

do {
// Use emit-module to link sil files.
// Use emit-module to build sil files.
var driver = try Driver(args: ["swiftc", "foo.sil", "bar.sil", "-module-name", "Test", "-emit-module-path", "/foo/bar/Test.swiftmodule", "-experimental-emit-module-separately", "-emit-library", "-target", "x86_64-apple-macosx10.15"])
let plannedJobs = try driver.planBuild()
XCTAssertEqual(plannedJobs.count, 4)
Expand Down

0 comments on commit 582e81a

Please sign in to comment.