Ninja
|
Plan stores the state of a build plan: what we intend to build, which steps we're ready to execute. More...
#include <build.h>
Public Member Functions | |
bool | AddTarget (Node *node, string *err) |
Add a target to our plan (including all its dependencies). More... | |
void | CleanNode (DependencyScan *scan, Node *node) |
Clean the given node during the build. More... | |
int | command_edge_count () const |
Number of edges with commands to run. More... | |
void | Dump () |
Dumps the current state of the plan. More... | |
void | EdgeFinished (Edge *edge) |
Mark an edge as done building. More... | |
Edge * | FindWork () |
bool | more_to_do () const |
Returns true if there's more work to be done. More... | |
Plan () | |
Private Member Functions | |
bool | AddSubTarget (Node *node, vector< Node * > *stack, string *err) |
bool | CheckDependencyCycle (Node *node, vector< Node * > *stack, string *err) |
void | NodeFinished (Node *node) |
void | ResumeDelayedJobs (Edge *edge) |
Allows jobs blocking on |edge| to potentially resume. More... | |
void | ScheduleWork (Edge *edge) |
Submits a ready edge as a candidate for execution. More... | |
Private Attributes | |
int | command_edges_ |
Total number of edges that have commands (not phony). More... | |
set< Edge * > | ready_ |
map< Edge *, bool > | want_ |
Keep track of which edges we want to build in this plan. More... | |
int | wanted_edges_ |
Total remaining number of wanted edges. More... | |
Plan stores the state of a build plan: what we intend to build, which steps we're ready to execute.
Definition at line 260 of file build.cc.
References Edge::AllInputsReady(), CheckDependencyCycle(), command_edges_, Node::dirty(), Node::in_edge(), Edge::inputs_, Edge::is_phony(), Edge::outputs_ready(), Node::path(), ScheduleWork(), want_, and wanted_edges_.
Referenced by AddTarget().
bool Plan::AddTarget | ( | Node * | node, |
string * | err | ||
) |
Add a target to our plan (including all its dependencies).
Returns false if we don't need to build this target; may fill in |err| with an error message if there's a problem.
Definition at line 255 of file build.cc.
References AddSubTarget().
Referenced by Builder::AddTarget().
Definition at line 311 of file build.cc.
Referenced by AddSubTarget().
void Plan::CleanNode | ( | DependencyScan * | scan, |
Node * | node | ||
) |
Clean the given node during the build.
Definition at line 401 of file build.cc.
References command_edges_, Node::dirty(), Node::MarkDirty(), Node::mtime(), Node::out_edges(), DependencyScan::RecomputeOutputDirty(), Node::set_dirty(), want_, and wanted_edges_.
Referenced by Builder::FinishCommand().
|
inline |
Number of edges with commands to run.
Definition at line 67 of file build.h.
References command_edges_.
Referenced by Builder::Build(), and Builder::FinishCommand().
void Plan::Dump | ( | ) |
void Plan::EdgeFinished | ( | Edge * | edge | ) |
Mark an edge as done building.
Used internally and by tests.
Definition at line 362 of file build.cc.
References NodeFinished(), Edge::outputs_, Edge::outputs_ready_, ResumeDelayedJobs(), want_, and wanted_edges_.
Referenced by Builder::Build(), Builder::FinishCommand(), and NodeFinished().
Edge * Plan::FindWork | ( | ) |
Definition at line 331 of file build.cc.
References ready_.
Referenced by Builder::Build(), and PlanTest::FindWorkSorted().
|
inline |
Returns true if there's more work to be done.
Definition at line 54 of file build.h.
References wanted_edges_.
Referenced by Builder::AlreadyUpToDate(), Builder::Build(), and PlanTest::FindWorkSorted().
|
private |
Definition at line 380 of file build.cc.
References EdgeFinished(), Node::out_edges(), ScheduleWork(), and want_.
Referenced by EdgeFinished().
|
private |
Allows jobs blocking on |edge| to potentially resume.
For example, if |edge| is a member of a pool, calling this may schedule previously pending jobs in that pool.
Definition at line 357 of file build.cc.
References Pool::EdgeFinished(), Edge::pool(), ready_, and Pool::RetrieveReadyEdges().
Referenced by EdgeFinished().
|
private |
Submits a ready edge as a candidate for execution.
The edge may be delayed from running, for example if it's a member of a currently-full pool.
Definition at line 340 of file build.cc.
References Pool::DelayEdge(), Pool::EdgeScheduled(), Edge::pool(), ready_, Pool::RetrieveReadyEdges(), and Pool::ShouldDelayEdge().
Referenced by AddSubTarget(), and NodeFinished().
|
private |
Total number of edges that have commands (not phony).
Definition at line 94 of file build.h.
Referenced by AddSubTarget(), CleanNode(), and command_edge_count().
|
private |
Definition at line 91 of file build.h.
Referenced by Dump(), FindWork(), ResumeDelayedJobs(), and ScheduleWork().
|
private |
Keep track of which edges we want to build in this plan.
If this map does not contain an entry for an edge, we do not want to build the entry or its dependents. If an entry maps to false, we do not want to build it, but we might want to build one of its dependents. If the entry maps to true, we want to build it.
Definition at line 89 of file build.h.
Referenced by AddSubTarget(), CleanNode(), Dump(), EdgeFinished(), and NodeFinished().
|
private |
Total remaining number of wanted edges.
Definition at line 97 of file build.h.
Referenced by AddSubTarget(), CleanNode(), EdgeFinished(), and more_to_do().