From 1808337adcf93d6d2b244c6d86f3b0965cce10b1 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Mon, 15 Jun 2015 12:29:06 -0700 Subject: [PATCH] Make generating dependent include files for C++ the default. --gen-includes is now deprecate but still accepted. --no-includes can be used instead when needed. Change-Id: I2cd46d193032b9b7c31c76c6f655e9333d3a393a Tested: on Linux. --- CMakeLists.txt | 2 +- docs/html/md__compiler.html | 3 ++- docs/source/Compiler.md | 3 ++- include/flatbuffers/idl.h | 2 +- src/flatc.cpp | 10 +++++++--- tests/test.cpp | 1 + 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6a9704..b837b71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,7 @@ function(compile_flatbuffers_schema_to_cpp SRC_FBS) string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS}) add_custom_command( OUTPUT ${GEN_HEADER} - COMMAND flatc -c --gen-mutable -o "${SRC_FBS_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}" + COMMAND flatc -c --no-includes --gen-mutable -o "${SRC_FBS_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}" DEPENDS flatc) endfunction() diff --git a/docs/html/md__compiler.html b/docs/html/md__compiler.html index a372904..65ec451 100644 --- a/docs/html/md__compiler.html +++ b/docs/html/md__compiler.html @@ -69,7 +69,8 @@ $(document).ready(function(){initNavTree('md__compiler.html','');});
  • -I PATH : when encountering include statements, attempt to load the files from this path. Paths will be tried in the order given, and if all fail (or none are specified) it will try to load relative to the path of the schema file being parsed.
  • --strict-json : Require & generate strict JSON (field names are enclosed in quotes, no trailing commas in tables/vectors). By default, no quotes are required/generated, and trailing commas are allowed.
  • --no-prefix : Don't prefix enum values in generated C++ by their enum type.
  • -
  • --gen-includes : Generate include statements for included schemas the generated file depends on (C++).
  • +
  • --gen-includes : (deprecated), instead use:
  • +
  • --no-includes : Don't generate include statements for included schemas the generated file depends on (C++).
  • --gen-mutable : Generate additional non-const accessors for mutating FlatBuffers in-place.
  • --raw-binary : Allow binaries without a file_indentifier to be read. This may crash flatc given a mismatched schema.
  • --proto: Expect input files to be .proto files (protocol buffers). Output the corresponding .fbs file. Currently supports: package, message, enum. Does not support, but will skip without error: import, option. Does not support, will generate error: service, extend, extensions, oneof, group, custom options, nested declarations.
  • diff --git a/docs/source/Compiler.md b/docs/source/Compiler.md index 3ff89ed..31e2045 100755 --- a/docs/source/Compiler.md +++ b/docs/source/Compiler.md @@ -51,7 +51,8 @@ be generated for each file processed: - `--no-prefix` : Don't prefix enum values in generated C++ by their enum type. -- `--gen-includes` : Generate include statements for included schemas the +- `--gen-includes` : (deprecated), instead use: +- `--no-includes` : Don't generate include statements for included schemas the generated file depends on (C++). - `--gen-mutable` : Generate additional non-const accessors for mutating diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h index 2e9cfb5..9de893e 100644 --- a/include/flatbuffers/idl.h +++ b/include/flatbuffers/idl.h @@ -416,7 +416,7 @@ struct GeneratorOptions { output_default_scalars_in_json(false), indent_step(2), output_enum_identifiers(true), prefixed_enums(true), - include_dependence_headers(false), + include_dependence_headers(true), mutable_buffer(false), lang(GeneratorOptions::kJava) {} }; diff --git a/src/flatc.cpp b/src/flatc.cpp index 5eb0fda..7fe2cde 100755 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -90,8 +90,9 @@ static void Error(const std::string &err, bool usage, bool show_exe_name) { " --defaults-json Output fields whose value is the default when\n" " writing JSON\n" " --no-prefix Don\'t prefix enum values with the enum type in C++.\n" - " --gen-includes Generate include statements for included schemas the\n" - " generated file depends on (C++).\n" + " --gen-includes (deprecated), instead use:\n" + " --no-includes Don\'t generate include statements for included\n" + " schemas the generated file depends on (C++).\n" " --gen-mutable Generate accessors that can mutate buffers in-place.\n" " --raw-binary Allow binaries without file_indentifier to be read.\n" " This may crash flatc given a mismatched schema.\n" @@ -139,7 +140,10 @@ int main(int argc, const char *argv[]) { } else if(arg == "--gen-mutable") { opts.mutable_buffer = true; } else if(arg == "--gen-includes") { - opts.include_dependence_headers = true; + // Deprecated, remove this option some time in the future. + printf("warning: --gen-includes is deprecated (it is now default)\n"); + } else if(arg == "--no-includes") { + opts.include_dependence_headers = false; } else if(arg == "--raw-binary") { raw_binary = true; } else if(arg == "--") { // Separator between text and binary inputs. diff --git a/tests/test.cpp b/tests/test.cpp index dc80e71..0ed80f0 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -291,6 +291,7 @@ void ParseProtoTest() { // Generate fbs. flatbuffers::GeneratorOptions opts; + opts.include_dependence_headers = false; auto fbs = flatbuffers::GenerateFBS(parser, "test", opts); // Ensure generated file is parsable. -- 2.7.4