summaryrefslogtreecommitdiffstats
path: root/src/graph.h
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-09-02 18:03:01 (GMT)
committerEvan Martin <martine@danga.com>2012-09-02 18:05:51 (GMT)
commitfd91e0dc26d18209f7625730bb0e653f8321fff9 (patch)
tree3220f1082693486d0b2ba196afe3e791aecff3c7 /src/graph.h
parentdf6d995790ee15317fd9ddb47c9d59f30265afe5 (diff)
downloadNinja-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/graph.h')
-rw-r--r--src/graph.h49
1 files changed, 32 insertions, 17 deletions
diff --git a/src/graph.h b/src/graph.h
index f487a22..3e2e57a 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -20,6 +20,7 @@
using namespace std;
#include "eval_env.h"
+#include "state.h"
#include "timestamp.h"
struct DiskInterface;
@@ -142,39 +143,25 @@ struct Edge {
Edge() : rule_(NULL), env_(NULL), outputs_ready_(false), implicit_deps_(0),
order_only_deps_(0) {}
- /// Examine inputs, outputs, and command lines to judge whether this edge
- /// needs to be re-run, and update outputs_ready_ and each outputs' |dirty_|
- /// state accordingly.
- /// Returns false on failure.
- bool RecomputeDirty(State* state, DiskInterface* disk_interface, string* err);
-
- /// Recompute whether a given single output should be marked dirty.
- /// Returns true if so.
- bool RecomputeOutputDirty(BuildLog* build_log, TimeStamp most_recent_input,
- Node* most_recent_node, const string& command,
- Node* output);
-
/// Return true if all inputs' in-edges are ready.
bool AllInputsReady() const;
/// Expand all variables in a command and return it as a string.
- /// If incl_rsp_file is enabled, the string will also contain the
+ /// If incl_rsp_file is enabled, the string will also contain the
/// full contents of a response file (if applicable)
string EvaluateCommand(bool incl_rsp_file = false); // XXX move to env, take env ptr
string EvaluateDepFile();
string GetDescription();
-
+
/// Does the edge use a response file?
bool HasRspFile();
-
+
/// Get the path to the response file
string GetRspFile();
/// Get the contents of the response file
string GetRspFileContent();
- bool LoadDepFile(State* state, DiskInterface* disk_interface, string* err);
-
void Dump(const char* prefix="") const;
const Rule* rule_;
@@ -210,4 +197,32 @@ struct Edge {
bool is_phony() const;
};
+
+/// 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, DiskInterface* disk_interface)
+ : state_(state), disk_interface_(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_|
+ /// state accordingly.
+ /// Returns false on failure.
+ bool RecomputeDirty(Edge* edge, string* err);
+
+ /// Recompute whether a given single output should be marked dirty.
+ /// Returns true if so.
+ bool RecomputeOutputDirty(Edge* edge, TimeStamp most_recent_input,
+ Node* most_recent_node,
+ const string& command, Node* output);
+
+ bool LoadDepFile(Edge* edge, string* err);
+
+ State* state_;
+ DiskInterface* disk_interface_;
+ BuildLog* build_log() const {
+ return state_->build_log_;
+ }
+};
+
#endif // NINJA_GRAPH_H_