Skip to content

Commit b921b97

Browse files
authored
Merge pull request #1426 from tshortli/consolidate-adding-symbol-graph-option
NFC: Consolidate the code for adding symbol graph related options to a job
2 parents 3022752 + 78b7be5 commit b921b97

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

Sources/SwiftDriver/Jobs/CompileJob.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,8 @@ extension Driver {
372372
try commandLine.appendLast(.disableAutolinkingRuntimeCompatibilityConcurrency, from: &parsedOptions)
373373
try commandLine.appendLast(.checkApiAvailabilityOnly, from: &parsedOptions)
374374

375-
if compilerMode.isSingleCompilation {
376-
try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)
377-
try commandLine.appendLast(.emitSymbolGraphDir, from: &parsedOptions)
378-
}
379-
try commandLine.appendLast(.includeSpiSymbols, from: &parsedOptions)
380-
try commandLine.appendLast(.emitExtensionBlockSymbols, .omitExtensionBlockSymbols, from: &parsedOptions)
381-
try commandLine.appendLast(.symbolGraphMinimumAccessLevel, from: &parsedOptions)
375+
try addCommonSymbolGraphOptions(commandLine: &commandLine,
376+
includeGraph: compilerMode.isSingleCompilation)
382377

383378
addJobOutputs(outputs)
384379

Sources/SwiftDriver/Jobs/EmitModuleJob.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,8 @@ extension Driver {
9999
// FIXME: Add MSVC runtime library flags
100100

101101
try addCommonModuleOptions(commandLine: &commandLine, outputs: &outputs, isMergeModule: false)
102+
try addCommonSymbolGraphOptions(commandLine: &commandLine)
102103

103-
try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)
104-
try commandLine.appendLast(.emitSymbolGraphDir, from: &parsedOptions)
105-
try commandLine.appendLast(.includeSpiSymbols, from: &parsedOptions)
106-
try commandLine.appendLast(.emitExtensionBlockSymbols, .omitExtensionBlockSymbols, from: &parsedOptions)
107-
try commandLine.appendLast(.symbolGraphMinimumAccessLevel, from: &parsedOptions)
108104
try commandLine.appendLast(.checkApiAvailabilityOnly, from: &parsedOptions)
109105
if isFrontendArgSupported(.experimentalLazyTypecheck) {
110106
try commandLine.appendLast(.experimentalLazyTypecheck, from: &parsedOptions)

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,17 @@ extension Driver {
648648
return flaggedInputOutputPairs.map { $0.output }
649649
}
650650

651+
mutating func addCommonSymbolGraphOptions(commandLine: inout [Job.ArgTemplate],
652+
includeGraph: Bool = true) throws {
653+
if includeGraph {
654+
try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)
655+
try commandLine.appendLast(.emitSymbolGraphDir, from: &parsedOptions)
656+
}
657+
try commandLine.appendLast(.includeSpiSymbols, from: &parsedOptions)
658+
try commandLine.appendLast(.emitExtensionBlockSymbols, .omitExtensionBlockSymbols, from: &parsedOptions)
659+
try commandLine.appendLast(.symbolGraphMinimumAccessLevel, from: &parsedOptions)
660+
}
661+
651662
func addEntry(_ entries: inout [VirtualPath.Handle: [FileType: VirtualPath.Handle]], input: TypedVirtualPath?, output: TypedVirtualPath) {
652663
let entryInput: VirtualPath.Handle
653664
if let input = input?.fileHandle, input != OutputFileMap.singleInputKey {

Sources/SwiftDriver/Jobs/MergeModuleJob.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ extension Driver {
5959

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

62-
try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)
63-
try commandLine.appendLast(.emitSymbolGraphDir, from: &parsedOptions)
64-
try commandLine.appendLast(.includeSpiSymbols, from: &parsedOptions)
65-
try commandLine.appendLast(.emitExtensionBlockSymbols, .omitExtensionBlockSymbols, from: &parsedOptions)
66-
try commandLine.appendLast(.symbolGraphMinimumAccessLevel, from: &parsedOptions)
62+
try addCommonSymbolGraphOptions(commandLine: &commandLine)
6763

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

0 commit comments

Comments
 (0)