Add frontend mode -build-module-from-parseable-interface

Makes it easier to test the caching behavior, and may also be useful
for "prebuilding" swiftinterfaces in the future, or having the Driver
kick off a bunch of separate builds as proper tasks.
This commit is contained in:
Jordan Rose
2018-12-13 11:17:31 -08:00
parent 13c8a75da5
commit 37708ede6e
9 changed files with 80 additions and 6 deletions

View File

@@ -559,6 +559,17 @@ static bool precompileBridgingHeader(CompilerInvocation &Invocation,
.InputsAndOutputs.getSingleOutputFilename());
}
static bool buildModuleFromParseableInterface(CompilerInvocation &Invocation,
CompilerInstance &Instance) {
const auto &InputsAndOutputs =
Invocation.getFrontendOptions().InputsAndOutputs;
assert(InputsAndOutputs.hasSingleInput());
StringRef InputPath = InputsAndOutputs.getFilenameOfFirstInput();
return ParseableInterfaceModuleLoader::buildSwiftModuleFromSwiftInterface(
Instance.getASTContext(), Invocation.getClangModuleCachePath(),
Invocation.getModuleName(), InputPath, Invocation.getOutputFilename());
}
static bool compileLLVMIR(CompilerInvocation &Invocation,
CompilerInstance &Instance,
UnifiedStatsReporter *Stats) {
@@ -923,6 +934,9 @@ static bool performCompile(CompilerInstance &Instance,
if (Action == FrontendOptions::ActionType::EmitPCH)
return precompileBridgingHeader(Invocation, Instance);
if (Action == FrontendOptions::ActionType::BuildModuleFromParseableInterface)
return buildModuleFromParseableInterface(Invocation, Instance);
if (Invocation.getInputKind() == InputFileKind::LLVM)
return compileLLVMIR(Invocation, Instance, Stats);