Skip to content

Commit d467d32

Browse files
committed
Make -check-api-availability-only a driver flag and don't pass to verification jobs
Promote the flag -check-api-availability-only to a driver flag. Pass it down to all compilation jobs except swiftinterface verification. rdar://84680002
1 parent 2aeeb0c commit d467d32

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

Sources/SwiftDriver/Jobs/CompileJob.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ extension Driver {
348348
try commandLine.appendLast(.runtimeCompatibilityVersion, from: &parsedOptions)
349349
try commandLine.appendLast(.disableAutolinkingRuntimeCompatibilityDynamicReplacements, from: &parsedOptions)
350350
try commandLine.appendLast(.disableAutolinkingRuntimeCompatibilityConcurrency, from: &parsedOptions)
351+
try commandLine.appendLast(.checkApiAvailabilityOnly, from: &parsedOptions)
351352

352353
if compilerMode.isSingleCompilation {
353354
try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)

Sources/SwiftDriver/Jobs/EmitModuleJob.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extension Driver {
8484

8585
try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)
8686
try commandLine.appendLast(.emitSymbolGraphDir, from: &parsedOptions)
87+
try commandLine.appendLast(.checkApiAvailabilityOnly, from: &parsedOptions)
8788

8889
if parsedOptions.hasArgument(.parseAsLibrary, .emitLibrary) {
8990
commandLine.appendFlag(.parseAsLibrary)

Sources/SwiftOptions/Options.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extension Option {
4848
public static let buildModuleFromParseableInterface: Option = Option("-build-module-from-parseable-interface", .flag, alias: Option.compileModuleFromInterface, attributes: [.helpHidden, .frontend, .noDriver], group: .modes)
4949
public static let bypassBatchModeChecks: Option = Option("-bypass-batch-mode-checks", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Bypass checks for batch-mode errors.")
5050
public static let candidateModuleFile: Option = Option("-candidate-module-file", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "<path>", helpText: "Specify Swift module may be ready to use for an interface")
51-
public static let checkApiAvailabilityOnly: Option = Option("-check-api-availability-only", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Only check the availability of the APIs, ignore function bodies")
51+
public static let checkApiAvailabilityOnly: Option = Option("-check-api-availability-only", .flag, attributes: [.helpHidden, .frontend, .noInteractive], helpText: "Only check the availability of the APIs, ignore function bodies")
5252
public static let checkOnoneCompleteness: Option = Option("-check-onone-completeness", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Print errors if the compile OnoneSupport module is missing symbols")
5353
public static let clangTarget: Option = Option("-clang-target", .separate, attributes: [.frontend], helpText: "Separately set the target we should use for internal Clang instance")
5454
public static let codeCompleteCallPatternHeuristics: Option = Option("-code-complete-call-pattern-heuristics", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Use heuristics to guess whether we want call pattern completions")

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4282,6 +4282,23 @@ final class SwiftDriverTests: XCTestCase {
42824282
XCTAssertEqual(plannedJobs.count, 1)
42834283
XCTAssertEqual(plannedJobs[0].kind, .compile)
42844284
}
4285+
4286+
// The flag -check-api-availability-only is not passed down to the verify job.
4287+
do {
4288+
var driver = try Driver(args: ["swiftc", "foo.swift", "-emit-module", "-module-name",
4289+
"foo", "-emit-module-interface",
4290+
"-verify-emitted-module-interface",
4291+
"-enable-library-evolution",
4292+
"-check-api-availability-only"])
4293+
let plannedJobs = try driver.planBuild()
4294+
XCTAssertEqual(plannedJobs.count, 2)
4295+
4296+
let emitJob = plannedJobs.first(where: { $0.kind == .emitModule })!
4297+
XCTAssertTrue(emitJob.commandLine.contains(.flag("-check-api-availability-only")))
4298+
4299+
let verifyJob = plannedJobs.first(where: { $0.kind == .verifyModuleInterface })!
4300+
XCTAssertFalse(verifyJob.commandLine.contains(.flag("-check-api-availability-only")))
4301+
}
42854302
}
42864303

42874304
func testPCHGeneration() throws {

0 commit comments

Comments
 (0)