Skip to content

Commit 97c9ec7

Browse files
authored
Merge pull request #813 from xymus/library-level
Make `-library-level` a driver argument and pass it to the frontend
2 parents 9636cc0 + f61904c commit 97c9ec7

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ extension Driver {
193193
try commandLine.appendLast(.localizationPath, from: &parsedOptions)
194194
try commandLine.appendLast(.requireExplicitAvailability, from: &parsedOptions)
195195
try commandLine.appendLast(.requireExplicitAvailabilityTarget, from: &parsedOptions)
196+
try commandLine.appendLast(.libraryLevel, from: &parsedOptions)
196197
try commandLine.appendLast(.lto, from: &parsedOptions)
197198
try commandLine.appendLast(.accessNotesPath, from: &parsedOptions)
198199
try commandLine.appendLast(.enableActorDataRaceChecks, .disableActorDataRaceChecks, from: &parsedOptions)

Sources/SwiftOptions/Options.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ extension Option {
377377
public static let j: Option = Option("-j", .joinedOrSeparate, attributes: [.doesNotAffectIncrementalBuild], metaVar: "<n>", helpText: "Number of commands to execute in parallel")
378378
public static let LEQ: Option = Option("-L=", .joined, alias: Option.L, attributes: [.frontend, .doesNotAffectIncrementalBuild, .argumentIsPath], group: .linkerOption)
379379
public static let libc: Option = Option("-libc", .separate, helpText: "libc runtime library to use")
380-
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)")
380+
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)")
381381
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)
382382
public static let linkObjcRuntime: Option = Option("-link-objc-runtime", .flag, attributes: [.doesNotAffectIncrementalBuild])
383383
public static let lldbRepl: Option = Option("-lldb-repl", .flag, attributes: [.helpHidden, .noBatch], helpText: "LLDB-enhanced REPL mode", group: .modes)

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4881,6 +4881,15 @@ final class SwiftDriverTests: XCTestCase {
48814881
}
48824882
}
48834883

4884+
func testLibraryLevel() throws {
4885+
do {
4886+
var driver = try Driver(args: ["swiftc", "-library-level", "spi", "foo.swift"])
4887+
let plannedJobs = try driver.planBuild()
4888+
let job = plannedJobs[0]
4889+
XCTAssertTrue(job.commandLine.contains(subsequence: [.flag("-library-level"), .flag("spi")]))
4890+
}
4891+
}
4892+
48844893
func testRelativeResourceDir() throws {
48854894
do {
48864895
var driver = try Driver(args: ["swiftc",

0 commit comments

Comments
 (0)