28 current_use_ += edge.
weight();
33 current_use_ -= edge.
weight();
38 delayed_.insert(edge);
42 DelayedEdges::iterator it = delayed_.begin();
43 while (it != delayed_.end()) {
45 if (current_use_ + edge->
weight() > depth_)
47 ready_queue->insert(edge);
51 delayed_.erase(delayed_.begin(), it);
55 printf(
"%s (%d/%d) ->\n", name_.c_str(), current_use_, depth_);
56 for (DelayedEdges::const_iterator it = delayed_.begin();
57 it != delayed_.end(); ++it)
69 bindings_.AddRule(&kPhonyRule);
70 AddPool(&kDefaultPool);
71 AddPool(&kConsolePool);
75 assert(LookupPool(pool->
name()) == NULL);
76 pools_[pool->
name()] = pool;
80 map<string, Pool*>::iterator i = pools_.find(pool_name);
81 if (i == pools_.end())
90 edge->
env_ = &bindings_;
91 edge->
id_ = edges_.size();
92 edges_.push_back(edge);
97 Node* node = LookupNode(path);
101 paths_[node->
path()] = node;
106 Paths::const_iterator i = paths_.find(path);
107 if (i != paths_.end())
113 const bool kAllowReplacements =
true;
114 const int kMaxValidEditDistance = 3;
116 int min_distance = kMaxValidEditDistance + 1;
118 for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i) {
120 i->first, path, kAllowReplacements, kMaxValidEditDistance);
121 if (distance < min_distance && i->second) {
122 min_distance = distance;
130 Node* node = GetNode(path, slash_bits);
136 Node* node = GetNode(path, slash_bits);
145 Node* node = GetNode(path, slash_bits);
151 Node* node = LookupNode(path);
153 *err =
"unknown target '" + path.
AsString() +
"'";
156 defaults_.push_back(node);
161 vector<Node*> root_nodes;
163 for (vector<Edge*>::const_iterator e = edges_.begin();
164 e != edges_.end(); ++e) {
165 for (vector<Node*>::const_iterator out = (*e)->outputs_.begin();
166 out != (*e)->outputs_.end(); ++out) {
167 if ((*out)->out_edges().empty())
168 root_nodes.push_back(*out);
172 if (!edges_.empty() && root_nodes.empty())
173 *err =
"could not determine root nodes of build graph";
179 return defaults_.empty() ? RootNodes(err) : defaults_;
183 for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i)
184 i->second->ResetState();
185 for (vector<Edge*>::iterator e = edges_.begin(); e != edges_.end(); ++e) {
186 (*e)->outputs_ready_ =
false;
187 (*e)->deps_loaded_ =
false;
193 for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i) {
194 Node* node = i->second;
195 printf(
"%s %s [id:%d]\n",
196 node->
path().c_str(),
201 if (!pools_.empty()) {
202 printf(
"resource_pools:\n");
203 for (map<string, Pool*>::const_iterator it = pools_.begin();
204 it != pools_.end(); ++it)
206 if (!it->second->name().empty()) {
void AddValidationOutEdge(Edge *edge)
bool AddDefault(StringPiece path, std::string *error)
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)
std::vector< Node * > validations_
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 invocable 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.
Pool * LookupPool(const std::string &pool_name)
std::vector< Node * > inputs_
bool status_known() const
std::vector< Node * > DefaultNodes(std::string *error) const
void EdgeFinished(const Edge &edge)
informs this Pool that the given edge is no longer runnable, and should relinquish its resources back...
void AddValidation(Edge *edge, StringPiece path, uint64_t slash_bits)
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)
std::set< Edge *, EdgeCmp > EdgeSet
const std::string & name() const
void RetrieveReadyEdges(EdgeSet *ready_queue)
Pool will add zero or more edges to the ready_queue.
static const Rule kPhonyRule