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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 const LocationRange& range, | 108 const LocationRange& range, |
109 Err* err) const; | 109 Err* err) const; |
110 | 110 |
111 // Returns true if the given search_for target is a dependency of | 111 // Returns true if the given search_for target is a dependency of |
112 // search_from. | 112 // search_from. |
113 // | 113 // |
114 // If found, the vector given in "chain" will be filled with the reverse | 114 // If found, the vector given in "chain" will be filled with the reverse |
115 // dependency chain from the dest target (chain[0] = search_for) to the src | 115 // dependency chain from the dest target (chain[0] = search_for) to the src |
116 // target (chain[chain.size() - 1] = search_from). | 116 // target (chain[chain.size() - 1] = search_from). |
117 // | 117 // |
118 // If prefer_direct_dependent_configs is true, chains which forward direct | 118 // Chains with public dependencies will be considered first. If a public |
119 // dependent configs will be considered first, and a chain which does not | 119 // match is found, *is_public will be set to true. A chain with non-public |
120 // will be returned only if no such chain exists. | 120 // dependencies will only be considered if there are no public chains. In |
121 // | 121 // this case, *is_public will be false. |
122 // If direct_dependent_configs_apply is non-null, it will be set to true | |
123 // if the chain was found during a search that requires forwarding direct | |
124 // dependent configs, and false if it was found during a search of the | |
125 // entire dependency graph. | |
126 bool IsDependencyOf(const Target* search_for, | 122 bool IsDependencyOf(const Target* search_for, |
127 const Target* search_from, | 123 const Target* search_from, |
128 bool prefer_direct_dependent_configs, | |
129 std::vector<const Target*>* chain, | 124 std::vector<const Target*>* chain, |
130 bool* direct_dependent_configs_apply) const; | 125 bool* is_public) const; |
131 | 126 |
132 // For internal use by the previous override of IsDependencyOf. | 127 // For internal use by the previous override of IsDependencyOf. If |
133 // If requires_dependent_configs is true, only chains which forward | 128 // require_public is true, only public dependency chains are searched. |
134 // direct dependent configs are considered. | |
135 bool IsDependencyOf(const Target* search_for, | 129 bool IsDependencyOf(const Target* search_for, |
136 const Target* search_from, | 130 const Target* search_from, |
137 bool requires_dependent_configs, | 131 bool require_public, |
138 std::vector<const Target*>* chain) const; | 132 std::vector<const Target*>* chain) const; |
139 | 133 |
140 // Given a reverse dependency chain (chain[0] is the lower-level target, | |
141 // chain[end] is the higher-level target) which does not forward direct | |
142 // dependent configs, determines the index of the target that caused the | |
143 // config to not apply. | |
144 static size_t GetDependentConfigChainProblemIndex( | |
145 const std::vector<const Target*>& chain); | |
146 | |
147 // Non-locked variables ------------------------------------------------------ | 134 // Non-locked variables ------------------------------------------------------ |
148 // | 135 // |
149 // These are initialized during construction (which happens on one thread) | 136 // These are initialized during construction (which happens on one thread) |
150 // and are not modified after, so any thread can read these without locking. | 137 // and are not modified after, so any thread can read these without locking. |
151 | 138 |
152 base::MessageLoop* main_loop_; | 139 base::MessageLoop* main_loop_; |
153 base::RunLoop main_thread_runner_; | 140 base::RunLoop main_thread_runner_; |
154 | 141 |
155 const BuildSettings* build_settings_; | 142 const BuildSettings* build_settings_; |
156 | 143 |
157 // Maps source files to targets it appears in (usually just one target). | 144 // Maps source files to targets it appears in (usually just one target). |
158 FileMap file_map_; | 145 FileMap file_map_; |
159 | 146 |
160 // Locked variables ---------------------------------------------------------- | 147 // Locked variables ---------------------------------------------------------- |
161 // | 148 // |
162 // These are mutable during runtime and require locking. | 149 // These are mutable during runtime and require locking. |
163 | 150 |
164 base::Lock lock_; | 151 base::Lock lock_; |
165 | 152 |
166 std::vector<Err> errors_; | 153 std::vector<Err> errors_; |
167 | 154 |
168 DISALLOW_COPY_AND_ASSIGN(HeaderChecker); | 155 DISALLOW_COPY_AND_ASSIGN(HeaderChecker); |
169 }; | 156 }; |
170 | 157 |
171 #endif // TOOLS_GN_HEADER_CHECKER_H_ | 158 #endif // TOOLS_GN_HEADER_CHECKER_H_ |
OLD | NEW |