| 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/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "tools/gn/action_values.h" | 15 #include "tools/gn/action_values.h" |
| 16 #include "tools/gn/config_values.h" | 16 #include "tools/gn/config_values.h" |
| 17 #include "tools/gn/inherited_libraries.h" | 17 #include "tools/gn/inherited_libraries.h" |
| 18 #include "tools/gn/item.h" | 18 #include "tools/gn/item.h" |
| 19 #include "tools/gn/label_pattern.h" | 19 #include "tools/gn/label_pattern.h" |
| 20 #include "tools/gn/label_ptr.h" | 20 #include "tools/gn/label_ptr.h" |
| 21 #include "tools/gn/lib_file.h" | 21 #include "tools/gn/lib_file.h" |
| 22 #include "tools/gn/ordered_set.h" | 22 #include "tools/gn/ordered_set.h" |
| 23 #include "tools/gn/output_file.h" | 23 #include "tools/gn/output_file.h" |
| 24 #include "tools/gn/pattern.h" |
| 24 #include "tools/gn/source_file.h" | 25 #include "tools/gn/source_file.h" |
| 25 #include "tools/gn/toolchain.h" | 26 #include "tools/gn/toolchain.h" |
| 26 #include "tools/gn/unique_vector.h" | 27 #include "tools/gn/unique_vector.h" |
| 27 | 28 |
| 28 class DepsIteratorRange; | 29 class DepsIteratorRange; |
| 29 class InputFile; | 30 class InputFile; |
| 30 class Settings; | 31 class Settings; |
| 31 class Token; | 32 class Token; |
| 32 class Toolchain; | 33 class Toolchain; |
| 33 | 34 |
| 34 class Target : public Item { | 35 class Target : public Item { |
| 35 public: | 36 public: |
| 36 enum OutputType { | 37 enum OutputType { |
| 37 UNKNOWN, | 38 UNKNOWN, |
| 38 GROUP, | 39 GROUP, |
| 39 EXECUTABLE, | 40 EXECUTABLE, |
| 40 SHARED_LIBRARY, | 41 SHARED_LIBRARY, |
| 41 LOADABLE_MODULE, | 42 LOADABLE_MODULE, |
| 42 STATIC_LIBRARY, | 43 STATIC_LIBRARY, |
| 43 SOURCE_SET, | 44 SOURCE_SET, |
| 44 COPY_FILES, | 45 COPY_FILES, |
| 46 COPY_BUNDLE_DATA, |
| 45 ACTION, | 47 ACTION, |
| 46 ACTION_FOREACH, | 48 ACTION_FOREACH, |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 enum DepsIterationType { | 51 enum DepsIterationType { |
| 50 DEPS_ALL, // Iterates through all public, private, and data deps. | 52 DEPS_ALL, // Iterates through all public, private, and data deps. |
| 51 DEPS_LINKED, // Iterates through all non-data dependencies. | 53 DEPS_LINKED, // Iterates through all non-data dependencies. |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 typedef std::vector<SourceFile> FileList; | 56 typedef std::vector<SourceFile> FileList; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // Compile-time extra dependencies. | 130 // Compile-time extra dependencies. |
| 129 const FileList& inputs() const { return inputs_; } | 131 const FileList& inputs() const { return inputs_; } |
| 130 FileList& inputs() { return inputs_; } | 132 FileList& inputs() { return inputs_; } |
| 131 | 133 |
| 132 // Runtime dependencies. These are "file-like things" that can either be | 134 // Runtime dependencies. These are "file-like things" that can either be |
| 133 // directories or files. They do not need to exist, these are just passed as | 135 // directories or files. They do not need to exist, these are just passed as |
| 134 // runtime dependencies to external test systems as necessary. | 136 // runtime dependencies to external test systems as necessary. |
| 135 const std::vector<std::string>& data() const { return data_; } | 137 const std::vector<std::string>& data() const { return data_; } |
| 136 std::vector<std::string>& data() { return data_; } | 138 std::vector<std::string>& data() { return data_; } |
| 137 | 139 |
| 140 // Runtime file dependency for bundled application (Mac/iOS). Those files |
| 141 // are collected recursively (breaking at executable, shared library and |
| 142 // loadable modules). |
| 143 const std::set<SourceFile>& bundle_data() const { return bundle_data_; } |
| 144 std::set<SourceFile>& bundle_data() { return bundle_data_; } |
| 145 |
| 146 // Filter for copy_bundle_data target. All files matching this pattern |
| 147 // will be excluded from the copy. |
| 148 const PatternList& bundle_data_filter() const { return bundle_data_filter_; } |
| 149 PatternList& bundle_data_filter() { return bundle_data_filter_; } |
| 150 |
| 138 // Returns true if targets depending on this one should have an order | 151 // Returns true if targets depending on this one should have an order |
| 139 // dependency. | 152 // dependency. |
| 140 bool hard_dep() const { | 153 bool hard_dep() const { |
| 141 return output_type_ == ACTION || | 154 return output_type_ == ACTION || |
| 142 output_type_ == ACTION_FOREACH || | 155 output_type_ == ACTION_FOREACH || |
| 143 output_type_ == COPY_FILES; | 156 output_type_ == COPY_FILES; |
| 144 } | 157 } |
| 145 | 158 |
| 146 // Returns the iterator range which can be used in range-based for loops | 159 // Returns the iterator range which can be used in range-based for loops |
| 147 // to iterate over multiple types of deps in one loop: | 160 // to iterate over multiple types of deps in one loop: |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 private: | 286 private: |
| 274 FRIEND_TEST_ALL_PREFIXES(Target, ResolvePrecompiledHeaders); | 287 FRIEND_TEST_ALL_PREFIXES(Target, ResolvePrecompiledHeaders); |
| 275 | 288 |
| 276 // Pulls necessary information from dependencies to this one when all | 289 // Pulls necessary information from dependencies to this one when all |
| 277 // dependencies have been resolved. | 290 // dependencies have been resolved. |
| 278 void PullDependentTargetConfigsFrom(const Target* dep); | 291 void PullDependentTargetConfigsFrom(const Target* dep); |
| 279 void PullDependentTargetConfigs(); | 292 void PullDependentTargetConfigs(); |
| 280 void PullDependentTargetLibsFrom(const Target* dep, bool is_public); | 293 void PullDependentTargetLibsFrom(const Target* dep, bool is_public); |
| 281 void PullDependentTargetLibs(); | 294 void PullDependentTargetLibs(); |
| 282 void PullRecursiveHardDeps(); | 295 void PullRecursiveHardDeps(); |
| 296 void PullRecursiveBundleData(); |
| 283 | 297 |
| 284 // Fills the link and dependency output files when a target is resolved. | 298 // Fills the link and dependency output files when a target is resolved. |
| 285 void FillOutputFiles(); | 299 void FillOutputFiles(); |
| 286 | 300 |
| 287 // Checks precompiled headers from configs and makes sure the resulting | 301 // Checks precompiled headers from configs and makes sure the resulting |
| 288 // values are in config_values_. | 302 // values are in config_values_. |
| 289 bool ResolvePrecompiledHeaders(Err* err); | 303 bool ResolvePrecompiledHeaders(Err* err); |
| 290 | 304 |
| 291 // Validates the given thing when a target is resolved. | 305 // Validates the given thing when a target is resolved. |
| 292 bool CheckVisibility(Err* err) const; | 306 bool CheckVisibility(Err* err) const; |
| 293 bool CheckTestonly(Err* err) const; | 307 bool CheckTestonly(Err* err) const; |
| 294 bool CheckNoNestedStaticLibs(Err* err) const; | 308 bool CheckNoNestedStaticLibs(Err* err) const; |
| 295 bool CheckAssertNoDeps(Err* err) const; | 309 bool CheckAssertNoDeps(Err* err) const; |
| 296 void CheckSourcesGenerated() const; | 310 void CheckSourcesGenerated() const; |
| 297 void CheckSourceGenerated(const SourceFile& source) const; | 311 void CheckSourceGenerated(const SourceFile& source) const; |
| 298 | 312 |
| 299 OutputType output_type_; | 313 OutputType output_type_; |
| 300 std::string output_name_; | 314 std::string output_name_; |
| 301 std::string output_extension_; | 315 std::string output_extension_; |
| 302 | 316 |
| 303 FileList sources_; | 317 FileList sources_; |
| 304 bool all_headers_public_; | 318 bool all_headers_public_; |
| 305 FileList public_headers_; | 319 FileList public_headers_; |
| 306 bool check_includes_; | 320 bool check_includes_; |
| 307 bool complete_static_lib_; | 321 bool complete_static_lib_; |
| 308 bool testonly_; | 322 bool testonly_; |
| 309 FileList inputs_; | 323 FileList inputs_; |
| 324 std::set<SourceFile> bundle_data_; |
| 310 std::vector<std::string> data_; | 325 std::vector<std::string> data_; |
| 326 PatternList bundle_data_filter_; |
| 311 | 327 |
| 312 LabelTargetVector private_deps_; | 328 LabelTargetVector private_deps_; |
| 313 LabelTargetVector public_deps_; | 329 LabelTargetVector public_deps_; |
| 314 LabelTargetVector data_deps_; | 330 LabelTargetVector data_deps_; |
| 315 | 331 |
| 316 // See getters for more info. | 332 // See getters for more info. |
| 317 UniqueVector<LabelConfigPair> configs_; | 333 UniqueVector<LabelConfigPair> configs_; |
| 318 UniqueVector<LabelConfigPair> all_dependent_configs_; | 334 UniqueVector<LabelConfigPair> all_dependent_configs_; |
| 319 UniqueVector<LabelConfigPair> public_configs_; | 335 UniqueVector<LabelConfigPair> public_configs_; |
| 320 | 336 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 348 | 364 |
| 349 // Output files. Empty until the target is resolved. | 365 // Output files. Empty until the target is resolved. |
| 350 std::vector<OutputFile> computed_outputs_; | 366 std::vector<OutputFile> computed_outputs_; |
| 351 OutputFile link_output_file_; | 367 OutputFile link_output_file_; |
| 352 OutputFile dependency_output_file_; | 368 OutputFile dependency_output_file_; |
| 353 | 369 |
| 354 DISALLOW_COPY_AND_ASSIGN(Target); | 370 DISALLOW_COPY_AND_ASSIGN(Target); |
| 355 }; | 371 }; |
| 356 | 372 |
| 357 #endif // TOOLS_GN_TARGET_H_ | 373 #endif // TOOLS_GN_TARGET_H_ |
| OLD | NEW |