Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: tools/gn/analyzer.h

Issue 2940873002: Implement tracking of BUILD.gn files used to define target, toolchain or (Closed)
Patch Set: Fix compilation after rebase. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/containers/flat_tree.h ('k') | tools/gn/analyzer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TOOLS_GN_ANALYZER_H_ 5 #ifndef TOOLS_GN_ANALYZER_H_
6 #define TOOLS_GN_ANALYZER_H_ 6 #define TOOLS_GN_ANALYZER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "tools/gn/builder.h" 12 #include "tools/gn/builder.h"
13 #include "tools/gn/label.h" 13 #include "tools/gn/label.h"
14 #include "tools/gn/source_file.h" 14 #include "tools/gn/source_file.h"
15 #include "tools/gn/target.h" 15 #include "tools/gn/target.h"
16 16
17 // An Analyzer can answer questions about a build graph. It is used 17 // An Analyzer can answer questions about a build graph. It is used
18 // to answer queries for the `refs` and `analyze` commands, where we 18 // to answer queries for the `refs` and `analyze` commands, where we
19 // need to look at the graph in ways that can't easily be determined 19 // need to look at the graph in ways that can't easily be determined
20 // from just a single Target. 20 // from just a single Target.
21 class Analyzer { 21 class Analyzer {
22 public: 22 public:
23 using LabelSet = std::set<Label>; 23 using LabelSet = std::set<Label>;
24 using SourceFileSet = std::set<const SourceFile*>; 24 using SourceFileSet = std::set<const SourceFile*>;
25 using TargetSet = std::set<const Target*>; 25 using TargetSet = std::set<const Target*>;
26 26
27 explicit Analyzer(const Builder& builder); 27 Analyzer(const Builder& builder,
28 const SourceFile& build_config_file,
29 const SourceFile& dotgn_file);
28 ~Analyzer(); 30 ~Analyzer();
29 31
30 // Figures out from a Buider and a JSON-formatted string containing lists 32 // Figures out from a Buider and a JSON-formatted string containing lists
31 // of files and targets, which targets would be affected by modifications 33 // of files and targets, which targets would be affected by modifications
32 // to the files . See the help text for the analyze command (kAnalyze_Help) 34 // to the files . See the help text for the analyze command (kAnalyze_Help)
33 // for the specification of the input and output string formats and the 35 // for the specification of the input and output string formats and the
34 // expected behavior of the method. 36 // expected behavior of the method.
35 std::string Analyze(const std::string& input, Err* err) const; 37 std::string Analyze(const std::string& input, Err* err) const;
36 38
37 private: 39 private:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // (see Filter(), above). 78 // (see Filter(), above).
77 void FilterTarget(const Target*, TargetSet* seen, TargetSet* filtered) const; 79 void FilterTarget(const Target*, TargetSet* seen, TargetSet* filtered) const;
78 80
79 bool TargetRefersToFile(const Target* target, const SourceFile* file) const; 81 bool TargetRefersToFile(const Target* target, const SourceFile* file) const;
80 82
81 void AddTargetsDirectlyReferringToFileTo(const SourceFile* file, 83 void AddTargetsDirectlyReferringToFileTo(const SourceFile* file,
82 TargetSet* matches) const; 84 TargetSet* matches) const;
83 85
84 void AddAllRefsTo(const Target* target, TargetSet* matches) const; 86 void AddAllRefsTo(const Target* target, TargetSet* matches) const;
85 87
88 bool WereMainGNFilesModified(const SourceFileSet& source_files) const;
89
86 std::vector<const Target*> all_targets_; 90 std::vector<const Target*> all_targets_;
87 std::map<const Label, const Target*> labels_to_targets_; 91 std::map<const Label, const Target*> labels_to_targets_;
88 Label default_toolchain_; 92 Label default_toolchain_;
89 std::set<const Target*> roots_; 93 std::set<const Target*> roots_;
90 94
91 // Maps targets to the list of targets that depend on them. 95 // Maps targets to the list of targets that depend on them.
92 std::multimap<const Target*, const Target*> dep_map_; 96 std::multimap<const Target*, const Target*> dep_map_;
97 SourceFile build_config_file_;
98 SourceFile dotgn_file_;
93 }; 99 };
94 100
95 #endif // TOOLS_GN_ANALYZER_H_ 101 #endif // TOOLS_GN_ANALYZER_H_
OLDNEW
« no previous file with comments | « base/containers/flat_tree.h ('k') | tools/gn/analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698