Skip to content

Make -library-level a driver argument and pass it to the frontend #813

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
Aug 30, 2021
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
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ extension Driver {
try commandLine.appendLast(.localizationPath, from: &parsedOptions)
try commandLine.appendLast(.requireExplicitAvailability, from: &parsedOptions)
try commandLine.appendLast(.requireExplicitAvailabilityTarget, from: &parsedOptions)
try commandLine.appendLast(.libraryLevel, from: &parsedOptions)
try commandLine.appendLast(.lto, from: &parsedOptions)
try commandLine.appendLast(.accessNotesPath, from: &parsedOptions)
try commandLine.appendLast(.enableActorDataRaceChecks, .disableActorDataRaceChecks, from: &parsedOptions)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftOptions/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ extension Option {
public static let j: Option = Option("-j", .joinedOrSeparate, attributes: [.doesNotAffectIncrementalBuild], metaVar: "<n>", helpText: "Number of commands to execute in parallel")
public static let LEQ: Option = Option("-L=", .joined, alias: Option.L, attributes: [.frontend, .doesNotAffectIncrementalBuild, .argumentIsPath], group: .linkerOption)
public static let libc: Option = Option("-libc", .separate, helpText: "libc runtime library to use")
public static let libraryLevel: Option = Option("-library-level", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "<level>", helpText: "Library distribution level 'api', 'spi' or 'other' (the default)")
public static let libraryLevel: Option = Option("-library-level", .separate, attributes: [.helpHidden, .frontend, .moduleInterface], metaVar: "<level>", helpText: "Library distribution level 'api', 'spi' or 'other' (the default)")
Copy link
Contributor

Choose a reason for hiding this comment

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

This file is auto generated, did you make this change manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I generated it from a yet-to-land similar change on the compiler side. I think I have to merge this one first as the compiler change will end up testing this driver change.

public static let lineRange: Option = Option("-line-range", .separate, attributes: [.noInteractive, .noBatch, .indent], metaVar: "<n:n>", helpText: "<start line>:<end line>. Formats a range of lines (1-based). Can only be used with one input file.", group: .codeFormatting)
public static let linkObjcRuntime: Option = Option("-link-objc-runtime", .flag, attributes: [.doesNotAffectIncrementalBuild])
public static let lldbRepl: Option = Option("-lldb-repl", .flag, attributes: [.helpHidden, .noBatch], helpText: "LLDB-enhanced REPL mode", group: .modes)
Expand Down
9 changes: 9 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4853,6 +4853,15 @@ final class SwiftDriverTests: XCTestCase {
}
}

func testLibraryLevel() throws {
do {
var driver = try Driver(args: ["swiftc", "-library-level", "spi", "foo.swift"])
let plannedJobs = try driver.planBuild()
let job = plannedJobs[0]
XCTAssertTrue(job.commandLine.contains(subsequence: [.flag("-library-level"), .flag("spi")]))
}
}

func testRelativeResourceDir() throws {
do {
var driver = try Driver(args: ["swiftc",
Expand Down