Skip to content

Commit 7d56e79

Browse files
committed
Add -pch-output-directory driver flag and ClangImporter option
This will control the output path of a precompiled header (PCH) file generated from the bridging header. rdar://problem/31198711
1 parent 0328139 commit 7d56e79

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

include/swift/ClangImporter/ClangImporterOptions.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ class ClangImporterOptions {
3535
/// Equivalent to Clang's -mcpu=.
3636
std::string TargetCPU;
3737

38-
// The bridging header or PCH that will be imported.
38+
/// The bridging header or PCH that will be imported.
3939
std::string BridgingHeader;
4040

41+
/// When automatically generating a precompiled header from the bridging
42+
/// header, place it in this directory.
43+
std::string PrecompiledHeaderOutputDir;
44+
4145
/// \see Mode
4246
enum class Modes {
4347
/// Set up Clang for importing modules into Swift and generating IR from

include/swift/Option/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ def import_objc_header : Separate<["-"], "import-objc-header">,
166166
Flags<[FrontendOption, HelpHidden]>,
167167
HelpText<"Implicitly imports an Objective-C header file">;
168168

169+
def pch_output_dir: Separate<["-"], "pch-output-dir">,
170+
Flags<[FrontendOption, HelpHidden]>,
171+
HelpText<"Directory to persist automatically created precompiled bridging headers">;
172+
169173
// FIXME: Unhide this once it doesn't depend on an output file map.
170174
def incremental : Flag<["-"], "incremental">,
171175
Flags<[NoInteractiveOption, HelpHidden, DoesNotAffectIncrementalBuild]>,

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,10 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts,
10341034

10351035
Opts.DisableAdapterModules |= Args.hasArg(OPT_emit_imported_modules);
10361036

1037+
if (const Arg *A = Args.getLastArg(OPT_pch_output_dir)) {
1038+
Opts.PrecompiledHeaderOutputDir = A->getValue();
1039+
}
1040+
10371041
return false;
10381042
}
10391043

0 commit comments

Comments
 (0)