Ninja
missing_deps.h
Go to the documentation of this file.
1 // Copyright 2019 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_MISSING_DEPS_H_
16 #define NINJA_MISSING_DEPS_H_
17 
18 #include <map>
19 #include <set>
20 #include <string>
21 
22 #if __cplusplus >= 201103L
23 #include <unordered_map>
24 #endif
25 
26 struct DepsLog;
27 struct DiskInterface;
28 struct Edge;
29 struct Node;
30 struct Rule;
31 struct State;
32 
34  public:
36  virtual void OnMissingDep(Node* node, const std::string& path,
37  const Rule& generator) = 0;
38 };
39 
41  void OnMissingDep(Node* node, const std::string& path, const Rule& generator);
42  void OnStats(int nodes_processed, int nodes_missing_deps,
43  int missing_dep_path_count, int generated_nodes,
44  int generator_rules);
45 };
46 
48  public:
50  DepsLog* deps_log, State* state,
51  DiskInterface* disk_interface);
52  void ProcessNode(Node* node);
53  void PrintStats();
54  bool HadMissingDeps() { return !nodes_missing_deps_.empty(); }
55 
56  void ProcessNodeDeps(Node* node, Node** dep_nodes, int dep_nodes_count);
57 
58  bool PathExistsBetween(Edge* from, Edge* to);
59 
64  std::set<Node*> seen_;
65  std::set<Node*> nodes_missing_deps_;
66  std::set<Node*> generated_nodes_;
67  std::set<const Rule*> generator_rules_;
69 
70  private:
71 #if __cplusplus >= 201103L
72  using InnerAdjacencyMap = std::unordered_map<Edge*, bool>;
73  using AdjacencyMap = std::unordered_map<Edge*, InnerAdjacencyMap>;
74 #else
75  typedef std::map<Edge*, bool> InnerAdjacencyMap;
76  typedef std::map<Edge*, InnerAdjacencyMap> AdjacencyMap;
77 #endif
79 };
80 
81 #endif // NINJA_MISSING_DEPS_H_
void OnMissingDep(Node *node, const std::string &path, const Rule &generator)
Definition: missing_deps.cc:66
void ProcessNodeDeps(Node *node, Node **dep_nodes, int dep_nodes_count)
virtual void OnMissingDep(Node *node, const std::string &path, const Rule &generator)=0
std::set< Node * > nodes_missing_deps_
Definition: missing_deps.h:65
MissingDependencyScanner(MissingDependencyScannerDelegate *delegate, DepsLog *deps_log, State *state, DiskInterface *disk_interface)
Definition: missing_deps.cc:72
Information about a node in the dependency graph: the file, whether it&#39;s dirty, mtime, etc.
Definition: graph.h:39
Interface for accessing the disk.
An edge in the dependency graph; links between Nodes using Rules.
Definition: graph.h:164
As build commands run they can output extra dependency information (e.g.
Definition: deps_log.h:68
AdjacencyMap adjacency_map_
Definition: missing_deps.h:78
void ProcessNode(Node *node)
Definition: missing_deps.cc:78
std::set< Node * > generated_nodes_
Definition: missing_deps.h:66
An invocable build command and associated metadata (description, etc.).
Definition: eval_env.h:59
std::map< Edge *, bool > InnerAdjacencyMap
Definition: missing_deps.h:75
void OnStats(int nodes_processed, int nodes_missing_deps, int missing_dep_path_count, int generated_nodes, int generator_rules)
std::map< Edge *, InnerAdjacencyMap > AdjacencyMap
Definition: missing_deps.h:76
std::set< const Rule * > generator_rules_
Definition: missing_deps.h:67
DiskInterface * disk_interface_
Definition: missing_deps.h:63
Global state (file status) for a single run.
Definition: state.h:92
bool PathExistsBetween(Edge *from, Edge *to)
std::set< Node * > seen_
Definition: missing_deps.h:64
MissingDependencyScannerDelegate * delegate_
Definition: missing_deps.h:60