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#include "explanations.h"
23
24struct DiskInterface;
25struct Edge;
26struct Node;
27struct State;
28
29/// Store dynamically-discovered dependency information for one edge.
30struct Dyndeps {
31 Dyndeps() : used_(false), restat_(false) {}
32 bool used_;
33 bool restat_;
34 std::vector<Node*> implicit_inputs_;
35 std::vector<Node*> implicit_outputs_;
36};
37
38/// Store data loaded from one dyndep file. Map from an edge
39/// to its dynamically-discovered dependency information.
40/// This is a struct rather than a typedef so that we can
41/// forward-declare it in other headers.
42struct DyndepFile: public std::map<Edge*, Dyndeps> {};
43
44/// DyndepLoader loads dynamically discovered dependencies, as
45/// referenced via the "dyndep" attribute in build files.
47 DyndepLoader(State* state, DiskInterface* disk_interface,
48 Explanations* explanations = nullptr)
49 : state_(state), disk_interface_(disk_interface),
50 explanations_(explanations) {}
51
52 /// Load a dyndep file from the given node's path and update the
53 /// build graph with the new information. One overload accepts
54 /// a caller-owned 'DyndepFile' object in which to store the
55 /// information loaded from the dyndep file.
56 bool LoadDyndeps(Node* node, std::string* err) const;
57 bool LoadDyndeps(Node* node, DyndepFile* ddf, std::string* err) const;
58
59 private:
60 bool LoadDyndepFile(Node* file, DyndepFile* ddf, std::string* err) const;
61
62 bool UpdateEdge(Edge* edge, Dyndeps const* dyndeps, std::string* err) const;
63
67};
68
69#endif // NINJA_DYNDEP_LOADER_H_
Interface for accessing the disk.
Store data loaded from one dyndep file.
Definition dyndep.h:42
bool LoadDyndepFile(Node *file, DyndepFile *ddf, std::string *err) const
Definition dyndep.cc:118
bool UpdateEdge(Edge *edge, Dyndeps const *dyndeps, std::string *err) const
Definition dyndep.cc:81
State * state_
Definition dyndep.h:64
DyndepLoader(State *state, DiskInterface *disk_interface, Explanations *explanations=nullptr)
Definition dyndep.h:47
DiskInterface * disk_interface_
Definition dyndep.h:65
OptionalExplanations explanations_
Definition dyndep.h:66
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.
Definition dyndep.cc:30
Store dynamically-discovered dependency information for one edge.
Definition dyndep.h:30
std::vector< Node * > implicit_inputs_
Definition dyndep.h:34
bool used_
Definition dyndep.h:32
std::vector< Node * > implicit_outputs_
Definition dyndep.h:35
bool restat_
Definition dyndep.h:33
Dyndeps()
Definition dyndep.h:31
An edge in the dependency graph; links between Nodes using Rules.
Definition graph.h:175
A class used to record a list of explanation strings associated with a given 'item' pointer.
Information about a node in the dependency graph: the file, whether it's dirty, mtime,...
Definition graph.h:42
Convenience wrapper for an Explanations pointer, which can be null if no explanations need to be reco...
Global state (file status) for a single run.
Definition state.h:95