From: Evan Martin Date: Wed, 7 Dec 2011 01:32:25 +0000 (-0800) Subject: add and use getter for Edge::rule_ X-Git-Tag: release-120715~226 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6b33fd295b2ed892f2d31a7d1b82dd21d7cf3bd;p=platform%2Fupstream%2Fninja.git add and use getter for Edge::rule_ --- diff --git a/src/build.cc b/src/build.cc index f3d7d9b..d074d2b 100644 --- a/src/build.cc +++ b/src/build.cc @@ -575,7 +575,7 @@ void Builder::FinishEdge(Edge* edge, bool success, const string& output) { time_t restat_mtime = 0; if (success) { - if (edge->rule_->restat_) { + if (edge->rule().restat_) { bool node_cleaned = false; for (vector::iterator i = edge->outputs_.begin(); @@ -605,7 +605,7 @@ void Builder::FinishEdge(Edge* edge, bool success, const string& output) { restat_mtime = input_mtime; } - if (restat_mtime != 0 && !edge->rule_->depfile_.empty()) { + if (restat_mtime != 0 && !edge->rule().depfile_.empty()) { time_t depfile_mtime = disk_interface_->Stat(edge->EvaluateDepFile()); if (depfile_mtime == 0) restat_mtime = 0; diff --git a/src/build_test.cc b/src/build_test.cc index 0d4dce6..b1879ff 100644 --- a/src/build_test.cc +++ b/src/build_test.cc @@ -233,14 +233,14 @@ bool BuildTest::CanRunMore() { bool BuildTest::StartCommand(Edge* edge) { assert(!last_command_); commands_ran_.push_back(edge->EvaluateCommand()); - if (edge->rule_->name_ == "cat" || edge->rule_->name_ == "cc" || - edge->rule_->name_ == "touch") { + if (edge->rule().name_ == "cat" || edge->rule_->name_ == "cc" || + edge->rule().name_ == "touch") { for (vector::iterator out = edge->outputs_.begin(); out != edge->outputs_.end(); ++out) { fs_.Create((*out)->file_->path_, now_, ""); } - } else if (edge->rule_->name_ == "true" || - edge->rule_->name_ == "fail") { + } else if (edge->rule().name_ == "true" || + edge->rule().name_ == "fail") { // Don't do anything. } else { printf("unknown command\n"); @@ -253,7 +253,7 @@ bool BuildTest::StartCommand(Edge* edge) { Edge* BuildTest::WaitForCommand(bool* success, string* output) { if (Edge* edge = last_command_) { - if (edge->rule_->name_ == "fail") + if (edge->rule().name_ == "fail") *success = false; else *success = true; diff --git a/src/clean.cc b/src/clean.cc index a89e1f5..8ae4385 100644 --- a/src/clean.cc +++ b/src/clean.cc @@ -105,13 +105,13 @@ int Cleaner::CleanAll(bool generator) { if ((*e)->rule_ == &State::kPhonyRule) continue; // Do not remove generator's files unless generator specified. - if (!generator && (*e)->rule_->generator_) + if (!generator && (*e)->rule().generator_) continue; for (vector::iterator out_node = (*e)->outputs_.begin(); out_node != (*e)->outputs_.end(); ++out_node) { Remove((*out_node)->file_->path_); } - if (!(*e)->rule_->depfile_.empty()) + if (!(*e)->rule().depfile_.empty()) Remove((*e)->EvaluateDepFile()); } PrintFooter(); @@ -178,7 +178,7 @@ void Cleaner::DoCleanRule(const Rule* rule) { for (vector::iterator e = state_->edges_.begin(); e != state_->edges_.end(); ++e) - if ((*e)->rule_->name_ == rule->name_) + if ((*e)->rule().name_ == rule->name_) for (vector::iterator out_node = (*e)->outputs_.begin(); out_node != (*e)->outputs_.end(); ++out_node) diff --git a/src/graph.h b/src/graph.h index 67f7b10..1a0b624 100644 --- a/src/graph.h +++ b/src/graph.h @@ -104,6 +104,7 @@ struct Edge { Env* env_; bool outputs_ready_; + const Rule& rule() const { return *rule_; } bool outputs_ready() const { return outputs_ready_; } // XXX There are three types of inputs.