mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-07 22:03:40 +00:00
Added --keep-prefix to not strip schema include path in C++ includes.
Change-Id: I3c6356fc6664072796f273096df64829108b4a34 Tested: on Linux.
This commit is contained in:
@@ -103,6 +103,7 @@ std::string FlatCompiler::GetUsageString(const char* program_name) const {
|
||||
" PATH \n"
|
||||
" --include-prefix Prefix this path to any generated include statements.\n"
|
||||
" PATH\n"
|
||||
" --keep-prefix Keep original prefix of schema include statement.\n"
|
||||
" --no-fb-import Don't include flatbuffers import statement for TypeScript.\n"
|
||||
" --no-ts-reexport Don't re-export imported dependencies for TypeScript.\n"
|
||||
"FILEs may be schemas, or JSON files (conforming to preceding schema)\n"
|
||||
@@ -155,6 +156,8 @@ int FlatCompiler::Compile(int argc, const char** argv) {
|
||||
opts.include_prefix = argv[argi];
|
||||
if (opts.include_prefix.back() != '/' &&
|
||||
opts.include_prefix.back() != '\\') opts.include_prefix += "/";
|
||||
} else if(arg == "--keep-prefix") {
|
||||
opts.keep_include_path = true;
|
||||
} else if(arg == "--strict-json") {
|
||||
opts.strict_json = true;
|
||||
} else if(arg == "--allow-non-utf8") {
|
||||
|
||||
@@ -72,8 +72,9 @@ class CppGenerator : public BaseGenerator {
|
||||
}
|
||||
for (auto it = parser_.included_files_.begin();
|
||||
it != parser_.included_files_.end(); ++it) {
|
||||
const auto basename =
|
||||
flatbuffers::StripPath(flatbuffers::StripExtension(it->first));
|
||||
auto basename = flatbuffers::StripExtension(it->first);
|
||||
if (!parser_.opts.keep_include_path)
|
||||
basename = flatbuffers::StripPath(basename);
|
||||
if (basename != file_name_) {
|
||||
code_ += "#include \"" + parser_.opts.include_prefix + basename +
|
||||
"_generated.h\"";
|
||||
|
||||
Reference in New Issue
Block a user