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

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

Issue 561273003: Add public deps to GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 3 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 | « tools/gn/ninja_target_writer_unittest.cc ('k') | tools/gn/target.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_TARGET_H_ 5 #ifndef TOOLS_GN_TARGET_H_
6 #define TOOLS_GN_TARGET_H_ 6 #define TOOLS_GN_TARGET_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 FileList& data() { return data_; } 118 FileList& data() { return data_; }
119 119
120 // Returns true if targets depending on this one should have an order 120 // Returns true if targets depending on this one should have an order
121 // dependency. 121 // dependency.
122 bool hard_dep() const { 122 bool hard_dep() const {
123 return output_type_ == ACTION || 123 return output_type_ == ACTION ||
124 output_type_ == ACTION_FOREACH || 124 output_type_ == ACTION_FOREACH ||
125 output_type_ == COPY_FILES; 125 output_type_ == COPY_FILES;
126 } 126 }
127 127
128 // Linked dependencies. 128 // Linked private dependencies.
129 const LabelTargetVector& deps() const { return deps_; } 129 const LabelTargetVector& private_deps() const { return private_deps_; }
130 LabelTargetVector& deps() { return deps_; } 130 LabelTargetVector& private_deps() { return private_deps_; }
131
132 // Linked public dependencies.
133 const LabelTargetVector& public_deps() const { return public_deps_; }
134 LabelTargetVector& public_deps() { return public_deps_; }
131 135
132 // Non-linked dependencies. 136 // Non-linked dependencies.
133 const LabelTargetVector& datadeps() const { return datadeps_; } 137 const LabelTargetVector& data_deps() const { return data_deps_; }
134 LabelTargetVector& datadeps() { return datadeps_; } 138 LabelTargetVector& data_deps() { return data_deps_; }
135 139
136 // List of configs that this class inherits settings from. Once a target is 140 // List of configs that this class inherits settings from. Once a target is
137 // resolved, this will also list all- and direct-dependent configs. 141 // resolved, this will also list all-dependent and public configs.
138 const UniqueVector<LabelConfigPair>& configs() const { return configs_; } 142 const UniqueVector<LabelConfigPair>& configs() const { return configs_; }
139 UniqueVector<LabelConfigPair>& configs() { return configs_; } 143 UniqueVector<LabelConfigPair>& configs() { return configs_; }
140 144
141 // List of configs that all dependencies (direct and indirect) of this 145 // List of configs that all dependencies (direct and indirect) of this
142 // target get. These configs are not added to this target. Note that due 146 // target get. These configs are not added to this target. Note that due
143 // to the way this is computed, there may be duplicates in this list. 147 // to the way this is computed, there may be duplicates in this list.
144 const UniqueVector<LabelConfigPair>& all_dependent_configs() const { 148 const UniqueVector<LabelConfigPair>& all_dependent_configs() const {
145 return all_dependent_configs_; 149 return all_dependent_configs_;
146 } 150 }
147 UniqueVector<LabelConfigPair>& all_dependent_configs() { 151 UniqueVector<LabelConfigPair>& all_dependent_configs() {
148 return all_dependent_configs_; 152 return all_dependent_configs_;
149 } 153 }
150 154
151 // List of configs that targets depending directly on this one get. These 155 // List of configs that targets depending directly on this one get. These
152 // configs are not added to this target. 156 // configs are also added to this target.
153 const UniqueVector<LabelConfigPair>& direct_dependent_configs() const { 157 const UniqueVector<LabelConfigPair>& public_configs() const {
154 return direct_dependent_configs_; 158 return public_configs_;
155 } 159 }
156 UniqueVector<LabelConfigPair>& direct_dependent_configs() { 160 UniqueVector<LabelConfigPair>& public_configs() {
157 return direct_dependent_configs_; 161 return public_configs_;
158 } 162 }
159 163
160 // A list of a subset of deps where we'll re-export direct_dependent_configs 164 // A list of a subset of deps where we'll re-export public_configs as
161 // as direct_dependent_configs of this target. 165 // public_configs of this target.
162 const UniqueVector<LabelTargetPair>& forward_dependent_configs() const { 166 const UniqueVector<LabelTargetPair>& forward_dependent_configs() const {
163 return forward_dependent_configs_; 167 return forward_dependent_configs_;
164 } 168 }
165 UniqueVector<LabelTargetPair>& forward_dependent_configs() { 169 UniqueVector<LabelTargetPair>& forward_dependent_configs() {
166 return forward_dependent_configs_; 170 return forward_dependent_configs_;
167 } 171 }
168 172
169 // Dependencies that can include files from this target. 173 // Dependencies that can include files from this target.
170 const std::set<Label>& allow_circular_includes_from() const { 174 const std::set<Label>& allow_circular_includes_from() const {
171 return allow_circular_includes_from_; 175 return allow_circular_includes_from_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // that. This is a cache of the files to prevent every target that depends on 221 // that. This is a cache of the files to prevent every target that depends on
218 // a given library from recomputing the same pattern. 222 // a given library from recomputing the same pattern.
219 const OutputFile& link_output_file() const { 223 const OutputFile& link_output_file() const {
220 return link_output_file_; 224 return link_output_file_;
221 } 225 }
222 const OutputFile& dependency_output_file() const { 226 const OutputFile& dependency_output_file() const {
223 return dependency_output_file_; 227 return dependency_output_file_;
224 } 228 }
225 229
226 private: 230 private:
227 void ExpandGroups();
228
229 // Pulls necessary information from dependencies to this one when all 231 // Pulls necessary information from dependencies to this one when all
230 // dependencies have been resolved. 232 // dependencies have been resolved.
231 void PullDependentTargetInfo(); 233 void PullDependentTargetInfo();
232 234
233 // These each pull specific things from dependencies to this one when all 235 // These each pull specific things from dependencies to this one when all
234 // deps have been resolved. 236 // deps have been resolved.
235 void PullForwardedDependentConfigs(); 237 void PullForwardedDependentConfigs();
238 void PullForwardedDependentConfigsFrom(const Target* from);
236 void PullRecursiveHardDeps(); 239 void PullRecursiveHardDeps();
237 240
238 // Fills the link and dependency output files when a target is resolved. 241 // Fills the link and dependency output files when a target is resolved.
239 void FillOutputFiles(); 242 void FillOutputFiles();
240 243
241 // Validates the given thing when a target is resolved. 244 // Validates the given thing when a target is resolved.
242 bool CheckVisibility(Err* err) const; 245 bool CheckVisibility(Err* err) const;
243 bool CheckTestonly(Err* err) const; 246 bool CheckTestonly(Err* err) const;
244 247
245 OutputType output_type_; 248 OutputType output_type_;
246 std::string output_name_; 249 std::string output_name_;
247 std::string output_extension_; 250 std::string output_extension_;
248 251
249 FileList sources_; 252 FileList sources_;
250 bool all_headers_public_; 253 bool all_headers_public_;
251 FileList public_headers_; 254 FileList public_headers_;
252 bool check_includes_; 255 bool check_includes_;
253 bool complete_static_lib_; 256 bool complete_static_lib_;
254 bool testonly_; 257 bool testonly_;
255 FileList inputs_; 258 FileList inputs_;
256 FileList data_; 259 FileList data_;
257 260
258 bool hard_dep_; 261 bool hard_dep_;
259 262
260 // Note that if there are any groups in the deps, once the target is resolved 263 LabelTargetVector private_deps_;
261 // these vectors will list *both* the groups as well as the groups' deps. 264 LabelTargetVector public_deps_;
262 // 265 LabelTargetVector data_deps_;
263 // This is because, in general, groups should be "transparent" ways to add
264 // groups of dependencies, so adding the groups deps make this happen with
265 // no additional complexity when iterating over a target's deps.
266 //
267 // However, a group may also have specific settings and configs added to it,
268 // so we also need the group in the list so we find these things. But you
269 // shouldn't need to look inside the deps of the group since those will
270 // already be added.
271 LabelTargetVector deps_;
272 LabelTargetVector datadeps_;
273 266
274 UniqueVector<LabelConfigPair> configs_; 267 UniqueVector<LabelConfigPair> configs_;
275 UniqueVector<LabelConfigPair> all_dependent_configs_; 268 UniqueVector<LabelConfigPair> all_dependent_configs_;
276 UniqueVector<LabelConfigPair> direct_dependent_configs_; 269 UniqueVector<LabelConfigPair> public_configs_;
277 UniqueVector<LabelTargetPair> forward_dependent_configs_; 270 UniqueVector<LabelTargetPair> forward_dependent_configs_;
278 271
279 std::set<Label> allow_circular_includes_from_; 272 std::set<Label> allow_circular_includes_from_;
280 273
281 bool external_; 274 bool external_;
282 275
283 // Static libraries and source sets from transitive deps. These things need 276 // Static libraries and source sets from transitive deps. These things need
284 // to be linked only with the end target (executable, shared library). Source 277 // to be linked only with the end target (executable, shared library). Source
285 // sets do not get pushed beyond static library boundaries, and neither 278 // sets do not get pushed beyond static library boundaries, and neither
286 // source sets nor static libraries get pushed beyond sahred library 279 // source sets nor static libraries get pushed beyond sahred library
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 }; 312 };
320 #elif defined(COMPILER_MSVC) 313 #elif defined(COMPILER_MSVC)
321 inline size_t hash_value(const Target* t) { 314 inline size_t hash_value(const Target* t) {
322 return reinterpret_cast<size_t>(t); 315 return reinterpret_cast<size_t>(t);
323 } 316 }
324 #endif // COMPILER... 317 #endif // COMPILER...
325 318
326 } // namespace BASE_HASH_NAMESPACE 319 } // namespace BASE_HASH_NAMESPACE
327 320
328 #endif // TOOLS_GN_TARGET_H_ 321 #endif // TOOLS_GN_TARGET_H_
OLDNEW
« no previous file with comments | « tools/gn/ninja_target_writer_unittest.cc ('k') | tools/gn/target.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698