summaryrefslogtreecommitdiffstats
path: root/src/ninja.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-03-31 15:12:12 (GMT)
committerNico Weber <nicolasweber@gmx.de>2015-03-31 19:21:57 (GMT)
commit3beebde51a2089ecb01820f1428efe0263deaeea (patch)
tree55aec535c37434dbe5893e8ed37c69891b6d4b74 /src/ninja.cc
parenta88b75d9a9df1b3722ad649ae275d342f3b57b22 (diff)
downloadNinja-3beebde51a2089ecb01820f1428efe0263deaeea.zip
Ninja-3beebde51a2089ecb01820f1428efe0263deaeea.tar.gz
Ninja-3beebde51a2089ecb01820f1428efe0263deaeea.tar.bz2
Let Stat() have an err outparam instead of writing to stderr.
Also check for Stat() failure in a few more places. This way, ninja doesn't print two "ninja: error: " lines if stat() fails during a build. It also makes it easier to keep the stat tests quiet. Every caller of Stat() needs to explicitly log the error string if that's desired.
Diffstat (limited to 'src/ninja.cc')
-rw-r--r--src/ninja.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ninja.cc b/src/ninja.cc
index 1e43137..e5bf98d 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -143,6 +143,8 @@ struct NinjaMain : public BuildLogUser {
virtual bool IsPathDead(StringPiece s) const {
Node* n = state_.LookupNode(s);
+ if (!n || !n->in_edge())
+ return false;
// Just checking n isn't enough: If an old output is both in the build log
// and in the deps log, it will have a Node object in state_. (It will also
// have an in edge if one of its inputs is another output that's in the deps
@@ -152,7 +154,11 @@ struct NinjaMain : public BuildLogUser {
// which seems good enough for this corner case.)
// Do keep entries around for files which still exist on disk, for
// generators that want to use this information.
- return (!n || !n->in_edge()) && disk_interface_.Stat(s.AsString()) == 0;
+ string err;
+ TimeStamp mtime = disk_interface_.Stat(s.AsString(), &err);
+ if (mtime == -1)
+ Error("%s", err.c_str()); // Log and ignore Stat() errors.
+ return mtime == 0;
}
};
@@ -481,7 +487,10 @@ int NinjaMain::ToolDeps(int argc, char** argv) {
continue;
}
- TimeStamp mtime = disk_interface.Stat((*it)->path());
+ string err;
+ TimeStamp mtime = disk_interface.Stat((*it)->path(), &err);
+ if (mtime == -1)
+ Error("%s", err.c_str()); // Log and ignore Stat() errors;
printf("%s: #deps %d, deps mtime %d (%s)\n",
(*it)->path().c_str(), deps->node_count, deps->mtime,
(!mtime || mtime > deps->mtime ? "STALE":"VALID"));