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.
parent 5f091c46
......@@ -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()
......
......@@ -69,7 +69,8 @@ $(document).ready(function(){initNavTree('md__compiler.html','');});
<li><code>-I PATH</code> : when encountering <code>include</code> 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.</li>
<li><code>--strict-json</code> : Require &amp; 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.</li>
<li><code>--no-prefix</code> : Don't prefix enum values in generated C++ by their enum type.</li>
<li><code>--gen-includes</code> : Generate include statements for included schemas the generated file depends on (C++).</li>
<li><code>--gen-includes</code> : (deprecated), instead use:</li>
<li><code>--no-includes</code> : Don't generate include statements for included schemas the generated file depends on (C++).</li>
<li><code>--gen-mutable</code> : Generate additional non-const accessors for mutating FlatBuffers in-place.</li>
<li><code>--raw-binary</code> : Allow binaries without a file_indentifier to be read. This may crash flatc given a mismatched schema.</li>
<li><code>--proto</code>: Expect input files to be .proto files (protocol buffers). Output the corresponding .fbs file. Currently supports: <code>package</code>, <code>message</code>, <code>enum</code>. Does not support, but will skip without error: <code>import</code>, <code>option</code>. Does not support, will generate error: <code>service</code>, <code>extend</code>, <code>extensions</code>, <code>oneof</code>, <code>group</code>, custom options, nested declarations. </li>
......
......@@ -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
......
......@@ -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) {}
};
......
......@@ -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.
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment