Track included files in PATH-agnostic way. (#4329)

* Track included files in PATH-agnostic way.

Use full paths as keys in the map of included files. Store logical
include path as a value, in order to put it to the generated file.

* Fix tests by accepting null |include_filename|.

* Fix self-includes code generators.
This commit is contained in:
Pavel Kalinnikov
2017-06-02 17:50:18 +02:00
committed by Wouter van Oortmerssen
parent 22743ca45a
commit 642254bee6
4 changed files with 18 additions and 18 deletions

View File

@@ -72,14 +72,15 @@ class CppGenerator : public BaseGenerator {
}
for (auto it = parser_.included_files_.begin();
it != parser_.included_files_.end(); ++it) {
auto noext = flatbuffers::StripExtension(it->first);
if (it->second.empty())
continue;
auto noext = flatbuffers::StripExtension(it->second);
auto basename = flatbuffers::StripPath(noext);
if (basename != file_name_) {
code_ += "#include \"" + parser_.opts.include_prefix +
(parser_.opts.keep_include_path ? noext : basename) +
"_generated.h\"";
num_includes++;
}
code_ += "#include \"" + parser_.opts.include_prefix +
(parser_.opts.keep_include_path ? noext : basename) +
"_generated.h\"";
num_includes++;
}
if (num_includes) code_ += "";
}