Skip to content
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

NFC: Consolidate the code for adding symbol graph related options to a job #1426

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 2 additions & 7 deletions Sources/SwiftDriver/Jobs/CompileJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,8 @@ extension Driver {
try commandLine.appendLast(.disableAutolinkingRuntimeCompatibilityConcurrency, from: &parsedOptions)
try commandLine.appendLast(.checkApiAvailabilityOnly, from: &parsedOptions)

if compilerMode.isSingleCompilation {
try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)
try commandLine.appendLast(.emitSymbolGraphDir, from: &parsedOptions)
}
try commandLine.appendLast(.includeSpiSymbols, from: &parsedOptions)
try commandLine.appendLast(.emitExtensionBlockSymbols, .omitExtensionBlockSymbols, from: &parsedOptions)
try commandLine.appendLast(.symbolGraphMinimumAccessLevel, from: &parsedOptions)
try addCommonSymbolGraphOptions(commandLine: &commandLine,
includeGraph: compilerMode.isSingleCompilation)

addJobOutputs(outputs)

Expand Down
6 changes: 1 addition & 5 deletions Sources/SwiftDriver/Jobs/EmitModuleJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,8 @@ extension Driver {
// FIXME: Add MSVC runtime library flags

try addCommonModuleOptions(commandLine: &commandLine, outputs: &outputs, isMergeModule: false)
try addCommonSymbolGraphOptions(commandLine: &commandLine)

try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)
try commandLine.appendLast(.emitSymbolGraphDir, from: &parsedOptions)
try commandLine.appendLast(.includeSpiSymbols, from: &parsedOptions)
try commandLine.appendLast(.emitExtensionBlockSymbols, .omitExtensionBlockSymbols, from: &parsedOptions)
try commandLine.appendLast(.symbolGraphMinimumAccessLevel, from: &parsedOptions)
try commandLine.appendLast(.checkApiAvailabilityOnly, from: &parsedOptions)
if isFrontendArgSupported(.experimentalLazyTypecheck) {
try commandLine.appendLast(.experimentalLazyTypecheck, from: &parsedOptions)
Expand Down
11 changes: 11 additions & 0 deletions Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,17 @@ extension Driver {
return flaggedInputOutputPairs.map { $0.output }
}

mutating func addCommonSymbolGraphOptions(commandLine: inout [Job.ArgTemplate],
includeGraph: Bool = true) throws {
if includeGraph {
try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)
try commandLine.appendLast(.emitSymbolGraphDir, from: &parsedOptions)
}
try commandLine.appendLast(.includeSpiSymbols, from: &parsedOptions)
try commandLine.appendLast(.emitExtensionBlockSymbols, .omitExtensionBlockSymbols, from: &parsedOptions)
try commandLine.appendLast(.symbolGraphMinimumAccessLevel, from: &parsedOptions)
}

func addEntry(_ entries: inout [VirtualPath.Handle: [FileType: VirtualPath.Handle]], input: TypedVirtualPath?, output: TypedVirtualPath) {
let entryInput: VirtualPath.Handle
if let input = input?.fileHandle, input != OutputFileMap.singleInputKey {
Expand Down
6 changes: 1 addition & 5 deletions Sources/SwiftDriver/Jobs/MergeModuleJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ extension Driver {

try addCommonModuleOptions(commandLine: &commandLine, outputs: &outputs, isMergeModule: true)

try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)
try commandLine.appendLast(.emitSymbolGraphDir, from: &parsedOptions)
try commandLine.appendLast(.includeSpiSymbols, from: &parsedOptions)
try commandLine.appendLast(.emitExtensionBlockSymbols, .omitExtensionBlockSymbols, from: &parsedOptions)
try commandLine.appendLast(.symbolGraphMinimumAccessLevel, from: &parsedOptions)
try addCommonSymbolGraphOptions(commandLine: &commandLine)

// Propagate the disable flag for cross-module incremental builds
// if necessary. Note because we're interested in *disabling* this feature,
Expand Down