| 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/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "tools/gn/action_values.h" | 17 #include "tools/gn/action_values.h" |
| 18 #include "tools/gn/config_values.h" | 18 #include "tools/gn/config_values.h" |
| 19 #include "tools/gn/item.h" | 19 #include "tools/gn/item.h" |
| 20 #include "tools/gn/label_ptr.h" | 20 #include "tools/gn/label_ptr.h" |
| 21 #include "tools/gn/ordered_set.h" | 21 #include "tools/gn/ordered_set.h" |
| 22 #include "tools/gn/output_file.h" | 22 #include "tools/gn/output_file.h" |
| 23 #include "tools/gn/source_file.h" | 23 #include "tools/gn/source_file.h" |
| 24 #include "tools/gn/unique_vector.h" | 24 #include "tools/gn/unique_vector.h" |
| 25 | 25 |
| 26 class DepsIteratorRange; |
| 26 class InputFile; | 27 class InputFile; |
| 27 class Settings; | 28 class Settings; |
| 28 class Token; | 29 class Token; |
| 29 class Toolchain; | 30 class Toolchain; |
| 30 | 31 |
| 31 class Target : public Item { | 32 class Target : public Item { |
| 32 public: | 33 public: |
| 33 enum OutputType { | 34 enum OutputType { |
| 34 UNKNOWN, | 35 UNKNOWN, |
| 35 GROUP, | 36 GROUP, |
| 36 EXECUTABLE, | 37 EXECUTABLE, |
| 37 SHARED_LIBRARY, | 38 SHARED_LIBRARY, |
| 38 STATIC_LIBRARY, | 39 STATIC_LIBRARY, |
| 39 SOURCE_SET, | 40 SOURCE_SET, |
| 40 COPY_FILES, | 41 COPY_FILES, |
| 41 ACTION, | 42 ACTION, |
| 42 ACTION_FOREACH, | 43 ACTION_FOREACH, |
| 43 }; | 44 }; |
| 45 |
| 46 enum DepsIterationType { |
| 47 DEPS_ALL, // Iterates through all public, private, and data deps. |
| 48 DEPS_LINKED, // Iterates through all non-data dependencies. |
| 49 }; |
| 50 |
| 44 typedef std::vector<SourceFile> FileList; | 51 typedef std::vector<SourceFile> FileList; |
| 45 typedef std::vector<std::string> StringVector; | 52 typedef std::vector<std::string> StringVector; |
| 46 | 53 |
| 47 Target(const Settings* settings, const Label& label); | 54 Target(const Settings* settings, const Label& label); |
| 48 virtual ~Target(); | 55 virtual ~Target(); |
| 49 | 56 |
| 50 // Returns a string naming the output type. | 57 // Returns a string naming the output type. |
| 51 static const char* GetStringForOutputType(OutputType type); | 58 static const char* GetStringForOutputType(OutputType type); |
| 52 | 59 |
| 53 // Item overrides. | 60 // Item overrides. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 FileList& data() { return data_; } | 125 FileList& data() { return data_; } |
| 119 | 126 |
| 120 // Returns true if targets depending on this one should have an order | 127 // Returns true if targets depending on this one should have an order |
| 121 // dependency. | 128 // dependency. |
| 122 bool hard_dep() const { | 129 bool hard_dep() const { |
| 123 return output_type_ == ACTION || | 130 return output_type_ == ACTION || |
| 124 output_type_ == ACTION_FOREACH || | 131 output_type_ == ACTION_FOREACH || |
| 125 output_type_ == COPY_FILES; | 132 output_type_ == COPY_FILES; |
| 126 } | 133 } |
| 127 | 134 |
| 135 // Returns the iterator range which can be used in range-based for loops |
| 136 // to iterate over multiple types of deps in one loop: |
| 137 // for (const auto& pair : target->GetDeps(Target::DEPS_ALL)) ... |
| 138 DepsIteratorRange GetDeps(DepsIterationType type) const; |
| 139 |
| 128 // Linked private dependencies. | 140 // Linked private dependencies. |
| 129 const LabelTargetVector& private_deps() const { return private_deps_; } | 141 const LabelTargetVector& private_deps() const { return private_deps_; } |
| 130 LabelTargetVector& private_deps() { return private_deps_; } | 142 LabelTargetVector& private_deps() { return private_deps_; } |
| 131 | 143 |
| 132 // Linked public dependencies. | 144 // Linked public dependencies. |
| 133 const LabelTargetVector& public_deps() const { return public_deps_; } | 145 const LabelTargetVector& public_deps() const { return public_deps_; } |
| 134 LabelTargetVector& public_deps() { return public_deps_; } | 146 LabelTargetVector& public_deps() { return public_deps_; } |
| 135 | 147 |
| 136 // Non-linked dependencies. | 148 // Non-linked dependencies. |
| 137 const LabelTargetVector& data_deps() const { return data_deps_; } | 149 const LabelTargetVector& data_deps() const { return data_deps_; } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 }; | 325 }; |
| 314 #elif defined(COMPILER_MSVC) | 326 #elif defined(COMPILER_MSVC) |
| 315 inline size_t hash_value(const Target* t) { | 327 inline size_t hash_value(const Target* t) { |
| 316 return reinterpret_cast<size_t>(t); | 328 return reinterpret_cast<size_t>(t); |
| 317 } | 329 } |
| 318 #endif // COMPILER... | 330 #endif // COMPILER... |
| 319 | 331 |
| 320 } // namespace BASE_HASH_NAMESPACE | 332 } // namespace BASE_HASH_NAMESPACE |
| 321 | 333 |
| 322 #endif // TOOLS_GN_TARGET_H_ | 334 #endif // TOOLS_GN_TARGET_H_ |
| OLD | NEW |