summaryrefslogtreecommitdiffstats
path: root/src/build.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2013-04-09 04:43:49 (GMT)
committerEvan Martin <martine@danga.com>2013-04-09 04:48:10 (GMT)
commit0a2fc151976277d8c0319cdc4ee3b1932b673d91 (patch)
tree81c2f0d5319397870c1cd70e95051487b67d58d7 /src/build.cc
parentc78e1eea9a385340a1d47d5402f5a7c41f99c95d (diff)
downloadNinja-0a2fc151976277d8c0319cdc4ee3b1932b673d91.zip
Ninja-0a2fc151976277d8c0319cdc4ee3b1932b673d91.tar.gz
Ninja-0a2fc151976277d8c0319cdc4ee3b1932b673d91.tar.bz2
add a straightforward deps log test, fix the other one
The first test I wrote was wrong; write a simpler test that exercises the "no failures" code paths, then fix the second test and the bugs it exposed.
Diffstat (limited to 'src/build.cc')
-rw-r--r--src/build.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/build.cc b/src/build.cc
index 5e874df..7de4b16 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -801,10 +801,12 @@ void Builder::FinishCommand(CommandRunner::Result* result) {
// can fail, which makes the command fail from a build perspective.
vector<Node*> deps_nodes;
+ TimeStamp deps_mtime = 0;
string deps_type = edge->GetBinding("deps");
if (result->success() && !deps_type.empty()) {
string extract_err;
- if (!ExtractDeps(result, deps_type, &deps_nodes, &extract_err)) {
+ if (!ExtractDeps(result, deps_type, &deps_nodes, &deps_mtime,
+ &extract_err)) {
if (!result->output.empty())
result->output.append("\n");
result->output.append(extract_err);
@@ -875,10 +877,12 @@ void Builder::FinishCommand(CommandRunner::Result* result) {
if (!deps_type.empty()) {
assert(edge->outputs_.size() == 1 && "should have been rejected by parser");
Node* out = edge->outputs_[0];
- TimeStamp mtime = disk_interface_->Stat(out->path());
- // XXX we could reuse the restat logic to avoid a second stat,
- // but in practice we only care about the single output.
- scan_.deps_log()->RecordDeps(out, mtime, deps_nodes);
+ if (!deps_mtime) {
+ // On Windows there's no separate file to compare against; just reuse
+ // the output's mtime.
+ deps_mtime = disk_interface_->Stat(out->path());
+ }
+ scan_.deps_log()->RecordDeps(out, deps_mtime, deps_nodes);
}
}
@@ -886,6 +890,7 @@ void Builder::FinishCommand(CommandRunner::Result* result) {
bool Builder::ExtractDeps(CommandRunner::Result* result,
const string& deps_type,
vector<Node*>* deps_nodes,
+ TimeStamp* deps_mtime,
string* err) {
#ifdef _WIN32
if (deps_type == "msvc") {
@@ -900,7 +905,13 @@ bool Builder::ExtractDeps(CommandRunner::Result* result,
if (deps_type == "gcc") {
string depfile = result->edge->GetBinding("depfile");
if (depfile.empty()) {
- *err = string("edge with deps=gcc but no depfile makes no sense\n");
+ *err = string("edge with deps=gcc but no depfile makes no sense");
+ return false;
+ }
+
+ *deps_mtime = disk_interface_->Stat(depfile);
+ if (*deps_mtime <= 0) {
+ *err = string("unable to read depfile");
return false;
}