return true;
}
- if (path == ctx.args_info.input_file) {
+ if (path == ctx.args_info.normalized_input_file) {
// Don't remember the input file.
return true;
}
if (!ctx.has_absolute_include_headers) {
ctx.has_absolute_include_headers = util::is_absolute_path(inc_path);
}
+ inc_path = Util::normalize_concrete_absolute_path(inc_path);
inc_path = Util::make_relative_path(ctx, inc_path);
- bool should_hash_inc_path = true;
- if (!ctx.config.hash_dir()) {
- if (util::starts_with(inc_path, ctx.apparent_cwd)
- && util::ends_with(inc_path, "//")) {
- // When compiling with -g or similar, GCC adds the absolute path to
- // CWD like this:
- //
- // # 1 "CWD//"
- //
- // If the user has opted out of including the CWD in the hash, don't
- // hash it. See also how debug_prefix_map is handled.
- should_hash_inc_path = false;
- }
- }
- if (should_hash_inc_path) {
+ if ((inc_path != ctx.apparent_cwd) || ctx.config.hash_dir()) {
hash.hash(inc_path);
}
using util::Tokenizer;
using Mode = Tokenizer::Mode;
using IncludeDelimiter = Tokenizer::IncludeDelimiter;
- // distcc-pump outputs lines like this:
- //
- // __________Using # distcc servers in pump mode
- //
- // We don't want to cache those.
if (!stdout_data.empty()) {
std::string new_stdout_text;
for (const auto line : Tokenizer(
stdout_data, "\n", Mode::include_empty, IncludeDelimiter::yes)) {
if (util::starts_with(line, "__________")) {
Util::send_to_fd(ctx, std::string(line), STDOUT_FILENO);
+ }
+ // Ninja uses the lines with 'Note: including file: ' to determine the
+ // used headers. Headers within basedir need to be changed into relative
+ // paths because otherwise Ninja will use the abs path to original header
+ // to check if a file needs to be recompiled.
+ else if (ctx.config.compiler_type() == CompilerType::msvc
+ && !ctx.config.base_dir().empty()
+ && util::starts_with(line, "Note: including file:")) {
+ std::string orig_line(line.data(), line.length());
+ std::string abs_inc_path =
+ util::replace_first(orig_line, "Note: including file:", "");
+ abs_inc_path = util::strip_whitespace(abs_inc_path);
+ std::string rel_inc_path = Util::make_relative_path(
+ ctx, Util::normalize_concrete_absolute_path(abs_inc_path));
+ std::string line_with_rel_inc =
+ util::replace_first(orig_line, abs_inc_path, rel_inc_path);
+ new_stdout_text.append(line_with_rel_inc);
} else {
new_stdout_text.append(line.data(), line.length());
}