diff options
author | Evan Martin <martine@danga.com> | 2012-09-13 22:33:40 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-09-13 22:33:40 (GMT) |
commit | 7096bf1507f98be981aa14ffd9ed5a4a8b1c1494 (patch) | |
tree | 10f75334ddb1dc86c2cc85db0cab93ca672d39de /src/graph.h | |
parent | 50af448b293b411bde5232931525574aba3bb451 (diff) | |
parent | 06fa62352d1e9868409b299ffc8abc8f4cd9a39d (diff) | |
download | Ninja-7096bf1507f98be981aa14ffd9ed5a4a8b1c1494.zip Ninja-7096bf1507f98be981aa14ffd9ed5a4a8b1c1494.tar.gz Ninja-7096bf1507f98be981aa14ffd9ed5a4a8b1c1494.tar.bz2 |
version 1.0.0v1.0.0
Diffstat (limited to 'src/graph.h')
-rw-r--r-- | src/graph.h | 67 |
1 files changed, 45 insertions, 22 deletions
diff --git a/src/graph.h b/src/graph.h index 0ef4f3f..272fcb9 100644 --- a/src/graph.h +++ b/src/graph.h @@ -111,12 +111,14 @@ struct Rule { bool restat() const { return restat_; } const EvalString& command() const { return command_; } - EvalString& command() { return command_; } const EvalString& description() const { return description_; } const EvalString& depfile() const { return depfile_; } const EvalString& rspfile() const { return rspfile_; } const EvalString& rspfile_content() const { return rspfile_content_; } + /// Used by a test. + void set_command(const EvalString& command) { command_ = command; } + private: // Allow the parsers to reach into this object and fill out its fields. friend struct ManifestParser; @@ -142,39 +144,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_; @@ -199,15 +187,50 @@ struct Edge { // pointer...) int implicit_deps_; int order_only_deps_; - bool is_implicit(int index) { - return index >= ((int)inputs_.size()) - order_only_deps_ - implicit_deps_ && + bool is_implicit(size_t index) { + return index >= inputs_.size() - order_only_deps_ - implicit_deps_ && !is_order_only(index); } - bool is_order_only(int index) { - return index >= ((int)inputs_.size()) - order_only_deps_; + bool is_order_only(size_t index) { + return index >= inputs_.size() - order_only_deps_; } 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, BuildLog* build_log, + DiskInterface* disk_interface) + : state_(state), build_log_(build_log), + 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, Node* most_recent_input, + const string& command, Node* output); + + bool LoadDepFile(Edge* edge, string* err); + + BuildLog* build_log() const { + return build_log_; + } + void set_build_log(BuildLog* log) { + build_log_ = log; + } + + private: + State* state_; + BuildLog* build_log_; + DiskInterface* disk_interface_; +}; + #endif // NINJA_GRAPH_H_ |