OLD | NEW |
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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/gtest_prod_util.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
15 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
16 #include "tools/gn/action_values.h" | 17 #include "tools/gn/action_values.h" |
17 #include "tools/gn/config_values.h" | 18 #include "tools/gn/config_values.h" |
18 #include "tools/gn/inherited_libraries.h" | 19 #include "tools/gn/inherited_libraries.h" |
19 #include "tools/gn/item.h" | 20 #include "tools/gn/item.h" |
20 #include "tools/gn/label_ptr.h" | 21 #include "tools/gn/label_ptr.h" |
21 #include "tools/gn/ordered_set.h" | 22 #include "tools/gn/ordered_set.h" |
22 #include "tools/gn/output_file.h" | 23 #include "tools/gn/output_file.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // that. This is a cache of the files to prevent every target that depends on | 246 // that. This is a cache of the files to prevent every target that depends on |
246 // a given library from recomputing the same pattern. | 247 // a given library from recomputing the same pattern. |
247 const OutputFile& link_output_file() const { | 248 const OutputFile& link_output_file() const { |
248 return link_output_file_; | 249 return link_output_file_; |
249 } | 250 } |
250 const OutputFile& dependency_output_file() const { | 251 const OutputFile& dependency_output_file() const { |
251 return dependency_output_file_; | 252 return dependency_output_file_; |
252 } | 253 } |
253 | 254 |
254 private: | 255 private: |
| 256 FRIEND_TEST_ALL_PREFIXES(Target, ResolvePrecompiledHeaders); |
| 257 |
255 // Pulls necessary information from dependencies to this one when all | 258 // Pulls necessary information from dependencies to this one when all |
256 // dependencies have been resolved. | 259 // dependencies have been resolved. |
257 void PullDependentTarget(const Target* dep, bool is_public); | 260 void PullDependentTarget(const Target* dep, bool is_public); |
258 void PullDependentTargets(); | 261 void PullDependentTargets(); |
259 | 262 |
260 // These each pull specific things from dependencies to this one when all | 263 // These each pull specific things from dependencies to this one when all |
261 // deps have been resolved. | 264 // deps have been resolved. |
262 void PullForwardedDependentConfigs(); | 265 void PullForwardedDependentConfigs(); |
263 void PullForwardedDependentConfigsFrom(const Target* from); | 266 void PullForwardedDependentConfigsFrom(const Target* from); |
264 void PullRecursiveHardDeps(); | 267 void PullRecursiveHardDeps(); |
265 | 268 |
266 // Fills the link and dependency output files when a target is resolved. | 269 // Fills the link and dependency output files when a target is resolved. |
267 void FillOutputFiles(); | 270 void FillOutputFiles(); |
268 | 271 |
| 272 // Checks precompiled headers from configs and makes sure the resulting |
| 273 // values are in config_values_. |
| 274 bool ResolvePrecompiledHeaders(Err* err); |
| 275 |
269 // Validates the given thing when a target is resolved. | 276 // Validates the given thing when a target is resolved. |
270 bool CheckVisibility(Err* err) const; | 277 bool CheckVisibility(Err* err) const; |
271 bool CheckTestonly(Err* err) const; | 278 bool CheckTestonly(Err* err) const; |
272 bool CheckNoNestedStaticLibs(Err* err) const; | 279 bool CheckNoNestedStaticLibs(Err* err) const; |
273 void CheckSourcesGenerated() const; | 280 void CheckSourcesGenerated() const; |
274 void CheckSourceGenerated(const SourceFile& source) const; | 281 void CheckSourceGenerated(const SourceFile& source) const; |
275 | 282 |
276 OutputType output_type_; | 283 OutputType output_type_; |
277 std::string output_name_; | 284 std::string output_name_; |
278 std::string output_extension_; | 285 std::string output_extension_; |
(...skipping 24 matching lines...) Expand all Loading... |
303 | 310 |
304 // These libs and dirs are inherited from statically linked deps and all | 311 // These libs and dirs are inherited from statically linked deps and all |
305 // configs applying to this target. | 312 // configs applying to this target. |
306 OrderedSet<SourceDir> all_lib_dirs_; | 313 OrderedSet<SourceDir> all_lib_dirs_; |
307 OrderedSet<std::string> all_libs_; | 314 OrderedSet<std::string> all_libs_; |
308 | 315 |
309 // All hard deps from this target and all dependencies. Filled in when this | 316 // All hard deps from this target and all dependencies. Filled in when this |
310 // target is marked resolved. This will not include the current target. | 317 // target is marked resolved. This will not include the current target. |
311 std::set<const Target*> recursive_hard_deps_; | 318 std::set<const Target*> recursive_hard_deps_; |
312 | 319 |
313 ConfigValues config_values_; // Used for all binary targets. | 320 // Used for all binary targets. The precompiled header values in this struct |
314 ActionValues action_values_; // Used for action[_foreach] targets. | 321 // will be resolved to the ones to use for this target, if precompiled |
| 322 // headers are used. |
| 323 ConfigValues config_values_; |
| 324 |
| 325 // Used for action[_foreach] targets. |
| 326 ActionValues action_values_; |
315 | 327 |
316 // Toolchain used by this target. Null until target is resolved. | 328 // Toolchain used by this target. Null until target is resolved. |
317 const Toolchain* toolchain_; | 329 const Toolchain* toolchain_; |
318 | 330 |
319 // Output files. Empty until the target is resolved. | 331 // Output files. Empty until the target is resolved. |
320 std::vector<OutputFile> computed_outputs_; | 332 std::vector<OutputFile> computed_outputs_; |
321 OutputFile link_output_file_; | 333 OutputFile link_output_file_; |
322 OutputFile dependency_output_file_; | 334 OutputFile dependency_output_file_; |
323 | 335 |
324 DISALLOW_COPY_AND_ASSIGN(Target); | 336 DISALLOW_COPY_AND_ASSIGN(Target); |
325 }; | 337 }; |
326 | 338 |
327 #endif // TOOLS_GN_TARGET_H_ | 339 #endif // TOOLS_GN_TARGET_H_ |
OLD | NEW |