From d64f672e5083e01c579191b02c1e1667d9e63ef2 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sat, 14 Jun 2014 21:50:05 -0700 Subject: simplify more, move behind flag --- src/debug_flags.cc | 2 ++ src/debug_flags.h | 4 ++++ src/disk_interface.cc | 4 +--- src/ninja.cc | 15 +++++++++++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/debug_flags.cc b/src/debug_flags.cc index 75f1ea5..786a100 100644 --- a/src/debug_flags.cc +++ b/src/debug_flags.cc @@ -15,3 +15,5 @@ bool g_explaining = false; bool g_keep_rsp = false; + +bool g_experimental_win_statcache = false; diff --git a/src/debug_flags.h b/src/debug_flags.h index ba3ebf3..ce3c292 100644 --- a/src/debug_flags.h +++ b/src/debug_flags.h @@ -26,4 +26,8 @@ extern bool g_explaining; extern bool g_keep_rsp; +#ifdef _WIN32 +extern bool g_experimental_win_statcache; +#endif // _WIN32 + #endif // NINJA_EXPLAIN_H_ diff --git a/src/disk_interface.cc b/src/disk_interface.cc index 784f5d5..b7943ef 100644 --- a/src/disk_interface.cc +++ b/src/disk_interface.cc @@ -142,9 +142,7 @@ TimeStamp RealDiskInterface::Stat(const string& path) { return StatSingleFile(path, quiet_); string dir = DirName(path); - int offs = dir.size(); - if (offs) ++offs; // skip \ too - string base(path.substr(offs)); + string base(path.substr(dir.size() ? dir.size() + 1 : 0)); transform(dir.begin(), dir.end(), dir.begin(), ::tolower); transform(base.begin(), base.end(), base.begin(), ::tolower); diff --git a/src/ninja.cc b/src/ninja.cc index a2f3111..acb793e 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -760,6 +760,9 @@ bool DebugEnable(const string& name) { " stats print operation counts/timing info\n" " explain explain what caused a command to execute\n" " keeprsp don't delete @response files on success\n" +#ifdef _WIN32 +" experimentalwinstatcache use an alternative method for stat()ing files\n" +#endif "multiple modes can be enabled via -d FOO -d BAR\n"); return false; } else if (name == "stats") { @@ -771,9 +774,13 @@ bool DebugEnable(const string& name) { } else if (name == "keeprsp") { g_keep_rsp = true; return true; + } else if (name == "experimentalwinstatcache") { + g_experimental_win_statcache = true; + return true; } else { const char* suggestion = - SpellcheckString(name.c_str(), "stats", "explain", "keeprsp", NULL); + SpellcheckString(name.c_str(), "stats", "explain", "keeprsp", + "experimentalwinstatcache", NULL); if (suggestion) { Error("unknown debug setting '%s', did you mean '%s'?", name.c_str(), suggestion); @@ -882,8 +889,8 @@ int NinjaMain::RunBuild(int argc, char** argv) { return 1; } -// XXX allow stat caching - disk_interface_.use_cache_ = true; + if (g_experimental_win_statcache) + disk_interface_.use_cache_ = true; Builder builder(&state_, config_, &build_log_, &deps_log_, &disk_interface_); for (size_t i = 0; i < targets.size(); ++i) { @@ -898,7 +905,7 @@ int NinjaMain::RunBuild(int argc, char** argv) { } } -// XXX disallow stat caching + // Make sure restat rules do not see stale timestamps. disk_interface_.use_cache_ = false; if (builder.AlreadyUpToDate()) { -- cgit v0.12