From 63b526db52d562b45c64f1dc6b8185fe8c42c19e Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Fri, 8 Jan 2016 11:39:56 -0800 Subject: [PATCH] Ensured code is not generated directly from .proto files. The parser state generated from the .proto conversion process is not exactly the same as what you get by parsing the generated schema, which can cause problems. This check enforces that you first convert the .proto, then generate code from the new schema. Change-Id: I04b53af9288d87e256d1cc109388332fefb3a09f Tested: on Linux. --- src/flatc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/flatc.cpp b/src/flatc.cpp index 48d98ce41..97ee79386 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -183,7 +183,6 @@ int main(int argc, const char *argv[]) { binary_files_from = filenames.size(); } else if(arg == "--proto") { opts.proto_mode = true; - any_generator = true; } else if(arg == "--schema") { schema_binary = true; } else if(arg == "-M") { @@ -208,8 +207,12 @@ int main(int argc, const char *argv[]) { if (!filenames.size()) Error("missing input files", false, true); - if (!any_generator) + if (opts.proto_mode) { + if (any_generator) + Error("cannot generate code directly from .proto files", true); + } else if (!any_generator) { Error("no options: specify at least one generator.", true); + } // Now process the files: parser = new flatbuffers::Parser(opts);