diff options
author | Evan Martin <martine@danga.com> | 2012-12-29 19:24:03 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2013-04-08 21:45:06 (GMT) |
commit | 00ffada47e1f9649ba76f12ff514f9434a182ef8 (patch) | |
tree | 4ddf85d4cbfa11a56660b12436be28693fcb2eb7 /src | |
parent | 695a8e5704d390c84737292b06a2ec97aab52093 (diff) | |
download | Ninja-00ffada47e1f9649ba76f12ff514f9434a182ef8.zip Ninja-00ffada47e1f9649ba76f12ff514f9434a182ef8.tar.gz Ninja-00ffada47e1f9649ba76f12ff514f9434a182ef8.tar.bz2 |
factor out implicit dep loading
Diffstat (limited to 'src')
-rw-r--r-- | src/graph.cc | 5 | ||||
-rw-r--r-- | src/graph.h | 21 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/graph.cc b/src/graph.cc index 0f99698..cbd93b6 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -61,7 +61,7 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) { string depfile = edge->GetBinding("depfile"); if (!depfile.empty()) { - if (!LoadDepFile(edge, depfile, err)) { + if (!dep_loader_.LoadDepFile(edge, depfile, err)) { if (!err->empty()) return false; EXPLAIN("Edge targets are dirty because depfile '%s' is missing", @@ -282,7 +282,8 @@ bool Edge::GetBindingBool(const string& key) { return !GetBinding(key).empty(); } -bool DependencyScan::LoadDepFile(Edge* edge, const string& path, string* err) { +bool ImplicitDepLoader::LoadDepFile(Edge* edge, const string& path, + string* err) { METRIC_RECORD("depfile load"); string content = disk_interface_->ReadFile(path, err); if (!err->empty()) { diff --git a/src/graph.h b/src/graph.h index 4ef05ec..dc1ef89 100644 --- a/src/graph.h +++ b/src/graph.h @@ -185,13 +185,26 @@ struct Edge { }; +/// ImplicitDepLoader loads implicit dependencies, as referenced via the +/// "depfile" attribute in build files. +struct ImplicitDepLoader { + explicit ImplicitDepLoader(State* state, DiskInterface* disk_interface) + : state_(state), disk_interface_(disk_interface) {} + + bool LoadDepFile(Edge* edge, const string& path, string* err); + + State* state_; + DiskInterface* disk_interface_; +}; + /// DependencyScan manages the process of scanning the files in a graph /// and updating the dirty/outputs_ready state of all the nodes and edges. struct DependencyScan { DependencyScan(State* state, BuildLog* build_log, DiskInterface* disk_interface) - : state_(state), build_log_(build_log), - disk_interface_(disk_interface) {} + : build_log_(build_log), + disk_interface_(disk_interface), + dep_loader_(state, disk_interface) {} /// Examine inputs, outputs, and command lines to judge whether an edge /// needs to be re-run, and update outputs_ready_ and each outputs' |dirty_| @@ -204,8 +217,6 @@ struct DependencyScan { bool RecomputeOutputDirty(Edge* edge, Node* most_recent_input, const string& command, Node* output); - bool LoadDepFile(Edge* edge, const string& path, string* err); - BuildLog* build_log() const { return build_log_; } @@ -214,9 +225,9 @@ struct DependencyScan { } private: - State* state_; BuildLog* build_log_; DiskInterface* disk_interface_; + ImplicitDepLoader dep_loader_; }; #endif // NINJA_GRAPH_H_ |