OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_HEADER_CHECKER_H_ | 5 #ifndef TOOLS_GN_HEADER_CHECKER_H_ |
6 #define TOOLS_GN_HEADER_CHECKER_H_ | 6 #define TOOLS_GN_HEADER_CHECKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 21 matching lines...) Expand all Loading... |
32 public: | 32 public: |
33 HeaderChecker(const BuildSettings* build_settings, | 33 HeaderChecker(const BuildSettings* build_settings, |
34 const std::vector<const Target*>& targets); | 34 const std::vector<const Target*>& targets); |
35 | 35 |
36 // Runs the check. The targets in to_check will be checked. If this list is | 36 // Runs the check. The targets in to_check will be checked. If this list is |
37 // empty, all targets will be checked. | 37 // empty, all targets will be checked. |
38 // | 38 // |
39 // This assumes that the current thread already has a message loop. On | 39 // This assumes that the current thread already has a message loop. On |
40 // error, fills the given vector with the errors and returns false. Returns | 40 // error, fills the given vector with the errors and returns false. Returns |
41 // true on success. | 41 // true on success. |
| 42 // |
| 43 // force_check, if true, will override targets opting out of header checking |
| 44 // with "check_includes = false" and will check them anyway. |
42 bool Run(const std::vector<const Target*>& to_check, | 45 bool Run(const std::vector<const Target*>& to_check, |
| 46 bool force_check, |
43 std::vector<Err>* errors); | 47 std::vector<Err>* errors); |
44 | 48 |
45 private: | 49 private: |
46 friend class base::RefCountedThreadSafe<HeaderChecker>; | 50 friend class base::RefCountedThreadSafe<HeaderChecker>; |
47 FRIEND_TEST_ALL_PREFIXES(HeaderCheckerTest, IsDependencyOf); | 51 FRIEND_TEST_ALL_PREFIXES(HeaderCheckerTest, IsDependencyOf); |
48 FRIEND_TEST_ALL_PREFIXES(HeaderCheckerTest, | 52 FRIEND_TEST_ALL_PREFIXES(HeaderCheckerTest, |
49 IsDependencyOf_ForwardsDirectDependentConfigs); | 53 IsDependencyOf_ForwardsDirectDependentConfigs); |
50 FRIEND_TEST_ALL_PREFIXES(HeaderCheckerTest, CheckInclude); | 54 FRIEND_TEST_ALL_PREFIXES(HeaderCheckerTest, CheckInclude); |
| 55 FRIEND_TEST_ALL_PREFIXES(HeaderCheckerTest, CheckIncludeAllowCircular); |
51 FRIEND_TEST_ALL_PREFIXES(HeaderCheckerTest, | 56 FRIEND_TEST_ALL_PREFIXES(HeaderCheckerTest, |
52 GetDependentConfigChainProblemIndex); | 57 GetDependentConfigChainProblemIndex); |
53 ~HeaderChecker(); | 58 ~HeaderChecker(); |
54 | 59 |
55 struct TargetInfo { | 60 struct TargetInfo { |
56 TargetInfo() : target(NULL), is_public(false) {} | 61 TargetInfo() : target(NULL), is_public(false) {} |
57 TargetInfo(const Target* t, bool p) : target(t), is_public(p) {} | 62 TargetInfo(const Target* t, bool p) : target(t), is_public(p) {} |
58 | 63 |
59 const Target* target; | 64 const Target* target; |
60 bool is_public; | 65 bool is_public; |
61 }; | 66 }; |
62 | 67 |
63 typedef std::vector<TargetInfo> TargetVector; | 68 typedef std::vector<TargetInfo> TargetVector; |
64 typedef std::map<SourceFile, TargetVector> FileMap; | 69 typedef std::map<SourceFile, TargetVector> FileMap; |
65 | 70 |
66 // Backend for Run() that takes the list of files to check. The errors_ list | 71 // Backend for Run() that takes the list of files to check. The errors_ list |
67 // will be populate on failure. | 72 // will be populate on failure. |
68 void RunCheckOverFiles(const FileMap& flies); | 73 void RunCheckOverFiles(const FileMap& flies, bool force_check); |
69 | 74 |
70 void DoWork(const Target* target, const SourceFile& file); | 75 void DoWork(const Target* target, const SourceFile& file); |
71 | 76 |
72 // Adds the sources and public files from the given target to the given map. | 77 // Adds the sources and public files from the given target to the given map. |
73 static void AddTargetToFileMap(const Target* target, FileMap* dest); | 78 static void AddTargetToFileMap(const Target* target, FileMap* dest); |
74 | 79 |
75 // Returns true if the given file is in the output directory. | 80 // Returns true if the given file is in the output directory. |
76 bool IsFileInOuputDir(const SourceFile& file) const; | 81 bool IsFileInOuputDir(const SourceFile& file) const; |
77 | 82 |
78 // Resolves the contents of an include to a SourceFile. | 83 // Resolves the contents of an include to a SourceFile. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // These are mutable during runtime and require locking. | 153 // These are mutable during runtime and require locking. |
149 | 154 |
150 base::Lock lock_; | 155 base::Lock lock_; |
151 | 156 |
152 std::vector<Err> errors_; | 157 std::vector<Err> errors_; |
153 | 158 |
154 DISALLOW_COPY_AND_ASSIGN(HeaderChecker); | 159 DISALLOW_COPY_AND_ASSIGN(HeaderChecker); |
155 }; | 160 }; |
156 | 161 |
157 #endif // TOOLS_GN_HEADER_CHECKER_H_ | 162 #endif // TOOLS_GN_HEADER_CHECKER_H_ |
OLD | NEW |