Added --gen-all to generate code for a schema and all its includes.

Also refactored the way options are stored.

Change-Id: I709ac908cd2aba396c9c282725cf1d42ccce0882
Tested: on Linux.
This commit is contained in:
Wouter van Oortmerssen
2015-11-30 17:42:19 -08:00
parent 47478117d8
commit 45bda6e08d
15 changed files with 240 additions and 268 deletions

View File

@@ -52,8 +52,7 @@ static void GenNameSpace(const Namespace &name_space, std::string *_schema,
}
// Generate a flatbuffer schema from the Parser's internal representation.
std::string GenerateFBS(const Parser &parser, const std::string &file_name,
const GeneratorOptions &opts) {
std::string GenerateFBS(const Parser &parser, const std::string &file_name) {
// Proto namespaces may clash with table names, so we have to prefix all:
for (auto it = parser.namespaces_.begin(); it != parser.namespaces_.end();
++it) {
@@ -65,7 +64,7 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name,
std::string schema;
schema += "// Generated from " + file_name + ".proto\n\n";
if (opts.include_dependence_headers) {
if (parser.opts.include_dependence_headers) {
#ifdef FBS_GEN_INCLUDES // TODO: currently all in one file.
int num_includes = 0;
for (auto it = parser.included_files_.begin();
@@ -120,10 +119,9 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name,
bool GenerateFBS(const Parser &parser,
const std::string &path,
const std::string &file_name,
const GeneratorOptions &opts) {
const std::string &file_name) {
return SaveFile((path + file_name + ".fbs").c_str(),
GenerateFBS(parser, file_name, opts), false);
GenerateFBS(parser, file_name), false);
}
} // namespace flatbuffers