42 DelayedEdges::iterator it =
delayed_.begin();
47 ready_queue->insert(edge);
56 for (DelayedEdges::const_iterator it =
delayed_.begin();
68 return ((weight_diff < 0) || (weight_diff == 0 && a < b));
77 AddPool(&kDefaultPool);
78 AddPool(&kConsolePool);
82 assert(LookupRule(rule->
name()) == NULL);
83 rules_[rule->
name()] = rule;
87 map<string, const Rule*>::iterator i = rules_.find(rule_name);
88 if (i == rules_.end())
94 assert(LookupPool(pool->
name()) == NULL);
95 pools_[pool->
name()] = pool;
99 map<string, Pool*>::iterator i = pools_.find(pool_name);
100 if (i == pools_.end())
109 edge->
env_ = &bindings_;
110 edges_.push_back(edge);
115 Node* node = LookupNode(path);
119 paths_[node->
path()] = node;
125 Paths::const_iterator i = paths_.find(path);
126 if (i != paths_.end())
132 const bool kAllowReplacements =
true;
133 const int kMaxValidEditDistance = 3;
135 int min_distance = kMaxValidEditDistance + 1;
137 for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i) {
139 i->first, path, kAllowReplacements, kMaxValidEditDistance);
140 if (distance < min_distance && i->second) {
141 min_distance = distance;
149 Node* node = GetNode(path);
155 Node* node = GetNode(path);
158 Warning(
"multiple rules generate %s. " 159 "builds involving this target will not be correct; " 167 Node* node = LookupNode(path);
169 *err =
"unknown target '" + path.
AsString() +
"'";
172 defaults_.push_back(node);
177 vector<Node*> root_nodes;
179 for (vector<Edge*>::iterator e = edges_.begin(); e != edges_.end(); ++e) {
180 for (vector<Node*>::iterator out = (*e)->outputs_.begin();
181 out != (*e)->outputs_.end(); ++out) {
182 if ((*out)->out_edges().empty())
183 root_nodes.push_back(*out);
187 if (!edges_.empty() && root_nodes.empty())
188 *err =
"could not determine root nodes of build graph";
190 assert(edges_.empty() || !root_nodes.empty());
195 return defaults_.empty() ? RootNodes(err) : defaults_;
199 for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i)
200 i->second->ResetState();
201 for (vector<Edge*>::iterator e = edges_.begin(); e != edges_.end(); ++e)
202 (*e)->outputs_ready_ =
false;
206 for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i) {
207 Node* node = i->second;
208 printf(
"%s %s [id:%d]\n",
209 node->
path().c_str(),
214 if (!pools_.empty()) {
215 printf(
"resource_pools:\n");
216 for (map<string, Pool*>::const_iterator it = pools_.begin();
217 it != pools_.end(); ++it)
219 if (!it->second->name().empty()) {
void AddIn(Edge *edge, StringPiece path)
void EdgeScheduled(const Edge &edge)
informs this Pool that the given edge is committed to be run.
Node * GetNode(StringPiece path)
Pool * LookupPool(const string &pool_name)
StringPiece represents a slice of a string whose memory is managed externally.
Information about a node in the dependency graph: the file, whether it's dirty, mtime, etc.
Node * SpellcheckNode(const string &path)
string AsString() const
Convert the slice into a full-fledged std::string, copying the data into a new string.
void AddOutEdge(Edge *edge)
An edge in the dependency graph; links between Nodes using Rules.
Edge * AddEdge(const Rule *rule)
void AddOut(Edge *edge, StringPiece path)
vector< Node * > DefaultNodes(string *error)
void Dump()
Dump the nodes and Pools (useful for debugging).
void AddRule(const Rule *rule)
An invokable build command and associated metadata (description, etc.).
bool status_known() const
void DelayEdge(Edge *edge)
adds the given edge to this Pool to be delayed.
A pool for delayed edges.
vector< Node * > RootNodes(string *error)
#define METRIC_RECORD(name)
The primary interface to metrics.
const string & name() const
const string & path() const
void RetrieveReadyEdges(set< Edge * > *ready_queue)
Pool will add zero or more edges to the ready_queue.
bool AddDefault(StringPiece path, string *error)
static bool WeightedEdgeCmp(const Edge *a, const Edge *b)
void EdgeFinished(const Edge &edge)
informs this Pool that the given edge is no longer runnable, and should relinquish its resources back...
void set_in_edge(Edge *edge)
const string & name() const
void Dump() const
Dump the Pool and its edges (useful for debugging).
void Warning(const char *msg,...)
Log a warning message.
int EditDistance(const StringPiece &s1, const StringPiece &s2, bool allow_replacements, int max_edit_distance)
const Rule * LookupRule(const string &rule_name)
int current_use_
|current_use_| is the total of the weights of the edges which are currently scheduled in the Plan (i...
static const Rule kPhonyRule
Node * LookupNode(StringPiece path) const
vector< Node * > outputs_