mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 20:48:59 +00:00
Implement --file-names-only (#8788)
* flatc builds and seems to work, some of the extra targets are having linker errors * fix build system * pipeline failures * un-rename files * refactor to use unique_ptr * typo * rm make_unique, add comments * fix cmake --------- Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
This commit is contained in:
@@ -76,31 +76,6 @@ void FormatImports(std::stringstream& ss, const Imports& imports) {
|
||||
ss << "\n\n";
|
||||
}
|
||||
|
||||
bool SaveStub(const std::string& filename, const Imports& imports,
|
||||
const std::string& content) {
|
||||
std::stringstream ss;
|
||||
ss << "# Generated by the gRPC FlatBuffers compiler. DO NOT EDIT!\n"
|
||||
<< '\n'
|
||||
<< "from __future__ import annotations\n"
|
||||
<< '\n';
|
||||
FormatImports(ss, imports);
|
||||
ss << content << '\n';
|
||||
|
||||
EnsureDirExists(StripFileName(filename));
|
||||
return flatbuffers::SaveFile(filename.c_str(), ss.str(), false);
|
||||
}
|
||||
|
||||
bool SaveService(const std::string& filename, const Imports& imports,
|
||||
const std::string& content) {
|
||||
std::stringstream ss;
|
||||
ss << "# Generated by the gRPC FlatBuffers compiler. DO NOT EDIT!\n" << '\n';
|
||||
FormatImports(ss, imports);
|
||||
ss << content << '\n';
|
||||
|
||||
EnsureDirExists(StripFileName(filename));
|
||||
return flatbuffers::SaveFile(filename.c_str(), ss.str(), false);
|
||||
}
|
||||
|
||||
class BaseGenerator {
|
||||
protected:
|
||||
BaseGenerator(const Parser& parser, const Namer::Config& config,
|
||||
@@ -175,6 +150,20 @@ class StubGenerator : public BaseGenerator {
|
||||
}
|
||||
|
||||
private:
|
||||
bool SaveStub(const std::string& filename, const Imports& imports,
|
||||
const std::string& content) {
|
||||
std::stringstream ss;
|
||||
ss << "# Generated by the gRPC FlatBuffers compiler. DO NOT EDIT!\n"
|
||||
<< '\n'
|
||||
<< "from __future__ import annotations\n"
|
||||
<< '\n';
|
||||
FormatImports(ss, imports);
|
||||
ss << content << '\n';
|
||||
|
||||
EnsureDirExists(StripFileName(filename));
|
||||
return parser_.opts.file_saver->SaveFile(filename.c_str(), ss.str(), false);
|
||||
}
|
||||
|
||||
void Generate(std::stringstream& ss, const ServiceDef* service,
|
||||
Imports* imports) {
|
||||
imports->Import("grpc");
|
||||
@@ -293,6 +282,18 @@ class ServiceGenerator : public BaseGenerator {
|
||||
}
|
||||
|
||||
private:
|
||||
bool SaveService(const std::string& filename, const Imports& imports,
|
||||
const std::string& content) {
|
||||
std::stringstream ss;
|
||||
ss << "# Generated by the gRPC FlatBuffers compiler. DO NOT EDIT!\n"
|
||||
<< '\n';
|
||||
FormatImports(ss, imports);
|
||||
ss << content << '\n';
|
||||
|
||||
EnsureDirExists(StripFileName(filename));
|
||||
return parser_.opts.file_saver->SaveFile(filename.c_str(), ss.str(), false);
|
||||
}
|
||||
|
||||
void GenerateStub(std::stringstream& ss, const ServiceDef* service,
|
||||
Imports* imports) {
|
||||
ss << "class " << service->name << "Stub";
|
||||
|
||||
Reference in New Issue
Block a user