Ninja
graph.h
Go to the documentation of this file.
1 // Copyright 2011 Google Inc. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef NINJA_GRAPH_H_
16 #define NINJA_GRAPH_H_
17 
18 #include <algorithm>
19 #include <queue>
20 #include <set>
21 #include <string>
22 #include <vector>
23 
24 #include "dyndep.h"
25 #include "eval_env.h"
26 #include "explanations.h"
27 #include "jobserver.h"
28 #include "timestamp.h"
29 #include "util.h"
30 
31 struct BuildLog;
33 struct DiskInterface;
34 struct DepsLog;
35 struct Edge;
36 struct Node;
37 struct Pool;
38 struct State;
39 
40 /// Information about a node in the dependency graph: the file, whether
41 /// it's dirty, mtime, etc.
42 struct Node {
43  Node(const std::string& path, uint64_t slash_bits)
45 
46  /// Return false on error.
47  bool Stat(DiskInterface* disk_interface, std::string* err);
48 
49  /// If the file doesn't exist, set the mtime_ from its dependencies
51 
52  /// Return false on error.
53  bool StatIfNecessary(DiskInterface* disk_interface, std::string* err) {
54  if (status_known())
55  return true;
56  return Stat(disk_interface, err);
57  }
58 
59  /// Mark as not-yet-stat()ed and not dirty.
60  void ResetState() {
61  mtime_ = -1;
63  dirty_ = false;
64  }
65 
66  /// Mark the Node as already-stat()ed and missing.
67  void MarkMissing() {
68  if (mtime_ == -1) {
69  mtime_ = 0;
70  }
72  }
73 
74  bool exists() const {
76  }
77 
78  bool status_known() const {
80  }
81 
82  const std::string& path() const { return path_; }
83  /// Get |path()| but use slash_bits to convert back to original slash styles.
84  std::string PathDecanonicalized() const {
86  }
87  static std::string PathDecanonicalized(const std::string& path,
89  uint64_t slash_bits() const { return slash_bits_; }
90 
91  TimeStamp mtime() const { return mtime_; }
92 
93  bool dirty() const { return dirty_; }
94  void set_dirty(bool dirty) { dirty_ = dirty; }
95  void MarkDirty() { dirty_ = true; }
96 
97  bool dyndep_pending() const { return dyndep_pending_; }
98  void set_dyndep_pending(bool pending) { dyndep_pending_ = pending; }
99 
100  Edge* in_edge() const { return in_edge_; }
101  void set_in_edge(Edge* edge) { in_edge_ = edge; }
102 
103  /// Indicates whether this node was generated from a depfile or dyndep file,
104  /// instead of being a regular input or output from the Ninja manifest.
106 
107  void set_generated_by_dep_loader(bool value) {
108  generated_by_dep_loader_ = value;
109  }
110 
111  int id() const { return id_; }
112  void set_id(int id) { id_ = id; }
113 
114  const std::vector<Edge*>& out_edges() const { return out_edges_; }
115  const std::vector<Edge*>& validation_out_edges() const { return validation_out_edges_; }
116  void AddOutEdge(Edge* edge) { out_edges_.push_back(edge); }
117  void AddValidationOutEdge(Edge* edge) { validation_out_edges_.push_back(edge); }
118 
119  void Dump(const char* prefix="") const;
120 
121 private:
122  std::string path_;
123 
124  /// Set bits starting from lowest for backslashes that were normalized to
125  /// forward slashes by CanonicalizePath. See |PathDecanonicalized|.
127 
128  /// Possible values of mtime_:
129  /// -1: file hasn't been examined
130  /// 0: we looked, and file doesn't exist
131  /// >0: actual file's mtime, or the latest mtime of its dependencies if it doesn't exist
133 
135  /// The file hasn't been examined.
137  /// The file doesn't exist. mtime_ will be the latest mtime of its dependencies.
139  /// The path is an actual file. mtime_ will be the file's mtime.
141  };
143 
144  /// Dirty is true when the underlying file is out-of-date.
145  /// But note that Edge::outputs_ready_ is also used in judging which
146  /// edges to build.
147  bool dirty_ = false;
148 
149  /// Store whether dyndep information is expected from this node but
150  /// has not yet been loaded.
151  bool dyndep_pending_ = false;
152 
153  /// Set to true when this node comes from a depfile, a dyndep file or the
154  /// deps log. If it does not have a producing edge, the build should not
155  /// abort if it is missing (as for regular source inputs). By default
156  /// all nodes have this flag set to true, since the deps and build logs
157  /// can be loaded before the manifest.
159 
160  /// The Edge that produces this Node, or NULL when there is no
161  /// known edge to produce it.
162  Edge* in_edge_ = nullptr;
163 
164  /// All Edges that use this Node as an input.
165  std::vector<Edge*> out_edges_;
166 
167  /// All Edges that use this Node as a validation.
168  std::vector<Edge*> validation_out_edges_;
169 
170  /// A dense integer id for the node, assigned and used by DepsLog.
171  int id_ = -1;
172 };
173 
174 /// An edge in the dependency graph; links between Nodes using Rules.
175 struct Edge {
176  enum VisitMark {
179  VisitDone
180  };
181 
182  Edge() = default;
183 
184  /// Return true if all inputs' in-edges are ready.
185  bool AllInputsReady() const;
186 
187  /// Expand all variables in a command and return it as a string.
188  /// If incl_rsp_file is enabled, the string will also contain the
189  /// full contents of a response file (if applicable)
190  std::string EvaluateCommand(bool incl_rsp_file = false) const;
191 
192  /// Returns the shell-escaped value of |key|.
193  std::string GetBinding(const std::string& key) const;
194  bool GetBindingBool(const std::string& key) const;
195 
196  /// Like GetBinding("depfile"), but without shell escaping.
197  std::string GetUnescapedDepfile() const;
198  /// Like GetBinding("dyndep"), but without shell escaping.
199  std::string GetUnescapedDyndep() const;
200  /// Like GetBinding("rspfile"), but without shell escaping.
201  std::string GetUnescapedRspfile() const;
202 
203  void Dump(const char* prefix="") const;
204 
205  // critical_path_weight is the priority during build scheduling. The
206  // "critical path" between this edge's inputs and any target node is
207  // the path which maximises the sum oof weights along that path.
208  // NOTE: Defaults to -1 as a marker smaller than any valid weight
212  }
213 
214  const Rule* rule_ = nullptr;
215  Pool* pool_ = nullptr;
216  std::vector<Node*> inputs_;
217  std::vector<Node*> outputs_;
218  std::vector<Node*> validations_;
219  Node* dyndep_ = nullptr;
220  BindingEnv* env_ = nullptr;
222  size_t id_ = 0;
224  bool outputs_ready_ = false;
225  bool deps_loaded_ = false;
226  bool deps_missing_ = false;
229 
230  const Rule& rule() const { return *rule_; }
231  Pool* pool() const { return pool_; }
232  int weight() const { return 1; }
233  bool outputs_ready() const { return outputs_ready_; }
234 
235  // There are three types of inputs.
236  // 1) explicit deps, which show up as $in on the command line;
237  // 2) implicit deps, which the target depends on implicitly (e.g. C headers),
238  // and changes in them cause the target to rebuild;
239  // 3) order-only deps, which are needed before the target builds but which
240  // don't cause the target to rebuild.
241  // These are stored in inputs_ in that order, and we keep counts of
242  // #2 and #3 when we need to access the various subsets.
243  int implicit_deps_ = 0;
245  bool is_implicit(size_t index) {
246  return index >= inputs_.size() - order_only_deps_ - implicit_deps_ &&
247  !is_order_only(index);
248  }
249  bool is_order_only(size_t index) {
250  return index >= inputs_.size() - order_only_deps_;
251  }
252 
253  // There are two types of outputs.
254  // 1) explicit outs, which show up as $out on the command line;
255  // 2) implicit outs, which the target generates but are not part of $out.
256  // These are stored in outputs_ in that order, and we keep a count of
257  // #2 to use when we need to access the various subsets.
258  int implicit_outs_ = 0;
259  bool is_implicit_out(size_t index) const {
260  return index >= outputs_.size() - implicit_outs_;
261  }
262 
263  bool is_phony() const;
264  bool use_console() const;
265  bool maybe_phonycycle_diagnostic() const;
266 
267  /// A Jobserver slot instance. Invalid by default.
269 
270  // Historical info: how long did this edge take last time,
271  // as per .ninja_log, if known? Defaults to -1 if unknown.
273 };
274 
275 struct EdgeCmp {
276  bool operator()(const Edge* a, const Edge* b) const {
277  return a->id_ < b->id_;
278  }
279 };
280 
281 typedef std::set<Edge*, EdgeCmp> EdgeSet;
282 
283 /// ImplicitDepLoader loads implicit dependencies, as referenced via the
284 /// "depfile" attribute in build files.
287  DiskInterface* disk_interface,
288  DepfileParserOptions const* depfile_parser_options,
289  Explanations* explanations)
290  : state_(state), disk_interface_(disk_interface), deps_log_(deps_log),
291  depfile_parser_options_(depfile_parser_options),
292  explanations_(explanations) {}
293 
294  /// Load implicit dependencies for \a edge.
295  /// @return false on error (without filling \a err if info is just missing
296  // or out of date).
297  bool LoadDeps(Edge* edge, std::string* err);
298 
299  DepsLog* deps_log() const {
300  return deps_log_;
301  }
302 
303  protected:
304  /// Process loaded implicit dependencies for \a edge and update the graph
305  /// @return false on error (without filling \a err if info is just missing)
306  virtual bool ProcessDepfileDeps(Edge* edge,
307  std::vector<StringPiece>* depfile_ins,
308  std::string* err);
309 
310  /// Load implicit dependencies for \a edge from a depfile attribute.
311  /// @return false on error (without filling \a err if info is just missing).
312  bool LoadDepFile(Edge* edge, const std::string& path, std::string* err);
313 
314  /// Load implicit dependencies for \a edge from the DepsLog.
315  /// @return false on error (without filling \a err if info is just missing).
316  bool LoadDepsFromLog(Edge* edge, std::string* err);
317 
318  /// Preallocate \a count spaces in the input array on \a edge, returning
319  /// an iterator pointing at the first new space.
320  std::vector<Node*>::iterator PreallocateSpace(Edge* edge, int count);
321 
327 };
328 
329 
330 /// DependencyScan manages the process of scanning the files in a graph
331 /// and updating the dirty/outputs_ready state of all the nodes and edges.
334  DiskInterface* disk_interface,
335  DepfileParserOptions const* depfile_parser_options,
336  Explanations* explanations)
337  : build_log_(build_log), disk_interface_(disk_interface),
338  dep_loader_(state, deps_log, disk_interface, depfile_parser_options,
339  explanations),
340  dyndep_loader_(state, disk_interface), explanations_(explanations) {}
341 
342  /// Update the |dirty_| state of the given nodes by transitively inspecting
343  /// their input edges.
344  /// Examine inputs, outputs, and command lines to judge whether an edge
345  /// needs to be re-run, and update outputs_ready_ and each outputs' |dirty_|
346  /// state accordingly.
347  /// Appends any validation nodes found to the nodes parameter.
348  /// Returns false on failure.
349  bool RecomputeDirty(Node* node, std::vector<Node*>* validation_nodes, std::string* err);
350 
351  /// Recompute whether any output of the edge is dirty, if so sets |*dirty|.
352  /// Returns false on failure.
353  bool RecomputeOutputsDirty(Edge* edge, Node* most_recent_input,
354  bool* dirty, std::string* err);
355 
356  BuildLog* build_log() const {
357  return build_log_;
358  }
359  void set_build_log(BuildLog* log) {
360  build_log_ = log;
361  }
362 
363  DepsLog* deps_log() const {
364  return dep_loader_.deps_log();
365  }
366 
367  /// Load a dyndep file from the given node's path and update the
368  /// build graph with the new information. One overload accepts
369  /// a caller-owned 'DyndepFile' object in which to store the
370  /// information loaded from the dyndep file.
371  bool LoadDyndeps(Node* node, std::string* err) const;
372  bool LoadDyndeps(Node* node, DyndepFile* ddf, std::string* err) const;
373 
374  private:
375  bool RecomputeNodeDirty(Node* node, std::vector<Node*>* stack,
376  std::vector<Node*>* validation_nodes, std::string* err);
377  bool VerifyDAG(Node* node, std::vector<Node*>* stack, std::string* err);
378 
379  /// Recompute whether a given single output should be marked dirty.
380  /// Returns true if so.
381  bool RecomputeOutputDirty(const Edge* edge, const Node* most_recent_input,
382  const std::string& command, Node* output);
383 
384  void RecordExplanation(const Node* node, const char* fmt, ...);
385 
391 };
392 
393 // Implements a less comparison for edges by priority, where highest
394 // priority is defined lexicographically first by largest critical
395 // time, then lowest ID.
396 //
397 // Including ID means that wherever the critical path weights are the
398 // same, the edges are executed in ascending ID order which was
399 // historically how all tasks were scheduled.
401  bool operator()(const Edge* e1, const Edge* e2) const {
402  const int64_t cw1 = e1->critical_path_weight();
403  const int64_t cw2 = e2->critical_path_weight();
404  if (cw1 != cw2) {
405  return cw1 < cw2;
406  }
407  return e1->id_ > e2->id_;
408  }
409 };
410 
411 // Reverse of EdgePriorityLess, e.g. to sort by highest priority first
413  bool operator()(const Edge* e1, const Edge* e2) const {
414  return EdgePriorityLess()(e2, e1);
415  }
416 };
417 
418 // A priority queue holding non-owning Edge pointers. top() will
419 // return the edge with the largest critical path weight, and lowest
420 // ID if more than one edge has the same critical path weight.
422  public std::priority_queue<Edge*, std::vector<Edge*>, EdgePriorityLess>{
423 public:
424  void clear() {
425  c.clear();
426  }
427 };
428 
429 /// A class used to collect the transitive set of inputs from a given set
430 /// of starting nodes. Used to implement the `inputs` tool.
431 ///
432 /// When collecting inputs, the outputs of phony edges are always ignored
433 /// from the result, but are followed by the dependency walk.
434 ///
435 /// Usage is:
436 /// - Create instance.
437 /// - Call VisitNode() for each root node to collect inputs from.
438 /// - Call inputs() to retrieve the list of input node pointers.
439 /// - Call GetInputsAsStrings() to retrieve the list of inputs as a string
440 /// vector.
441 ///
443  /// Visit a single @arg node during this collection.
444  void VisitNode(const Node* node);
445 
446  /// Retrieve list of visited input nodes. A dependency always appears
447  /// before its dependents in the result, but final order depends on the
448  /// order of the VisitNode() calls performed before this.
449  const std::vector<const Node*>& inputs() const { return inputs_; }
450 
451  /// Same as inputs(), but returns the list of visited nodes as a list of
452  /// strings, with optional shell escaping.
453  std::vector<std::string> GetInputsAsStrings(bool shell_escape = false) const;
454 
455  /// Reset collector state.
456  void Reset() {
457  inputs_.clear();
458  visited_nodes_.clear();
459  }
460 
461  private:
462  std::vector<const Node*> inputs_;
463  std::set<const Node*> visited_nodes_;
464 };
465 
466 #endif // NINJA_GRAPH_H_
void clear()
Definition: graph.h:424
std::set< Edge *, EdgeCmp > EdgeSet
Definition: graph.h:281
An Env which contains a mapping of variables to values as well as a pointer to a parent scope.
Definition: eval_env.h:93
Store a log of every command ran for every build.
Definition: build_log.h:45
DependencyScan manages the process of scanning the files in a graph and updating the dirty/outputs_re...
Definition: graph.h:332
BuildLog * build_log_
Definition: graph.h:386
bool RecomputeOutputDirty(const Edge *edge, const Node *most_recent_input, const std::string &command, Node *output)
Recompute whether a given single output should be marked dirty.
Definition: graph.cc:278
void set_build_log(BuildLog *log)
Definition: graph.h:359
bool RecomputeNodeDirty(Node *node, std::vector< Node * > *stack, std::vector< Node * > *validation_nodes, std::string *err)
Definition: graph.cc:82
BuildLog * build_log() const
Definition: graph.h:356
void RecordExplanation(const Node *node, const char *fmt,...)
bool VerifyDAG(Node *node, std::vector< Node * > *stack, std::string *err)
Definition: graph.cc:226
bool RecomputeOutputsDirty(Edge *edge, Node *most_recent_input, bool *dirty, std::string *err)
Recompute whether any output of the edge is dirty, if so sets |*dirty|.
Definition: graph.cc:265
DiskInterface * disk_interface_
Definition: graph.h:387
DepsLog * deps_log() const
Definition: graph.h:363
bool LoadDyndeps(Node *node, std::string *err) const
Load a dyndep file from the given node's path and update the build graph with the new information.
bool LoadDyndeps(Node *node, DyndepFile *ddf, std::string *err) const
OptionalExplanations explanations_
Definition: graph.h:390
DyndepLoader dyndep_loader_
Definition: graph.h:389
DependencyScan(State *state, BuildLog *build_log, DepsLog *deps_log, DiskInterface *disk_interface, DepfileParserOptions const *depfile_parser_options, Explanations *explanations)
Definition: graph.h:333
ImplicitDepLoader dep_loader_
Definition: graph.h:388
bool RecomputeDirty(Node *node, std::vector< Node * > *validation_nodes, std::string *err)
Update the |dirty_| state of the given nodes by transitively inspecting their input edges.
Definition: graph.cc:49
As build commands run they can output extra dependency information (e.g.
Definition: deps_log.h:68
Interface for accessing the disk.
Store data loaded from one dyndep file.
Definition: dyndep.h:42
DyndepLoader loads dynamically discovered dependencies, as referenced via the "dyndep" attribute in b...
Definition: dyndep.h:46
Definition: graph.h:275
bool operator()(const Edge *a, const Edge *b) const
Definition: graph.h:276
bool operator()(const Edge *e1, const Edge *e2) const
Definition: graph.h:413
bool operator()(const Edge *e1, const Edge *e2) const
Definition: graph.h:401
An edge in the dependency graph; links between Nodes using Rules.
Definition: graph.h:175
Edge()=default
int64_t prev_elapsed_time_millis
Definition: graph.h:272
std::string GetBinding(const std::string &key) const
Returns the shell-escaped value of |key|.
Definition: graph.cc:511
bool generated_by_dep_loader_
Definition: graph.h:227
bool maybe_phonycycle_diagnostic() const
Definition: graph.cc:571
int64_t critical_path_weight() const
Definition: graph.h:209
std::string GetUnescapedDyndep() const
Like GetBinding("dyndep"), but without shell escaping.
Definition: graph.cc:525
std::vector< Node * > outputs_
Definition: graph.h:217
Jobserver::Slot job_slot_
A Jobserver slot instance. Invalid by default.
Definition: graph.h:268
VisitMark mark_
Definition: graph.h:221
bool outputs_ready() const
Definition: graph.h:233
int weight() const
Definition: graph.h:232
int implicit_deps_
Definition: graph.h:243
Node * dyndep_
Definition: graph.h:219
bool is_order_only(size_t index)
Definition: graph.h:249
void set_critical_path_weight(int64_t critical_path_weight)
Definition: graph.h:210
const Rule * rule_
Definition: graph.h:214
VisitMark
Definition: graph.h:176
@ VisitInStack
Definition: graph.h:178
@ VisitDone
Definition: graph.h:179
@ VisitNone
Definition: graph.h:177
int order_only_deps_
Definition: graph.h:244
bool is_phony() const
Definition: graph.cc:563
bool GetBindingBool(const std::string &key) const
Definition: graph.cc:516
Pool * pool_
Definition: graph.h:215
bool is_implicit(size_t index)
Definition: graph.h:245
bool deps_loaded_
Definition: graph.h:225
TimeStamp command_start_time_
Definition: graph.h:228
int implicit_outs_
Definition: graph.h:258
bool is_implicit_out(size_t index) const
Definition: graph.h:259
std::string EvaluateCommand(bool incl_rsp_file=false) const
Expand all variables in a command and return it as a string.
Definition: graph.cc:501
void Dump(const char *prefix="") const
Definition: graph.cc:535
int64_t critical_path_weight_
Definition: graph.h:223
const Rule & rule() const
Definition: graph.h:230
bool use_console() const
Definition: graph.cc:567
std::vector< Node * > validations_
Definition: graph.h:218
BindingEnv * env_
Definition: graph.h:220
std::vector< Node * > inputs_
Definition: graph.h:216
bool deps_missing_
Definition: graph.h:226
std::string GetUnescapedRspfile() const
Like GetBinding("rspfile"), but without shell escaping.
Definition: graph.cc:530
size_t id_
Definition: graph.h:222
Pool * pool() const
Definition: graph.h:231
std::string GetUnescapedDepfile() const
Like GetBinding("depfile"), but without shell escaping.
Definition: graph.cc:520
bool AllInputsReady() const
Return true if all inputs' in-edges are ready.
Definition: graph.cc:381
bool outputs_ready_
Definition: graph.h:224
A class used to record a list of explanation strings associated with a given 'item' pointer.
Definition: explanations.h:27
ImplicitDepLoader loads implicit dependencies, as referenced via the "depfile" attribute in build fil...
Definition: graph.h:285
bool LoadDepFile(Edge *edge, const std::string &path, std::string *err)
Load implicit dependencies for edge from a depfile attribute.
Definition: graph.cc:642
std::vector< Node * >::iterator PreallocateSpace(Edge *edge, int count)
Preallocate count spaces in the input array on edge, returning an iterator pointing at the first new ...
Definition: graph.cc:756
virtual bool ProcessDepfileDeps(Edge *edge, std::vector< StringPiece > *depfile_ins, std::string *err)
Process loaded implicit dependencies for edge and update the graph.
Definition: graph.cc:707
bool LoadDeps(Edge *edge, std::string *err)
Load implicit dependencies for edge.
Definition: graph.cc:618
bool LoadDepsFromLog(Edge *edge, std::string *err)
Load implicit dependencies for edge from the DepsLog.
Definition: graph.cc:726
DepsLog * deps_log() const
Definition: graph.h:299
ImplicitDepLoader(State *state, DepsLog *deps_log, DiskInterface *disk_interface, DepfileParserOptions const *depfile_parser_options, Explanations *explanations)
Definition: graph.h:286
State * state_
Definition: graph.h:322
DepsLog * deps_log_
Definition: graph.h:324
DiskInterface * disk_interface_
Definition: graph.h:323
OptionalExplanations explanations_
Definition: graph.h:326
DepfileParserOptions const * depfile_parser_options_
Definition: graph.h:325
A class used to collect the transitive set of inputs from a given set of starting nodes.
Definition: graph.h:442
void VisitNode(const Node *node)
Visit a single.
Definition: graph.cc:764
std::vector< const Node * > inputs_
Definition: graph.h:462
std::set< const Node * > visited_nodes_
Definition: graph.h:463
std::vector< std::string > GetInputsAsStrings(bool shell_escape=false) const
Same as inputs(), but returns the list of visited nodes as a list of strings, with optional shell esc...
Definition: graph.cc:786
void Reset()
Reset collector state.
Definition: graph.h:456
const std::vector< const Node * > & inputs() const
Retrieve list of visited input nodes.
Definition: graph.h:449
A Jobserver::Slot models a single job slot that can be acquired from.
Definition: jobserver.h:55
Information about a node in the dependency graph: the file, whether it's dirty, mtime,...
Definition: graph.h:42
void set_dirty(bool dirty)
Definition: graph.h:94
void set_in_edge(Edge *edge)
Definition: graph.h:101
const std::vector< Edge * > & validation_out_edges() const
Definition: graph.h:115
int id() const
Definition: graph.h:111
void UpdatePhonyMtime(TimeStamp mtime)
If the file doesn't exist, set the mtime_ from its dependencies.
Definition: graph.cc:43
void AddValidationOutEdge(Edge *edge)
Definition: graph.h:117
void set_id(int id)
Definition: graph.h:112
void Dump(const char *prefix="") const
Definition: graph.cc:594
void set_dyndep_pending(bool pending)
Definition: graph.h:98
TimeStamp mtime_
Possible values of mtime_: -1: file hasn't been examined 0: we looked, and file doesn't exist >0: act...
Definition: graph.h:132
bool generated_by_dep_loader() const
Indicates whether this node was generated from a depfile or dyndep file, instead of being a regular i...
Definition: graph.h:105
bool dirty() const
Definition: graph.h:93
bool dyndep_pending_
Store whether dyndep information is expected from this node but has not yet been loaded.
Definition: graph.h:151
std::vector< Edge * > validation_out_edges_
All Edges that use this Node as a validation.
Definition: graph.h:168
Node(const std::string &path, uint64_t slash_bits)
Definition: graph.h:43
ExistenceStatus
Definition: graph.h:134
@ ExistenceStatusMissing
The file doesn't exist. mtime_ will be the latest mtime of its dependencies.
Definition: graph.h:138
@ ExistenceStatusExists
The path is an actual file. mtime_ will be the file's mtime.
Definition: graph.h:140
@ ExistenceStatusUnknown
The file hasn't been examined.
Definition: graph.h:136
void AddOutEdge(Edge *edge)
Definition: graph.h:116
static std::string PathDecanonicalized(const std::string &path, uint64_t slash_bits)
const std::string & path() const
Definition: graph.h:82
Edge * in_edge() const
Definition: graph.h:100
uint64_t slash_bits_
Set bits starting from lowest for backslashes that were normalized to forward slashes by Canonicalize...
Definition: graph.h:126
bool status_known() const
Definition: graph.h:78
bool dyndep_pending() const
Definition: graph.h:97
void ResetState()
Mark as not-yet-stat()ed and not dirty.
Definition: graph.h:60
std::vector< Edge * > out_edges_
All Edges that use this Node as an input.
Definition: graph.h:165
bool exists() const
Definition: graph.h:74
void set_generated_by_dep_loader(bool value)
Definition: graph.h:107
ExistenceStatus exists_
Definition: graph.h:142
void MarkDirty()
Definition: graph.h:95
std::string PathDecanonicalized() const
Get |path()| but use slash_bits to convert back to original slash styles.
Definition: graph.h:84
TimeStamp mtime() const
Definition: graph.h:91
bool StatIfNecessary(DiskInterface *disk_interface, std::string *err)
Return false on error.
Definition: graph.h:53
void MarkMissing()
Mark the Node as already-stat()ed and missing.
Definition: graph.h:67
std::string path_
Definition: graph.h:122
bool dirty_
Dirty is true when the underlying file is out-of-date.
Definition: graph.h:147
Edge * in_edge_
The Edge that produces this Node, or NULL when there is no known edge to produce it.
Definition: graph.h:162
bool Stat(DiskInterface *disk_interface, std::string *err)
Return false on error.
Definition: graph.cc:34
uint64_t slash_bits() const
Definition: graph.h:89
bool generated_by_dep_loader_
Set to true when this node comes from a depfile, a dyndep file or the deps log.
Definition: graph.h:158
const std::vector< Edge * > & out_edges() const
Definition: graph.h:114
int id_
A dense integer id for the node, assigned and used by DepsLog.
Definition: graph.h:171
Convenience wrapper for an Explanations pointer, which can be null if no explanations need to be reco...
Definition: explanations.h:61
A pool for delayed edges.
Definition: state.h:40
An invocable build command and associated metadata (description, etc.).
Definition: eval_env.h:66
Global state (file status) for a single run.
Definition: state.h:95
int64_t TimeStamp
Definition: timestamp.h:31
unsigned long long uint64_t
Definition: win32port.h:29
signed long long int64_t
A 64-bit integer type.
Definition: win32port.h:28