|
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 Types | |
| enum | EdgeResult { kEdgeFailed , kEdgeSucceeded } |
| enum | Want { kWantNothing , kWantToStart , kWantToFinish } |
| Enumerate possible steps we want for an edge. More... | |
Public Member Functions | |
| bool | AddTarget (const Node *target, std::string *err) |
| Add a target to our plan (including all its dependencies). More... | |
| bool | CleanNode (DependencyScan *scan, Node *node, std::string *err) |
| Clean the given node during the build. More... | |
| int | command_edge_count () const |
| Number of edges with commands to run. More... | |
| void | Dump () const |
| Dumps the current state of the plan. More... | |
| bool | DyndepsLoaded (DependencyScan *scan, const Node *node, const DyndepFile &ddf, std::string *err) |
| Update the build plan to account for modifications made to the graph by information loaded from a dyndep file. More... | |
| bool | EdgeFinished (Edge *edge, EdgeResult result, std::string *err) |
| Mark an edge as done building (whether it succeeded or failed). More... | |
| Edge * | FindWork () |
| bool | more_to_do () const |
| Returns true if there's more work to be done. More... | |
| Plan (Builder *builder=NULL) | |
| void | PrepareQueue () |
| void | Reset () |
| Reset state. Clears want and ready sets. More... | |
Private Member Functions | |
| bool | AddSubTarget (const Node *node, const Node *dependent, std::string *err, std::set< Edge * > *dyndep_walk) |
| void | ComputeCriticalPath () |
| bool | EdgeMaybeReady (std::map< Edge *, Want >::iterator want_e, std::string *err) |
| void | EdgeWanted (const Edge *edge) |
| bool | NodeFinished (Node *node, std::string *err) |
| Update plan with knowledge that the given node is up to date. More... | |
| bool | RefreshDyndepDependents (DependencyScan *scan, const Node *node, std::string *err) |
| void | ScheduleInitialEdges () |
| void | ScheduleWork (std::map< Edge *, Want >::iterator want_e) |
| Submits a ready edge as a candidate for execution. More... | |
| void | UnmarkDependents (const Node *node, std::set< Node * > *dependents) |
Private Attributes | |
| Builder * | builder_ |
| int | command_edges_ |
| Total number of edges that have commands (not phony). More... | |
| EdgePriorityQueue | ready_ |
| std::vector< const Node * > | targets_ |
| user provided targets in build order, earlier one have higher priority More... | |
| std::map< Edge *, Want > | 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.
| enum Plan::EdgeResult |
| enum Plan::Want |
Enumerate possible steps we want for an edge.
|
private |
Definition at line 99 of file build.cc.
References Node::dirty(), EdgeWanted(), Node::generated_by_dep_loader(), Node::in_edge(), Edge::inputs_, kWantNothing, kWantToFinish, kWantToStart, Edge::outputs_ready(), Node::path(), and want_.
Referenced by AddTarget(), and DyndepsLoaded().
| bool Plan::AddTarget | ( | const Node * | target, |
| std::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 94 of file build.cc.
References AddSubTarget(), and targets_.
Referenced by PlanTest::PrepareForTarget(), RefreshDyndepDependents(), and TEST_F().
| bool Plan::CleanNode | ( | DependencyScan * | scan, |
| Node * | node, | ||
| std::string * | err | ||
| ) |
Clean the given node during the build.
Return false on error.
Definition at line 271 of file build.cc.
References builder_, command_edges_, Node::dirty(), Status::EdgeRemovedFromPlan(), kWantNothing, MEM_FN, Node::mtime(), Node::out_edges(), DependencyScan::RecomputeOutputsDirty(), Node::set_dirty(), Builder::status_, want_, and wanted_edges_.
Referenced by Builder::FinishCommand().
|
inline |
Number of edges with commands to run.
Definition at line 75 of file build.h.
References command_edges_.
Referenced by TEST_F().
|
private |
Definition at line 476 of file build.cc.
References Edge::critical_path_weight(), Node::in_edge(), Edge::inputs_, METRIC_RECORD, Edge::set_critical_path_weight(), and targets_.
Referenced by PrepareQueue().
| void Plan::Dump | ( | ) | const |
Dumps the current state of the plan.
Definition at line 597 of file build.cc.
References kWantNothing, ready_, and want_.
| bool Plan::DyndepsLoaded | ( | DependencyScan * | scan, |
| const Node * | node, | ||
| const DyndepFile & | ddf, | ||
| std::string * | err | ||
| ) |
Update the build plan to account for modifications made to the graph by information loaded from a dyndep file.
Definition at line 331 of file build.cc.
References AddSubTarget(), EdgeMaybeReady(), Node::out_edges(), Edge::outputs_ready(), RefreshDyndepDependents(), and want_.
Referenced by Builder::LoadDyndeps().
| bool Plan::EdgeFinished | ( | Edge * | edge, |
| EdgeResult | result, | ||
| std::string * | err | ||
| ) |
Mark an edge as done building (whether it succeeded or failed).
If any of the edge's outputs are dyndep bindings of their dependents, this loads dynamic dependencies from the nodes' paths. Returns 'false' if loading dyndep info fails and 'true' otherwise.
Definition at line 201 of file build.cc.
References builder_, Pool::EdgeFinished(), Edge::job_slot_, Builder::jobserver_, kEdgeSucceeded, kWantNothing, NodeFinished(), Edge::outputs_, Edge::outputs_ready_, Edge::pool(), ready_, Pool::RetrieveReadyEdges(), want_, and wanted_edges_.
Referenced by Builder::Build(), EdgeMaybeReady(), and Builder::FinishCommand().
Definition at line 256 of file build.cc.
References Edge::AllInputsReady(), EdgeFinished(), kEdgeSucceeded, kWantNothing, and ScheduleWork().
Referenced by DyndepsLoaded(), and NodeFinished().
|
private |
Definition at line 152 of file build.cc.
References builder_, command_edges_, Status::EdgeAddedToPlan(), Edge::is_phony(), Builder::status_, and wanted_edges_.
Referenced by AddSubTarget(), and RefreshDyndepDependents().
| Edge * Plan::FindWork | ( | ) |
Definition at line 161 of file build.cc.
References builder_, Jobserver::Slot::IsValid(), Edge::job_slot_, Builder::jobserver_, and 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 command_edges_, and wanted_edges_.
Referenced by Builder::AlreadyUpToDate(), Builder::Build(), PlanTest::FindWorkSorted(), PlanTest::PrepareForTarget(), and TEST_F().
|
private |
Update plan with knowledge that the given node is up to date.
If the node is a dyndep binding on any of its dependents, this loads dynamic dependencies from the node's path. Returns 'false' if loading dyndep info fails and 'true' otherwise.
Definition at line 233 of file build.cc.
References builder_, Node::dyndep_pending(), EdgeMaybeReady(), Builder::LoadDyndeps(), Node::out_edges(), and want_.
Referenced by EdgeFinished().
| void Plan::PrepareQueue | ( | ) |
Definition at line 592 of file build.cc.
References ComputeCriticalPath(), and ScheduleInitialEdges().
Referenced by Builder::Build(), and PlanTest::PrepareForTarget().
|
private |
Definition at line 399 of file build.cc.
References AddTarget(), Node::dirty(), EdgeWanted(), Node::in_edge(), kWantNothing, kWantToStart, Edge::outputs_ready(), DependencyScan::RecomputeDirty(), UnmarkDependents(), and want_.
Referenced by DyndepsLoaded().
| void Plan::Reset | ( | ) |
Reset state. Clears want and ready sets.
Definition at line 87 of file build.cc.
References EdgePriorityQueue::clear(), command_edges_, ready_, want_, and wanted_edges_.
|
private |
Definition at line 563 of file build.cc.
References Edge::AllInputsReady(), Pool::DelayEdge(), kWantToStart, Edge::pool(), ready_, ScheduleWork(), Pool::ShouldDelayEdge(), and want_.
Referenced by PrepareQueue().
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 179 of file build.cc.
References Pool::DelayEdge(), Pool::EdgeScheduled(), kWantToFinish, kWantToStart, Edge::pool(), ready_, Pool::RetrieveReadyEdges(), and Pool::ShouldDelayEdge().
Referenced by EdgeMaybeReady(), and ScheduleInitialEdges().
Definition at line 446 of file build.cc.
References Edge::mark_, Node::out_edges(), Edge::outputs_, Edge::VisitNone, and want_.
Referenced by RefreshDyndepDependents().
|
private |
Definition at line 134 of file build.h.
Referenced by CleanNode(), EdgeFinished(), EdgeWanted(), FindWork(), and NodeFinished().
|
private |
Total number of edges that have commands (not phony).
Definition at line 139 of file build.h.
Referenced by CleanNode(), command_edge_count(), EdgeWanted(), more_to_do(), and Reset().
|
private |
Definition at line 132 of file build.h.
Referenced by Dump(), EdgeFinished(), FindWork(), Reset(), ScheduleInitialEdges(), and ScheduleWork().
|
private |
user provided targets in build order, earlier one have higher priority
Definition at line 136 of file build.h.
Referenced by AddTarget(), and ComputeCriticalPath().
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 it does contain an entry, the enumeration indicates what we want for the edge.
Definition at line 130 of file build.h.
Referenced by AddSubTarget(), CleanNode(), Dump(), DyndepsLoaded(), EdgeFinished(), NodeFinished(), RefreshDyndepDependents(), Reset(), ScheduleInitialEdges(), and UnmarkDependents().
|
private |
Total remaining number of wanted edges.
Definition at line 142 of file build.h.
Referenced by CleanNode(), EdgeFinished(), EdgeWanted(), more_to_do(), and Reset().