TBDGen: Don't emit pretty-printed API descriptor JSON by default.

Instead, use the `%validate-json` lit substitution to validate and format the
API descriptor file before running it through FileCheck. This allows us to
avoid needing to introduce a dedicated frontend option just to control whether
the output of -emit-api-descriptor is pretty printed.
This commit is contained in:
Allan Shortlidge
2023-10-05 11:33:14 -07:00
parent e91580bf0e
commit 778532dbdf
7 changed files with 15 additions and 11 deletions

View File

@@ -810,11 +810,10 @@ static bool writeTBDIfNeeded(CompilerInstance &Instance) {
}
static bool writeAPIDescriptor(ModuleDecl *M, StringRef OutputPath,
llvm::vfs::OutputBackend &Backend,
bool PrettyPrinted) {
llvm::vfs::OutputBackend &Backend) {
return withOutputPath(M->getDiags(), Backend, OutputPath,
[&](raw_ostream &OS) -> bool {
writeAPIJSONFile(M, OS, PrettyPrinted);
writeAPIJSONFile(M, OS, /*PrettyPrinted=*/false);
return false;
});
}
@@ -834,9 +833,8 @@ static bool writeAPIDescriptorIfNeeded(CompilerInstance &Instance) {
const std::string &APIDescriptorPath =
Invocation.getAPIDescriptorPathForWholeModule();
// FIXME: Need a frontend flag for pretty printing
return writeAPIDescriptor(Instance.getMainModule(), APIDescriptorPath,
Instance.getOutputBackend(), true);
Instance.getOutputBackend());
}
static bool performCompileStepsPostSILGen(CompilerInstance &Instance,