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

@@ -1917,8 +1917,7 @@ CheckedError Parser::SkipJsonString() {
bool Parser::Parse(const char *source, const char **include_paths,
const char *source_filename) {
return !DoParse(source, include_paths, source_filename,
source_filename).Check();
return !DoParse(source, include_paths, source_filename, nullptr).Check();
}
CheckedError Parser::DoParse(const char *source, const char **include_paths,
@@ -1926,8 +1925,8 @@ CheckedError Parser::DoParse(const char *source, const char **include_paths,
const char *include_filename) {
file_being_parsed_ = source_filename ? source_filename : "";
if (source_filename &&
included_files_.find(include_filename) == included_files_.end()) {
included_files_[include_filename] = true;
included_files_.find(source_filename) == included_files_.end()) {
included_files_[source_filename] = include_filename ? include_filename : "";
files_included_per_file_[source_filename] = std::set<std::string>();
}
if (!include_paths) {
@@ -1976,7 +1975,7 @@ CheckedError Parser::DoParse(const char *source, const char **include_paths,
return Error("unable to locate include file: " + name);
if (source_filename)
files_included_per_file_[source_filename].insert(filepath);
if (included_files_.find(name) == included_files_.end()) {
if (included_files_.find(filepath) == included_files_.end()) {
// We found an include file that we have not parsed yet.
// Load it and parse it.
std::string contents;