| 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/config_values.h" | 17 #include "tools/gn/config_values.h" |
| 18 #include "tools/gn/item.h" | 18 #include "tools/gn/item.h" |
| 19 #include "tools/gn/label_ptr.h" |
| 19 #include "tools/gn/ordered_set.h" | 20 #include "tools/gn/ordered_set.h" |
| 20 #include "tools/gn/script_values.h" | 21 #include "tools/gn/script_values.h" |
| 21 #include "tools/gn/source_file.h" | 22 #include "tools/gn/source_file.h" |
| 22 | 23 |
| 23 class InputFile; | 24 class InputFile; |
| 24 class Settings; | 25 class Settings; |
| 25 class Token; | 26 class Token; |
| 26 | 27 |
| 27 class Target : public Item { | 28 class Target : public Item { |
| 28 public: | 29 public: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 78 |
| 78 // Runtime dependencies. | 79 // Runtime dependencies. |
| 79 const FileList& data() const { return data_; } | 80 const FileList& data() const { return data_; } |
| 80 FileList& data() { return data_; } | 81 FileList& data() { return data_; } |
| 81 | 82 |
| 82 // Targets depending on this one should have an order dependency. | 83 // Targets depending on this one should have an order dependency. |
| 83 bool hard_dep() const { return hard_dep_; } | 84 bool hard_dep() const { return hard_dep_; } |
| 84 void set_hard_dep(bool hd) { hard_dep_ = hd; } | 85 void set_hard_dep(bool hd) { hard_dep_ = hd; } |
| 85 | 86 |
| 86 // Linked dependencies. | 87 // Linked dependencies. |
| 87 const std::vector<const Target*>& deps() const { return deps_; } | 88 const LabelTargetVector& deps() const { return deps_; } |
| 88 std::vector<const Target*>& deps() { return deps_; } | 89 LabelTargetVector& deps() { return deps_; } |
| 89 | 90 |
| 90 // Non-linked dependencies. | 91 // Non-linked dependencies. |
| 91 const std::vector<const Target*>& datadeps() const { return datadeps_; } | 92 const LabelTargetVector& datadeps() const { return datadeps_; } |
| 92 std::vector<const Target*>& datadeps() { return datadeps_; } | 93 LabelTargetVector& datadeps() { return datadeps_; } |
| 93 | 94 |
| 94 // List of configs that this class inherits settings from. | 95 // List of configs that this class inherits settings from. |
| 95 const std::vector<const Config*>& configs() const { return configs_; } | 96 const LabelConfigVector& configs() const { return configs_; } |
| 96 std::vector<const Config*>& configs() { return configs_; } | 97 LabelConfigVector& configs() { return configs_; } |
| 97 | 98 |
| 98 // List of configs that all dependencies (direct and indirect) of this | 99 // List of configs that all dependencies (direct and indirect) of this |
| 99 // target get. These configs are not added to this target. Note that due | 100 // target get. These configs are not added to this target. Note that due |
| 100 // to the way this is computed, there may be duplicates in this list. | 101 // to the way this is computed, there may be duplicates in this list. |
| 101 const std::vector<const Config*>& all_dependent_configs() const { | 102 const LabelConfigVector& all_dependent_configs() const { |
| 102 return all_dependent_configs_; | 103 return all_dependent_configs_; |
| 103 } | 104 } |
| 104 std::vector<const Config*>& all_dependent_configs() { | 105 LabelConfigVector& all_dependent_configs() { |
| 105 return all_dependent_configs_; | 106 return all_dependent_configs_; |
| 106 } | 107 } |
| 107 | 108 |
| 108 // List of configs that targets depending directly on this one get. These | 109 // List of configs that targets depending directly on this one get. These |
| 109 // configs are not added to this target. | 110 // configs are not added to this target. |
| 110 const std::vector<const Config*>& direct_dependent_configs() const { | 111 const LabelConfigVector& direct_dependent_configs() const { |
| 111 return direct_dependent_configs_; | 112 return direct_dependent_configs_; |
| 112 } | 113 } |
| 113 std::vector<const Config*>& direct_dependent_configs() { | 114 LabelConfigVector& direct_dependent_configs() { |
| 114 return direct_dependent_configs_; | 115 return direct_dependent_configs_; |
| 115 } | 116 } |
| 116 | 117 |
| 117 // A list of a subset of deps where we'll re-export direct_dependent_configs | 118 // A list of a subset of deps where we'll re-export direct_dependent_configs |
| 118 // as direct_dependent_configs of this target. | 119 // as direct_dependent_configs of this target. |
| 119 const std::vector<const Target*>& forward_dependent_configs() const { | 120 const LabelTargetVector& forward_dependent_configs() const { |
| 120 return forward_dependent_configs_; | 121 return forward_dependent_configs_; |
| 121 } | 122 } |
| 122 std::vector<const Target*>& forward_dependent_configs() { | 123 LabelTargetVector& forward_dependent_configs() { |
| 123 return forward_dependent_configs_; | 124 return forward_dependent_configs_; |
| 124 } | 125 } |
| 125 | 126 |
| 126 bool external() const { return external_; } | 127 bool external() const { return external_; } |
| 127 void set_external(bool e) { external_ = e; } | 128 void set_external(bool e) { external_ = e; } |
| 128 | 129 |
| 129 const std::set<const Target*>& inherited_libraries() const { | 130 const std::set<const Target*>& inherited_libraries() const { |
| 130 return inherited_libraries_; | 131 return inherited_libraries_; |
| 131 } | 132 } |
| 132 | 133 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 162 // these vectors will list *both* the groups as well as the groups' deps. | 163 // these vectors will list *both* the groups as well as the groups' deps. |
| 163 // | 164 // |
| 164 // This is because, in general, groups should be "transparent" ways to add | 165 // This is because, in general, groups should be "transparent" ways to add |
| 165 // groups of dependencies, so adding the groups deps make this happen with | 166 // groups of dependencies, so adding the groups deps make this happen with |
| 166 // no additional complexity when iterating over a target's deps. | 167 // no additional complexity when iterating over a target's deps. |
| 167 // | 168 // |
| 168 // However, a group may also have specific settings and configs added to it, | 169 // However, a group may also have specific settings and configs added to it, |
| 169 // so we also need the group in the list so we find these things. But you | 170 // so we also need the group in the list so we find these things. But you |
| 170 // shouldn't need to look inside the deps of the group since those will | 171 // shouldn't need to look inside the deps of the group since those will |
| 171 // already be added. | 172 // already be added. |
| 172 std::vector<const Target*> deps_; | 173 LabelTargetVector deps_; |
| 173 std::vector<const Target*> datadeps_; | 174 LabelTargetVector datadeps_; |
| 174 | 175 |
| 175 std::vector<const Config*> configs_; | 176 LabelConfigVector configs_; |
| 176 std::vector<const Config*> all_dependent_configs_; | 177 LabelConfigVector all_dependent_configs_; |
| 177 std::vector<const Config*> direct_dependent_configs_; | 178 LabelConfigVector direct_dependent_configs_; |
| 178 std::vector<const Target*> forward_dependent_configs_; | 179 LabelTargetVector forward_dependent_configs_; |
| 179 | 180 |
| 180 bool external_; | 181 bool external_; |
| 181 | 182 |
| 182 // Static libraries and source sets from transitive deps. These things need | 183 // Static libraries and source sets from transitive deps. These things need |
| 183 // to be linked only with the end target (executable, shared library). These | 184 // to be linked only with the end target (executable, shared library). These |
| 184 // do not get pushed beyond shared library boundaries. | 185 // do not get pushed beyond shared library boundaries. |
| 185 std::set<const Target*> inherited_libraries_; | 186 std::set<const Target*> inherited_libraries_; |
| 186 | 187 |
| 187 // These libs and dirs are inherited from statically linked deps and all | 188 // These libs and dirs are inherited from statically linked deps and all |
| 188 // configs applying to this target. | 189 // configs applying to this target. |
| 189 OrderedSet<SourceDir> all_lib_dirs_; | 190 OrderedSet<SourceDir> all_lib_dirs_; |
| 190 OrderedSet<std::string> all_libs_; | 191 OrderedSet<std::string> all_libs_; |
| 191 | 192 |
| 192 ConfigValues config_values_; // Used for all binary targets. | 193 ConfigValues config_values_; // Used for all binary targets. |
| 193 ScriptValues script_values_; // Used for script (CUSTOM) targets. | 194 ScriptValues script_values_; // Used for script (CUSTOM) targets. |
| 194 | 195 |
| 195 SourceFile gyp_file_; | 196 SourceFile gyp_file_; |
| 196 | 197 |
| 197 bool generated_; | 198 bool generated_; |
| 198 const Token* generator_function_; // Who generated this: for error messages. | 199 const Token* generator_function_; // Who generated this: for error messages. |
| 199 | 200 |
| 200 DISALLOW_COPY_AND_ASSIGN(Target); | 201 DISALLOW_COPY_AND_ASSIGN(Target); |
| 201 }; | 202 }; |
| 202 | 203 |
| 203 #endif // TOOLS_GN_TARGET_H_ | 204 #endif // TOOLS_GN_TARGET_H_ |
| OLD | NEW |