Skip to content

Commit 06deecd

Browse files
committed
Move importedObjCHeader code back into addCommonFrontendOptions
1 parent ddbb4f6 commit 06deecd

File tree

5 files changed

+19
-33
lines changed

5 files changed

+19
-33
lines changed

Sources/SwiftDriver/Jobs/CompileJob.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,6 @@ extension Driver {
103103
try addCommonFrontendOptions(commandLine: &commandLine)
104104
// FIXME: MSVC runtime flags
105105

106-
if let importedObjCHeader = importedObjCHeader {
107-
commandLine.appendFlag(.importObjcHeader)
108-
if let pch = bridgingPrecompiledHeader {
109-
if parsedOptions.contains(.pchOutputDir) {
110-
commandLine.appendPath(importedObjCHeader)
111-
if compilerMode != .singleCompile {
112-
commandLine.appendFlag(.pchDisableValidation)
113-
}
114-
} else {
115-
commandLine.appendPath(pch)
116-
}
117-
} else {
118-
commandLine.appendPath(importedObjCHeader)
119-
}
120-
}
121-
122106
if parsedOptions.hasArgument(.parseAsLibrary, .emitLibrary) {
123107
commandLine.appendFlag(.parseAsLibrary)
124108
}

Sources/SwiftDriver/Jobs/EmitModuleJob.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ extension Driver {
6262

6363
try addCommonFrontendOptions(commandLine: &commandLine)
6464
// FIXME: Add MSVC runtime library flags
65-
66-
if let importedObjCHeader = importedObjCHeader {
67-
commandLine.appendFlag(.importObjcHeader)
68-
commandLine.appendPath(importedObjCHeader)
69-
}
7065

7166
try addCommonModuleOptions(commandLine: &commandLine, outputs: &outputs)
7267

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ fileprivate func shouldColorDiagnostics() -> Bool {
2222

2323
extension Driver {
2424
/// Add frontend options that are common to different frontend invocations.
25-
mutating func addCommonFrontendOptions(commandLine: inout [Job.ArgTemplate]) throws {
25+
mutating func addCommonFrontendOptions(commandLine: inout [Job.ArgTemplate],
26+
requestPrecompiledObjCHeader: Bool = true) throws {
2627
// Only pass -target to the REPL or immediate modes if it was explicitly
2728
// specified on the command line.
2829
switch compilerMode {
@@ -154,6 +155,22 @@ extension Driver {
154155
// Pass through any subsystem flags.
155156
try commandLine.appendAll(.Xllvm, from: &parsedOptions)
156157
try commandLine.appendAll(.Xcc, from: &parsedOptions)
158+
159+
if let importedObjCHeader = importedObjCHeader {
160+
commandLine.appendFlag(.importObjcHeader)
161+
if requestPrecompiledObjCHeader, let pch = bridgingPrecompiledHeader {
162+
if parsedOptions.contains(.pchOutputDir) {
163+
commandLine.appendPath(importedObjCHeader)
164+
if compilerMode != .singleCompile {
165+
commandLine.appendFlag(.pchDisableValidation)
166+
}
167+
} else {
168+
commandLine.appendPath(pch)
169+
}
170+
} else {
171+
commandLine.appendPath(importedObjCHeader)
172+
}
173+
}
157174

158175
// Repl Jobs may include -module-name depending on the selected REPL (LLDB or integrated).
159176
if compilerMode != .repl {

Sources/SwiftDriver/Jobs/GeneratePCHJob.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ extension Driver {
2727

2828
outputs.append(output)
2929

30-
try addCommonFrontendOptions(commandLine: &commandLine)
31-
32-
if let importedObjCHeader = importedObjCHeader {
33-
commandLine.appendFlag(.importObjcHeader)
34-
commandLine.appendPath(importedObjCHeader)
35-
}
30+
try addCommonFrontendOptions(commandLine: &commandLine, requestPrecompiledObjCHeader: false)
3631

3732
try commandLine.appendLast(.indexStorePath, from: &parsedOptions)
3833

Sources/SwiftDriver/Jobs/MergeModuleJob.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ extension Driver {
4343

4444
try addCommonFrontendOptions(commandLine: &commandLine)
4545
// FIXME: Add MSVC runtime library flags
46-
47-
if let importedObjCHeader = importedObjCHeader {
48-
commandLine.appendFlag(.importObjcHeader)
49-
commandLine.appendPath(importedObjCHeader)
50-
}
5146

5247
try addCommonModuleOptions(commandLine: &commandLine, outputs: &outputs)
5348

0 commit comments

Comments
 (0)