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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ public struct Driver {
/// Path to the Swift interface file.
let swiftInterfacePath: VirtualPath?

/// Path to the Swift private interface file.
let swiftPrivateInterfacePath: VirtualPath?

/// Path to the optimization record.
let optimizationRecordPath: VirtualPath?

Expand Down Expand Up @@ -521,6 +524,14 @@ public struct Driver {
outputFileMap: self.outputFileMap,
moduleName: moduleOutputInfo.name)

self.swiftPrivateInterfacePath = try Self.computeSupplementaryOutputPath(
&parsedOptions, type: .privateSwiftInterface, isOutputOptions: [],
outputPath: .emitPrivateModuleInterfacePath,
compilerOutputType: compilerOutputType,
compilerMode: compilerMode,
outputFileMap: self.outputFileMap,
moduleName: moduleOutputInfo.name)

var optimizationRecordFileType = FileType.yamlOptimizationRecord
if let argument = parsedOptions.getLastArgument(.saveOptimizationRecordEQ)?.asSingle {
switch argument {
Expand Down Expand Up @@ -1576,7 +1587,8 @@ extension Driver {
moduleOutputKind = .auxiliary
} else if compilerMode != .singleCompile &&
parsedOptions.hasArgument(.emitObjcHeader, .emitObjcHeaderPath,
.emitModuleInterface, .emitModuleInterfacePath) {
.emitModuleInterface, .emitModuleInterfacePath,
.emitPrivateModuleInterfacePath) {
// An option has been passed which requires whole-module knowledge, but we
// don't have that. Generate a module, but treat it as an intermediate
// output.
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/EmitModuleJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extension Driver {
addSupplementalOutput(path: moduleDocOutputPath, flag: "-emit-module-doc-path", type: .swiftDocumentation)
addSupplementalOutput(path: moduleSourceInfoPath, flag: "-emit-module-source-info-path", type: .swiftSourceInfoFile)
addSupplementalOutput(path: swiftInterfacePath, flag: "-emit-module-interface-path", type: .swiftInterface)
addSupplementalOutput(path: swiftPrivateInterfacePath, flag: "-emit-private-module-interface-path", type: .privateSwiftInterface)
addSupplementalOutput(path: objcGeneratedHeaderPath, flag: "-emit-objc-header-path", type: .objcHeader)
addSupplementalOutput(path: tbdPath, flag: "-emit-tbd-path", type: .tbd)

Expand Down
6 changes: 6 additions & 0 deletions Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ extension Driver {
input: nil,
flag: "-emit-module-interface-path")

addOutputOfType(
outputType: .privateSwiftInterface,
finalOutputPath: swiftPrivateInterfacePath,
input: nil,
flag: "-emit-private-module-interface-path")

addOutputOfType(
outputType: .tbd,
finalOutputPath: tbdPath,
Expand Down
6 changes: 4 additions & 2 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1376,16 +1376,18 @@ final class SwiftDriverTests: XCTestCase {
}

func testSingleThreadedWholeModuleOptimizationCompiles() throws {
var driver1 = try Driver(args: ["swiftc", "-whole-module-optimization", "foo.swift", "bar.swift", "-module-name", "Test", "-target", "x86_64-apple-macosx10.15", "-emit-module-interface", "-emit-objc-header-path", "Test-Swift.h"])
var driver1 = try Driver(args: ["swiftc", "-whole-module-optimization", "foo.swift", "bar.swift", "-module-name", "Test", "-target", "x86_64-apple-macosx10.15", "-emit-module-interface", "-emit-objc-header-path", "Test-Swift.h", "-emit-private-module-interface-path", "Test.private.swiftinterface"])
let plannedJobs = try driver1.planBuild()
XCTAssertEqual(plannedJobs.count, 2)
XCTAssertEqual(plannedJobs[0].kind, .compile)
XCTAssertEqual(plannedJobs[0].outputs.count, 3)
XCTAssertEqual(plannedJobs[0].outputs.count, 4)
XCTAssertEqual(plannedJobs[0].outputs[0].file, VirtualPath.temporary(RelativePath("Test.o")))
XCTAssertEqual(plannedJobs[0].outputs[1].file, VirtualPath.relative(RelativePath("Test-Swift.h")))
XCTAssertEqual(plannedJobs[0].outputs[2].file, VirtualPath.relative(RelativePath("Test.swiftinterface")))
XCTAssertEqual(plannedJobs[0].outputs[3].file, VirtualPath.relative(RelativePath("Test.private.swiftinterface")))
XCTAssert(!plannedJobs[0].commandLine.contains(.flag("-primary-file")))
XCTAssert(plannedJobs[0].commandLine.contains(.flag("-emit-module-interface-path")))
XCTAssert(plannedJobs[0].commandLine.contains(.flag("-emit-private-module-interface-path")))

XCTAssertEqual(plannedJobs[1].kind, .link)
}
Expand Down