From 20b3e6ba2161b42f5fec72ac5adda424f4b68f34 Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Wed, 7 Dec 2011 09:51:14 -0800 Subject: make Rule::generator_ and restat_ private --- src/build.cc | 2 +- src/clean.cc | 2 +- src/graph.cc | 4 ++-- src/graph.h | 12 ++++++++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/build.cc b/src/build.cc index a6d8bf1..c69c967 100644 --- a/src/build.cc +++ b/src/build.cc @@ -572,7 +572,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(); diff --git a/src/clean.cc b/src/clean.cc index 9a39ec9..e8405f5 100644 --- a/src/clean.cc +++ b/src/clean.cc @@ -105,7 +105,7 @@ 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) { diff --git a/src/graph.cc b/src/graph.cc index dcfa622..90e730c 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -122,7 +122,7 @@ bool Edge::RecomputeOutputDirty(BuildLog* build_log, time_t most_recent_input, // rule in a previous run and stored the most recent input mtime in the // build log. Use that mtime instead, so that the file will only be // considered dirty if an input was modified since the previous run. - if (rule_->restat_ && build_log && + if (rule_->restat() && build_log && (entry = build_log->LookupByOutput(output->path()))) { if (entry->restat_mtime < most_recent_input) return true; @@ -134,7 +134,7 @@ bool Edge::RecomputeOutputDirty(BuildLog* build_log, time_t most_recent_input, // May also be dirty due to the command changing since the last build. // But if this is a generator rule, the command changing does not make us // dirty. - if (!rule_->generator_ && build_log && + if (!rule_->generator() && build_log && (entry || (entry = build_log->LookupByOutput(output->path())))) { if (command != entry->command) return true; diff --git a/src/graph.h b/src/graph.h index e8c6c57..067d90e 100644 --- a/src/graph.h +++ b/src/graph.h @@ -101,16 +101,24 @@ struct Rule { const string& name() const { return name_; } + bool generator() const { return generator_; } + bool restat() const { return restat_; } + private: string name_; - // TODO: make these private. But adding set/getters for each is so boring - // and doesn't really contribute to the readability of the code... + // TODO: make these private. But various tests want to reach into them... public: EvalString command_; EvalString description_; EvalString depfile_; + +private: bool generator_, restat_; + + // Allow the parsers to reach into this object and fill out its fields. + friend class ManifestParser; + friend class ParserTest; }; struct BuildLog; -- cgit v0.12