mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/main' into rebranch
This commit is contained in:
@@ -809,6 +809,34 @@ static bool writeTBDIfNeeded(CompilerInstance &Instance) {
|
||||
Instance.getOutputBackend(), tbdOpts);
|
||||
}
|
||||
|
||||
static bool writeAPIDescriptor(ModuleDecl *M, StringRef OutputPath,
|
||||
llvm::vfs::OutputBackend &Backend) {
|
||||
return withOutputPath(M->getDiags(), Backend, OutputPath,
|
||||
[&](raw_ostream &OS) -> bool {
|
||||
writeAPIJSONFile(M, OS, /*PrettyPrinted=*/false);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
static bool writeAPIDescriptorIfNeeded(CompilerInstance &Instance) {
|
||||
const auto &Invocation = Instance.getInvocation();
|
||||
const auto &frontendOpts = Invocation.getFrontendOptions();
|
||||
if (!frontendOpts.InputsAndOutputs.hasAPIDescriptorOutputPath())
|
||||
return false;
|
||||
|
||||
if (!frontendOpts.InputsAndOutputs.isWholeModule()) {
|
||||
Instance.getDiags().diagnose(
|
||||
SourceLoc(), diag::api_descriptor_only_supported_in_whole_module);
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string &APIDescriptorPath =
|
||||
Invocation.getAPIDescriptorPathForWholeModule();
|
||||
|
||||
return writeAPIDescriptor(Instance.getMainModule(), APIDescriptorPath,
|
||||
Instance.getOutputBackend());
|
||||
}
|
||||
|
||||
static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
|
||||
std::unique_ptr<SILModule> SM,
|
||||
ModuleOrSourceFile MSF,
|
||||
@@ -975,6 +1003,10 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
|
||||
hadAnyError |= writeTBDIfNeeded(Instance);
|
||||
}
|
||||
|
||||
{
|
||||
hadAnyError |= writeAPIDescriptorIfNeeded(Instance);
|
||||
}
|
||||
|
||||
{
|
||||
hadAnyError |= writeModuleSemanticInfoIfNeeded(Instance);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user