Skip to content

Pass down -public-module-name to the frontend #1699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ extension Driver {
commandLine.appendFlag(ver)
}

if isFrontendArgSupported(.publicModuleName) {
try commandLine.appendLast(.publicModuleName, from: &parsedOptions)
}

// Pass down -validate-clang-modules-once if we are working with a compiler that
// supports it.
if isFrontendArgSupported(.validateClangModulesOnce),
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftOptions/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ extension Option {
public static let protocolRequirementAllowList: Option = Option("-protocol-requirement-allow-list", .separate, attributes: [.noDriver, .argumentIsPath], metaVar: "<path>", helpText: "File containing a new-line separated list of protocol names")
public static let protocolRequirementAllowList_: Option = Option("--protocol-requirement-allow-list", .separate, alias: Option.protocolRequirementAllowList, attributes: [.noDriver, .argumentIsPath], metaVar: "<path>", helpText: "File containing a new-line separated list of protocol names")
public static let publicAutolinkLibrary: Option = Option("-public-autolink-library", .separate, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Add public dependent library")
public static let publicModuleName: Option = Option("-public-module-name", .separate, attributes: [.frontend], helpText: "Public facing module name to use in diagnostics and documentation")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A reminder that Options.swift is to be generated according to the following procedure:
https://github.com/swiftlang/swift-driver?tab=readme-ov-file#rebuilding-optionsswift
In case it wasn't already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was but I committed only the relevant lines.

public static let RaccessNoteEQ: Option = Option("-Raccess-note=", .joined, alias: Option.RaccessNote, attributes: [.frontend, .noDriver])
public static let RaccessNote: Option = Option("-Raccess-note", .separate, attributes: [.frontend, .noDriver], metaVar: "none|failures|all|all-validate", helpText: "Control access note remarks (default: all)")
public static let cacheRemarks: Option = Option("-Rcache-compile-job", .flag, attributes: [.frontend, .cacheInvariant], helpText: "Show remarks for compiler caching")
Expand Down Expand Up @@ -1581,6 +1582,7 @@ extension Option {
Option.protocolRequirementAllowList,
Option.protocolRequirementAllowList_,
Option.publicAutolinkLibrary,
Option.publicModuleName,
Option.RaccessNoteEQ,
Option.RaccessNote,
Option.cacheRemarks,
Expand Down
16 changes: 16 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,22 @@ final class SwiftDriverTests: XCTestCase {
XCTAssert(compileJob.commandLine.contains(.flag("ABIMod")))
}

func testPublicModuleName() throws {
var driver = try Driver(
args: ["swiftc", "foo.swift", "-public-module-name", "PublicFacing"]
)
let jobs = try driver.planBuild()
let compileJob = try jobs.findJob(.compile)

if driver.isFrontendArgSupported(.publicModuleName) {
XCTAssert(compileJob.commandLine.contains(.flag("-public-module-name")))
XCTAssert(compileJob.commandLine.contains(.flag("PublicFacing")))
} else {
XCTAssertFalse(compileJob.commandLine.contains(.flag("-public-module-name")))
XCTAssertFalse(compileJob.commandLine.contains(.flag("PublicFacing")))
}
}

func testStandardCompileJobs() throws {
var driver1 = try Driver(args: ["swiftc", "foo.swift", "bar.swift", "-module-name", "Test"])
let plannedJobs = try driver1.planBuild().removingAutolinkExtractJobs()
Expand Down