Ninja
dyndep.h
Go to the documentation of this file.
1 // Copyright 2015 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_DYNDEP_LOADER_H_
16 #define NINJA_DYNDEP_LOADER_H_
17 
18 #include <map>
19 #include <string>
20 #include <vector>
21 
22 struct DiskInterface;
23 struct Edge;
24 struct Node;
25 struct State;
26 
27 /// Store dynamically-discovered dependency information for one edge.
28 struct Dyndeps {
29  Dyndeps() : used_(false), restat_(false) {}
30  bool used_;
31  bool restat_;
32  std::vector<Node*> implicit_inputs_;
33  std::vector<Node*> implicit_outputs_;
34 };
35 
36 /// Store data loaded from one dyndep file. Map from an edge
37 /// to its dynamically-discovered dependency information.
38 /// This is a struct rather than a typedef so that we can
39 /// forward-declare it in other headers.
40 struct DyndepFile: public std::map<Edge*, Dyndeps> {};
41 
42 /// DyndepLoader loads dynamically discovered dependencies, as
43 /// referenced via the "dyndep" attribute in build files.
44 struct DyndepLoader {
45  DyndepLoader(State* state, DiskInterface* disk_interface)
46  : state_(state), disk_interface_(disk_interface) {}
47 
48  /// Load a dyndep file from the given node's path and update the
49  /// build graph with the new information. One overload accepts
50  /// a caller-owned 'DyndepFile' object in which to store the
51  /// information loaded from the dyndep file.
52  bool LoadDyndeps(Node* node, std::string* err) const;
53  bool LoadDyndeps(Node* node, DyndepFile* ddf, std::string* err) const;
54 
55  private:
56  bool LoadDyndepFile(Node* file, DyndepFile* ddf, std::string* err) const;
57 
58  bool UpdateEdge(Edge* edge, Dyndeps const* dyndeps, std::string* err) const;
59 
62 };
63 
64 #endif // NINJA_DYNDEP_LOADER_H_
std::vector< Node * > implicit_inputs_
Definition: dyndep.h:32
Store data loaded from one dyndep file.
Definition: dyndep.h:40
bool restat_
Definition: dyndep.h:31
State * state_
Definition: dyndep.h:60
Information about a node in the dependency graph: the file, whether it&#39;s dirty, mtime, etc.
Definition: graph.h:37
Interface for accessing the disk.
An edge in the dependency graph; links between Nodes using Rules.
Definition: graph.h:139
Store dynamically-discovered dependency information for one edge.
Definition: dyndep.h:28
DyndepLoader(State *state, DiskInterface *disk_interface)
Definition: dyndep.h:45
bool LoadDyndepFile(Node *file, DyndepFile *ddf, std::string *err) const
Definition: dyndep.cc:122
DyndepLoader loads dynamically discovered dependencies, as referenced via the "dyndep" attribute in b...
Definition: dyndep.h:44
Dyndeps()
Definition: dyndep.h:29
bool UpdateEdge(Edge *edge, Dyndeps const *dyndeps, std::string *err) const
Definition: dyndep.cc:82
Global state (file status) for a single run.
Definition: state.h:84
bool LoadDyndeps(Node *node, std::string *err) const
Load a dyndep file from the given node&#39;s path and update the build graph with the new information...
Definition: dyndep.cc:29
DiskInterface * disk_interface_
Definition: dyndep.h:61
std::vector< Node * > implicit_outputs_
Definition: dyndep.h:33
bool used_
Definition: dyndep.h:30