diff options
author | Evan Martin <martine@danga.com> | 2012-09-02 18:03:01 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-09-02 18:05:51 (GMT) |
commit | fd91e0dc26d18209f7625730bb0e653f8321fff9 (patch) | |
tree | 3220f1082693486d0b2ba196afe3e791aecff3c7 /src/build.cc | |
parent | df6d995790ee15317fd9ddb47c9d59f30265afe5 (diff) | |
download | Ninja-fd91e0dc26d18209f7625730bb0e653f8321fff9.zip Ninja-fd91e0dc26d18209f7625730bb0e653f8321fff9.tar.gz Ninja-fd91e0dc26d18209f7625730bb0e653f8321fff9.tar.bz2 |
split out dirty recomputation logic from Edge class
Rather than passing States and DiskInterfaces through all the calls,
put the necessary ambient information in a new DependencyScan object
and move the code accordingly.
Note: I didn't move the source location of the functions to preserve
history, though this does result in a sort of weird order for the
functions in graph.cc.
Diffstat (limited to 'src/build.cc')
-rw-r--r-- | src/build.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/build.cc b/src/build.cc index 6d1318c..18bba9e 100644 --- a/src/build.cc +++ b/src/build.cc @@ -406,7 +406,7 @@ void Plan::NodeFinished(Node* node) { } } -void Plan::CleanNode(BuildLog* build_log, Node* node) { +void Plan::CleanNode(DependencyScan* scan, Node* node) { node->set_dirty(false); for (vector<Edge*>::const_iterator ei = node->out_edges().begin(); @@ -435,12 +435,12 @@ void Plan::CleanNode(BuildLog* build_log, Node* node) { if (!(*ni)->dirty()) continue; - if ((*ei)->RecomputeOutputDirty(build_log, most_recent_input, NULL, command, - *ni)) { + if (scan->RecomputeOutputDirty(*ei, most_recent_input, NULL, + command, *ni)) { (*ni)->MarkDirty(); all_outputs_clean = false; } else { - CleanNode(build_log, *ni); + CleanNode(scan, *ni); } } @@ -554,7 +554,8 @@ struct DryRunCommandRunner : public CommandRunner { Builder::Builder(State* state, const BuildConfig& config, DiskInterface* disk_interface) - : state_(state), config_(config), disk_interface_(disk_interface) { + : state_(state), config_(config), disk_interface_(disk_interface), + scan_(state, disk_interface) { status_ = new BuildStatus(config); log_ = state->build_log_; } @@ -604,7 +605,7 @@ Node* Builder::AddTarget(const string& name, string* err) { bool Builder::AddTarget(Node* node, string* err) { node->StatIfNecessary(disk_interface_); if (Edge* in_edge = node->in_edge()) { - if (!in_edge->RecomputeDirty(state_, disk_interface_, err)) + if (!scan_.RecomputeDirty(in_edge, err)) return false; if (in_edge->outputs_ready()) return true; // Nothing to do. @@ -756,7 +757,7 @@ void Builder::FinishEdge(Edge* edge, bool success, const string& output) { // The rule command did not change the output. Propagate the clean // state through the build graph. // Note that this also applies to nonexistent outputs (mtime == 0). - plan_.CleanNode(log_, *i); + plan_.CleanNode(&scan_, *i); node_cleaned = true; } } |