Ninja
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Plan Struct Reference

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...
 
EdgeFindWork ()
 
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...
 

Detailed Description

Plan stores the state of a build plan: what we intend to build, which steps we're ready to execute.

Definition at line 41 of file build.h.

Constructor & Destructor Documentation

Plan::Plan ( )

Definition at line 253 of file build.cc.

Member Function Documentation

bool Plan::AddSubTarget ( Node node,
vector< Node * > *  stack,
string *  err 
)
private
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().

bool Plan::CheckDependencyCycle ( Node node,
vector< Node * > *  stack,
string *  err 
)
private

Definition at line 311 of file build.cc.

Referenced by AddSubTarget().

void Plan::CleanNode ( DependencyScan scan,
Node node 
)
int Plan::command_edge_count ( ) const
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 ( )

Dumps the current state of the plan.

Definition at line 452 of file build.cc.

References ready_, and want_.

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().

bool Plan::more_to_do ( ) const
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().

void Plan::NodeFinished ( Node node)
private

Definition at line 380 of file build.cc.

References EdgeFinished(), Node::out_edges(), ScheduleWork(), and want_.

Referenced by EdgeFinished().

void Plan::ResumeDelayedJobs ( Edge edge)
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().

void Plan::ScheduleWork ( Edge edge)
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().

Member Data Documentation

int Plan::command_edges_
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().

set<Edge*> Plan::ready_
private

Definition at line 91 of file build.h.

Referenced by Dump(), FindWork(), ResumeDelayedJobs(), and ScheduleWork().

map<Edge*, bool> Plan::want_
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().

int Plan::wanted_edges_
private

Total remaining number of wanted edges.

Definition at line 97 of file build.h.

Referenced by AddSubTarget(), CleanNode(), EdgeFinished(), and more_to_do().


The documentation for this struct was generated from the following files: