29 current_use_ += edge.
weight();
34 current_use_ -= edge.
weight();
39 delayed_.insert(edge);
43 DelayedEdges::iterator it = delayed_.begin();
44 while (it != delayed_.end()) {
46 if (current_use_ + edge->
weight() > depth_)
48 ready_queue->insert(edge);
52 delayed_.erase(delayed_.begin(), it);
56 printf(
"%s (%d/%d) ->\n", name_.c_str(), current_use_, depth_);
57 for (DelayedEdges::const_iterator it = delayed_.begin();
58 it != delayed_.end(); ++it)
70 return ((weight_diff < 0) || (weight_diff == 0 && a < b));
78 bindings_.AddRule(&kPhonyRule);
79 AddPool(&kDefaultPool);
80 AddPool(&kConsolePool);
84 assert(LookupPool(pool->
name()) == NULL);
85 pools_[pool->
name()] = pool;
89 map<string, Pool*>::iterator i = pools_.find(pool_name);
90 if (i == pools_.end())
99 edge->
env_ = &bindings_;
100 edges_.push_back(edge);
105 Node* node = LookupNode(path);
109 paths_[node->
path()] = node;
115 Paths::const_iterator i = paths_.find(path);
116 if (i != paths_.end())
122 const bool kAllowReplacements =
true;
123 const int kMaxValidEditDistance = 3;
125 int min_distance = kMaxValidEditDistance + 1;
127 for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i) {
129 i->first, path, kAllowReplacements, kMaxValidEditDistance);
130 if (distance < min_distance && i->second) {
131 min_distance = distance;
139 Node* node = GetNode(path, slash_bits);
145 Node* node = GetNode(path, slash_bits);
154 Node* node = LookupNode(path);
156 *err =
"unknown target '" + path.
AsString() +
"'";
159 defaults_.push_back(node);
164 vector<Node*> root_nodes;
166 for (vector<Edge*>::const_iterator e = edges_.begin();
167 e != edges_.end(); ++e) {
168 for (vector<Node*>::const_iterator out = (*e)->outputs_.begin();
169 out != (*e)->outputs_.end(); ++out) {
170 if ((*out)->out_edges().empty())
171 root_nodes.push_back(*out);
175 if (!edges_.empty() && root_nodes.empty())
176 *err =
"could not determine root nodes of build graph";
182 return defaults_.empty() ? RootNodes(err) : defaults_;
186 for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i)
187 i->second->ResetState();
188 for (vector<Edge*>::iterator e = edges_.begin(); e != edges_.end(); ++e) {
189 (*e)->outputs_ready_ =
false;
190 (*e)->deps_loaded_ =
false;
196 for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i) {
197 Node* node = i->second;
198 printf(
"%s %s [id:%d]\n",
199 node->
path().c_str(),
204 if (!pools_.empty()) {
205 printf(
"resource_pools:\n");
206 for (map<string, Pool*>::const_iterator it = pools_.begin();
207 it != pools_.end(); ++it)
209 if (!it->second->name().empty()) {
bool AddDefault(StringPiece path, std::string *error)
void RetrieveReadyEdges(std::set< Edge *> *ready_queue)
Pool will add zero or more edges to the ready_queue.
std::string AsString() const
Convert the slice into a full-fledged std::string, copying the data into a new string.
Node * SpellcheckNode(const std::string &path)
void EdgeScheduled(const Edge &edge)
informs this Pool that the given edge is committed to be run.
Node * GetNode(StringPiece path, uint64_t slash_bits)
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.
void AddIn(Edge *edge, StringPiece path, uint64_t slash_bits)
std::vector< Node * > outputs_
void AddOutEdge(Edge *edge)
An edge in the dependency graph; links between Nodes using Rules.
Node * LookupNode(StringPiece path) const
std::vector< Node * > RootNodes(std::string *error) const
const std::string & path() const
Edge * AddEdge(const Rule *rule)
bool AddOut(Edge *edge, StringPiece path, uint64_t slash_bits)
void Dump()
Dump the nodes and Pools (useful for debugging).
An invokable build command and associated metadata (description, etc.).
void Dump() const
Dump the Pool and its edges (useful for debugging).
void DelayEdge(Edge *edge)
adds the given edge to this Pool to be delayed.
A pool for delayed edges.
#define METRIC_RECORD(name)
The primary interface to metrics.
Pool * LookupPool(const std::string &pool_name)
std::vector< Node * > inputs_
bool status_known() const
std::vector< Node * > DefaultNodes(std::string *error) const
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)
unsigned long long uint64_t
int EditDistance(const StringPiece &s1, const StringPiece &s2, bool allow_replacements, int max_edit_distance)
const std::string & name() const
static const Rule kPhonyRule