mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-01 20:03:58 +00:00
Added --prefix-include option for generated includes.
Change-Id: I288cda33345362f9aec5cbe309e590bf64f328e1 Tested: on Linux.
This commit is contained in:
@@ -118,5 +118,8 @@ Additional options:
|
|||||||
an evolution of. Gives errors if not. Useful to check if schema
|
an evolution of. Gives errors if not. Useful to check if schema
|
||||||
modifications don't break schema evolution rules.
|
modifications don't break schema evolution rules.
|
||||||
|
|
||||||
|
- `--include-prefix PATH` : Prefix this path to any generated include
|
||||||
|
statements.
|
||||||
|
|
||||||
NOTE: short-form options for generators are deprecated, use the long form
|
NOTE: short-form options for generators are deprecated, use the long form
|
||||||
whenever possible.
|
whenever possible.
|
||||||
|
|||||||
@@ -355,6 +355,7 @@ struct IDLOptions {
|
|||||||
std::string cpp_object_api_pointer_type;
|
std::string cpp_object_api_pointer_type;
|
||||||
bool union_value_namespacing;
|
bool union_value_namespacing;
|
||||||
bool allow_non_utf8;
|
bool allow_non_utf8;
|
||||||
|
std::string include_prefix;
|
||||||
|
|
||||||
// Possible options for the more general generator below.
|
// Possible options for the more general generator below.
|
||||||
enum Language {
|
enum Language {
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ std::string FlatCompiler::GetUsageString(const char* program_name) const {
|
|||||||
" an evolution of. Gives errors if not.\n"
|
" an evolution of. Gives errors if not.\n"
|
||||||
" --conform-includes Include path for the schema given with --conform\n"
|
" --conform-includes Include path for the schema given with --conform\n"
|
||||||
" PATH \n"
|
" PATH \n"
|
||||||
|
" --include-prefix Prefix this path to any generated include statements.\n"
|
||||||
|
" PATH\n"
|
||||||
"FILEs may be schemas, or JSON files (conforming to preceding schema)\n"
|
"FILEs may be schemas, or JSON files (conforming to preceding schema)\n"
|
||||||
"FILEs after the -- must be binary flatbuffer format files.\n"
|
"FILEs after the -- must be binary flatbuffer format files.\n"
|
||||||
"Output files are named using the base file name of the input,\n"
|
"Output files are named using the base file name of the input,\n"
|
||||||
@@ -142,6 +144,11 @@ int FlatCompiler::Compile(int argc, const char** argv) {
|
|||||||
} else if (arg == "--conform-includes") {
|
} else if (arg == "--conform-includes") {
|
||||||
if (++argi >= argc) Error("missing path following" + arg, true);
|
if (++argi >= argc) Error("missing path following" + arg, true);
|
||||||
conform_include_directories.push_back(argv[argi]);
|
conform_include_directories.push_back(argv[argi]);
|
||||||
|
} else if (arg == "--include-prefix") {
|
||||||
|
if (++argi >= argc) Error("missing path following" + arg, true);
|
||||||
|
opts.include_prefix = argv[argi];
|
||||||
|
if (opts.include_prefix.back() != '/' &&
|
||||||
|
opts.include_prefix.back() != '\\') opts.include_prefix += "/";
|
||||||
} else if(arg == "--strict-json") {
|
} else if(arg == "--strict-json") {
|
||||||
opts.strict_json = true;
|
opts.strict_json = true;
|
||||||
} else if(arg == "--allow-non-utf8") {
|
} else if(arg == "--allow-non-utf8") {
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ class CppGenerator : public BaseGenerator {
|
|||||||
const auto basename =
|
const auto basename =
|
||||||
flatbuffers::StripPath(flatbuffers::StripExtension(it->first));
|
flatbuffers::StripPath(flatbuffers::StripExtension(it->first));
|
||||||
if (basename != file_name_) {
|
if (basename != file_name_) {
|
||||||
code_ += "#include \"" + basename + "_generated.h\"";
|
code_ += "#include \"" + parser_.opts.include_prefix + basename +
|
||||||
|
"_generated.h\"";
|
||||||
num_includes++;
|
num_includes++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user