mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 12:05:50 +00:00
Add Code Generator for idl_gen_fbs to parse .proto files (#7832)
* Add code generator for proto files * Update * Add --proto to script * Remove cmt * Move proto parsing logic into else block to share same set up logic for code_generator * Remove IsValidCodeGenerator
This commit is contained in:
@@ -166,7 +166,6 @@ const static FlatCOption flatc_options[] = {
|
||||
"Allow binaries without file_identifier to be read. This may crash flatc "
|
||||
"given a mismatched schema." },
|
||||
{ "", "size-prefixed", "", "Input binaries are size prefixed buffers." },
|
||||
{ "", "proto", "", "Input is a .proto, translate to .fbs." },
|
||||
{ "", "proto-namespace-suffix", "SUFFIX",
|
||||
"Add this namespace to any flatbuffers generated from protobufs." },
|
||||
{ "", "oneof-union", "", "Translate .proto oneofs to flatbuffer unions." },
|
||||
@@ -243,7 +242,7 @@ const static FlatCOption flatc_options[] = {
|
||||
"ts_entry_points." },
|
||||
{ "", "ts-entry-points", "",
|
||||
"Generate entry point typescript per namespace. Implies gen-all." },
|
||||
{ "", "annotate-sparse-vectors", "", "Don't annotate every vector element."},
|
||||
{ "", "annotate-sparse-vectors", "", "Don't annotate every vector element." },
|
||||
{ "", "annotate", "SCHEMA",
|
||||
"Annotate the provided BINARY_FILE with the specified SCHEMA file." },
|
||||
{ "", "no-leak-private-annotation", "",
|
||||
@@ -548,8 +547,6 @@ FlatCOptions FlatCompiler::ParseFromCommandLineArguments(int argc,
|
||||
opts.size_prefixed = true;
|
||||
} else if (arg == "--") { // Separator between text and binary inputs.
|
||||
options.binary_files_from = options.filenames.size();
|
||||
} else if (arg == "--proto") {
|
||||
opts.proto_mode = true;
|
||||
} else if (arg == "--proto-namespace-suffix") {
|
||||
if (++argi >= argc) Error("missing namespace suffix" + arg, true);
|
||||
opts.proto_namespace_suffix = argv[argi];
|
||||
@@ -647,12 +644,13 @@ FlatCOptions FlatCompiler::ParseFromCommandLineArguments(int argc,
|
||||
} else if (arg == "--no-leak-private-annotation") {
|
||||
opts.no_leak_private_annotations = true;
|
||||
} else if (arg == "--annotate-sparse-vectors") {
|
||||
options.annotate_include_vector_contents = false;
|
||||
options.annotate_include_vector_contents = false;
|
||||
} else if (arg == "--annotate") {
|
||||
if (++argi >= argc) Error("missing path following: " + arg, true);
|
||||
options.annotate_schema = flatbuffers::PosixPath(argv[argi]);
|
||||
} else {
|
||||
// Look up if the command line argument refers to a code generator.
|
||||
if (arg == "--proto") { opts.proto_mode = true; }
|
||||
|
||||
auto code_generator_it = code_generators_.find(arg);
|
||||
if (code_generator_it == code_generators_.end()) {
|
||||
Error("unknown commandline argument: " + arg, true);
|
||||
@@ -888,8 +886,6 @@ std::unique_ptr<Parser> FlatCompiler::GenerateCode(const FlatCOptions &options,
|
||||
Error("root type must be a table");
|
||||
}
|
||||
|
||||
if (opts.proto_mode) GenerateFBS(*parser, options.output_path, filebase);
|
||||
|
||||
// We do not want to generate code for the definitions in this file
|
||||
// in any files coming up next.
|
||||
parser->MarkGenerated();
|
||||
|
||||
Reference in New Issue
Block a user