[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef TOOLS_GN_TARGET_H_ |
| 6 | #define TOOLS_GN_TARGET_H_ |
| 7 | |
| 8 | #include <set> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
| 12 | #include "base/basictypes.h" |
| 13 | #include "base/compiler_specific.h" |
| 14 | #include "base/logging.h" |
| 15 | #include "base/strings/string_piece.h" |
| 16 | #include "base/synchronization/lock.h" |
[email protected] | 2fbe101 | 2014-03-20 17:59:15 | [diff] [blame] | 17 | #include "tools/gn/action_values.h" |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 18 | #include "tools/gn/config_values.h" |
| 19 | #include "tools/gn/item.h" |
[email protected] | 68d1dd3 | 2013-11-01 21:59:51 | [diff] [blame] | 20 | #include "tools/gn/label_ptr.h" |
[email protected] | b1e468f | 2013-09-10 22:58:02 | [diff] [blame] | 21 | #include "tools/gn/ordered_set.h" |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 22 | #include "tools/gn/output_file.h" |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 23 | #include "tools/gn/source_file.h" |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 24 | #include "tools/gn/unique_vector.h" |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 25 | |
| 26 | class InputFile; |
| 27 | class Settings; |
| 28 | class Token; |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 29 | class Toolchain; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 30 | |
| 31 | class Target : public Item { |
| 32 | public: |
| 33 | enum OutputType { |
[email protected] | c0822d7f | 2013-08-13 17:10:56 | [diff] [blame] | 34 | UNKNOWN, |
| 35 | GROUP, |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 36 | EXECUTABLE, |
| 37 | SHARED_LIBRARY, |
| 38 | STATIC_LIBRARY, |
[email protected] | 7ff2f5d | 2013-10-08 21:30:34 | [diff] [blame] | 39 | SOURCE_SET, |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 40 | COPY_FILES, |
[email protected] | 2fbe101 | 2014-03-20 17:59:15 | [diff] [blame] | 41 | ACTION, |
| 42 | ACTION_FOREACH, |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 43 | }; |
| 44 | typedef std::vector<SourceFile> FileList; |
| 45 | typedef std::vector<std::string> StringVector; |
| 46 | |
| 47 | Target(const Settings* settings, const Label& label); |
| 48 | virtual ~Target(); |
| 49 | |
[email protected] | ac1128e | 2013-08-23 00:26:56 | [diff] [blame] | 50 | // Returns a string naming the output type. |
| 51 | static const char* GetStringForOutputType(OutputType type); |
| 52 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 53 | // Item overrides. |
| 54 | virtual Target* AsTarget() OVERRIDE; |
| 55 | virtual const Target* AsTarget() const OVERRIDE; |
Brett Wilson | 85423a0 | 2014-09-02 19:29:42 | [diff] [blame] | 56 | virtual bool OnResolved(Err* err) OVERRIDE; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 57 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 58 | OutputType output_type() const { return output_type_; } |
| 59 | void set_output_type(OutputType t) { output_type_ = t; } |
| 60 | |
cmasone | a426cf93 | 2014-09-13 00:51:47 | [diff] [blame] | 61 | // Can be linked into other targets. |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 62 | bool IsLinkable() const; |
| 63 | |
cmasone | a426cf93 | 2014-09-13 00:51:47 | [diff] [blame] | 64 | // Can have dependencies linked in. |
| 65 | bool IsFinal() const; |
| 66 | |
[email protected] | b5c19e3 | 2013-09-10 23:01:25 | [diff] [blame] | 67 | // Will be the empty string to use the target label as the output name. |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 68 | // See GetComputedOutputName(). |
[email protected] | b5c19e3 | 2013-09-10 23:01:25 | [diff] [blame] | 69 | const std::string& output_name() const { return output_name_; } |
| 70 | void set_output_name(const std::string& name) { output_name_ = name; } |
| 71 | |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 72 | // Returns the output name for this target, which is the output_name if |
| 73 | // specified, or the target label if not. If the flag is set, it will also |
| 74 | // include any output prefix specified on the tool (often "lib" on Linux). |
| 75 | // |
| 76 | // Because this depends on the tool for this target, the toolchain must |
| 77 | // have been set before calling. |
| 78 | std::string GetComputedOutputName(bool include_prefix) const; |
| 79 | |
[email protected] | b9473ee | 2014-02-28 21:51:10 | [diff] [blame] | 80 | const std::string& output_extension() const { return output_extension_; } |
| 81 | void set_output_extension(const std::string& extension) { |
| 82 | output_extension_ = extension; |
| 83 | } |
| 84 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 85 | const FileList& sources() const { return sources_; } |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 86 | FileList& sources() { return sources_; } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 87 | |
[email protected] | 126d8b5 | 2014-04-07 22:17:35 | [diff] [blame] | 88 | // Set to true when all sources are public. This is the default. In this case |
| 89 | // the public headers list should be empty. |
| 90 | bool all_headers_public() const { return all_headers_public_; } |
| 91 | void set_all_headers_public(bool p) { all_headers_public_ = p; } |
| 92 | |
| 93 | // When all_headers_public is false, this is the list of public headers. It |
| 94 | // could be empty which would mean no headers are public. |
| 95 | const FileList& public_headers() const { return public_headers_; } |
| 96 | FileList& public_headers() { return public_headers_; } |
| 97 | |
brettw | 81db36a | 2014-08-29 22:52:36 | [diff] [blame] | 98 | // Whether this target's includes should be checked by "gn check". |
| 99 | bool check_includes() const { return check_includes_; } |
| 100 | void set_check_includes(bool ci) { check_includes_ = ci; } |
| 101 | |
cmasone | a426cf93 | 2014-09-13 00:51:47 | [diff] [blame] | 102 | // Whether this static_library target should have code linked in. |
| 103 | bool complete_static_lib() const { return complete_static_lib_; } |
| 104 | void set_complete_static_lib(bool complete) { |
| 105 | DCHECK_EQ(STATIC_LIBRARY, output_type_); |
| 106 | complete_static_lib_ = complete; |
| 107 | } |
| 108 | |
Brett Wilson | 85423a0 | 2014-09-02 19:29:42 | [diff] [blame] | 109 | bool testonly() const { return testonly_; } |
| 110 | void set_testonly(bool value) { testonly_ = value; } |
| 111 | |
[email protected] | 234be520 | 2013-09-11 20:44:02 | [diff] [blame] | 112 | // Compile-time extra dependencies. |
[email protected] | 61a6fca | 2014-06-17 20:26:53 | [diff] [blame] | 113 | const FileList& inputs() const { return inputs_; } |
| 114 | FileList& inputs() { return inputs_; } |
[email protected] | 234be520 | 2013-09-11 20:44:02 | [diff] [blame] | 115 | |
| 116 | // Runtime dependencies. |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 117 | const FileList& data() const { return data_; } |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 118 | FileList& data() { return data_; } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 119 | |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 120 | // Returns true if targets depending on this one should have an order |
| 121 | // dependency. |
| 122 | bool hard_dep() const { |
| 123 | return output_type_ == ACTION || |
| 124 | output_type_ == ACTION_FOREACH || |
| 125 | output_type_ == COPY_FILES; |
| 126 | } |
[email protected] | 234be520 | 2013-09-11 20:44:02 | [diff] [blame] | 127 | |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame^] | 128 | // Linked private dependencies. |
| 129 | const LabelTargetVector& private_deps() const { return private_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_; } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 135 | |
[email protected] | 4441041b | 2013-08-06 21:11:06 | [diff] [blame] | 136 | // Non-linked dependencies. |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame^] | 137 | const LabelTargetVector& data_deps() const { return data_deps_; } |
| 138 | LabelTargetVector& data_deps() { return data_deps_; } |
[email protected] | 4441041b | 2013-08-06 21:11:06 | [diff] [blame] | 139 | |
[email protected] | 08035b9 | 2014-05-13 19:40:56 | [diff] [blame] | 140 | // List of configs that this class inherits settings from. Once a target is |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame^] | 141 | // resolved, this will also list all-dependent and public configs. |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 142 | const UniqueVector<LabelConfigPair>& configs() const { return configs_; } |
| 143 | UniqueVector<LabelConfigPair>& configs() { return configs_; } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 144 | |
| 145 | // List of configs that all dependencies (direct and indirect) of this |
[email protected] | 62a61063 | 2013-08-21 23:45:23 | [diff] [blame] | 146 | // target get. These configs are not added to this target. Note that due |
| 147 | // to the way this is computed, there may be duplicates in this list. |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 148 | const UniqueVector<LabelConfigPair>& all_dependent_configs() const { |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 149 | return all_dependent_configs_; |
| 150 | } |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 151 | UniqueVector<LabelConfigPair>& all_dependent_configs() { |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 152 | return all_dependent_configs_; |
| 153 | } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 154 | |
| 155 | // List of configs that targets depending directly on this one get. These |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame^] | 156 | // configs are also added to this target. |
| 157 | const UniqueVector<LabelConfigPair>& public_configs() const { |
| 158 | return public_configs_; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 159 | } |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame^] | 160 | UniqueVector<LabelConfigPair>& public_configs() { |
| 161 | return public_configs_; |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 162 | } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 163 | |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame^] | 164 | // A list of a subset of deps where we'll re-export public_configs as |
| 165 | // public_configs of this target. |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 166 | const UniqueVector<LabelTargetPair>& forward_dependent_configs() const { |
[email protected] | 62a61063 | 2013-08-21 23:45:23 | [diff] [blame] | 167 | return forward_dependent_configs_; |
| 168 | } |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 169 | UniqueVector<LabelTargetPair>& forward_dependent_configs() { |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 170 | return forward_dependent_configs_; |
| 171 | } |
[email protected] | 62a61063 | 2013-08-21 23:45:23 | [diff] [blame] | 172 | |
brettw | 81db36a | 2014-08-29 22:52:36 | [diff] [blame] | 173 | // Dependencies that can include files from this target. |
| 174 | const std::set<Label>& allow_circular_includes_from() const { |
| 175 | return allow_circular_includes_from_; |
| 176 | } |
| 177 | std::set<Label>& allow_circular_includes_from() { |
| 178 | return allow_circular_includes_from_; |
| 179 | } |
| 180 | |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 181 | const UniqueVector<const Target*>& inherited_libraries() const { |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 182 | return inherited_libraries_; |
| 183 | } |
| 184 | |
| 185 | // This config represents the configuration set directly on this target. |
| 186 | ConfigValues& config_values() { return config_values_; } |
| 187 | const ConfigValues& config_values() const { return config_values_; } |
| 188 | |
[email protected] | 2fbe101 | 2014-03-20 17:59:15 | [diff] [blame] | 189 | ActionValues& action_values() { return action_values_; } |
| 190 | const ActionValues& action_values() const { return action_values_; } |
[email protected] | c0822d7f | 2013-08-13 17:10:56 | [diff] [blame] | 191 | |
[email protected] | 2ed04ae | 2013-10-07 20:17:16 | [diff] [blame] | 192 | const OrderedSet<SourceDir>& all_lib_dirs() const { return all_lib_dirs_; } |
| 193 | const OrderedSet<std::string>& all_libs() const { return all_libs_; } |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 194 | |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 195 | const std::set<const Target*>& recursive_hard_deps() const { |
| 196 | return recursive_hard_deps_; |
| 197 | } |
| 198 | |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 199 | // The toolchain is only known once this target is resolved (all if its |
| 200 | // dependencies are known). They will be null until then. Generally, this can |
| 201 | // only be used during target writing. |
| 202 | const Toolchain* toolchain() const { return toolchain_; } |
| 203 | |
| 204 | // Sets the toolchain. The toolchain must include a tool for this target |
| 205 | // or the error will be set and the function will return false. Unusually, |
| 206 | // this function's "err" output is optional since this is commonly used |
| 207 | // frequently by unit tests which become needlessly verbose. |
| 208 | bool SetToolchain(const Toolchain* toolchain, Err* err = NULL); |
| 209 | |
| 210 | // Returns outputs from this target. The link output file is the one that |
| 211 | // other targets link to when they depend on this target. This will only be |
| 212 | // valid for libraries and will be empty for all other target types. |
| 213 | // |
| 214 | // The dependency output file is the file that should be used to express |
| 215 | // a dependency on this one. It could be the same as the link output file |
| 216 | // (this will be the case for static libraries). For shared libraries it |
| 217 | // could be the same or different than the link output file, depending on the |
| 218 | // system. For actions this will be the stamp file. |
| 219 | // |
| 220 | // These are only known once the target is resolved and will be empty before |
| 221 | // that. This is a cache of the files to prevent every target that depends on |
| 222 | // a given library from recomputing the same pattern. |
| 223 | const OutputFile& link_output_file() const { |
| 224 | return link_output_file_; |
| 225 | } |
| 226 | const OutputFile& dependency_output_file() const { |
| 227 | return dependency_output_file_; |
| 228 | } |
| 229 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 230 | private: |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 231 | // Pulls necessary information from dependencies to this one when all |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 232 | // dependencies have been resolved. |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 233 | void PullDependentTargetInfo(); |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 234 | |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 235 | // These each pull specific things from dependencies to this one when all |
| 236 | // deps have been resolved. |
[email protected] | 8499f51f | 2014-04-24 23:43:02 | [diff] [blame] | 237 | void PullForwardedDependentConfigs(); |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame^] | 238 | void PullForwardedDependentConfigsFrom(const Target* from); |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 239 | void PullRecursiveHardDeps(); |
[email protected] | 8499f51f | 2014-04-24 23:43:02 | [diff] [blame] | 240 | |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 241 | // Fills the link and dependency output files when a target is resolved. |
| 242 | void FillOutputFiles(); |
| 243 | |
Brett Wilson | 85423a0 | 2014-09-02 19:29:42 | [diff] [blame] | 244 | // Validates the given thing when a target is resolved. |
| 245 | bool CheckVisibility(Err* err) const; |
| 246 | bool CheckTestonly(Err* err) const; |
| 247 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 248 | OutputType output_type_; |
[email protected] | b5c19e3 | 2013-09-10 23:01:25 | [diff] [blame] | 249 | std::string output_name_; |
[email protected] | b9473ee | 2014-02-28 21:51:10 | [diff] [blame] | 250 | std::string output_extension_; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 251 | |
| 252 | FileList sources_; |
[email protected] | 126d8b5 | 2014-04-07 22:17:35 | [diff] [blame] | 253 | bool all_headers_public_; |
| 254 | FileList public_headers_; |
brettw | 81db36a | 2014-08-29 22:52:36 | [diff] [blame] | 255 | bool check_includes_; |
cmasone | a426cf93 | 2014-09-13 00:51:47 | [diff] [blame] | 256 | bool complete_static_lib_; |
Brett Wilson | 85423a0 | 2014-09-02 19:29:42 | [diff] [blame] | 257 | bool testonly_; |
[email protected] | 61a6fca | 2014-06-17 20:26:53 | [diff] [blame] | 258 | FileList inputs_; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 259 | FileList data_; |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 260 | |
[email protected] | 234be520 | 2013-09-11 20:44:02 | [diff] [blame] | 261 | bool hard_dep_; |
| 262 | |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame^] | 263 | LabelTargetVector private_deps_; |
| 264 | LabelTargetVector public_deps_; |
| 265 | LabelTargetVector data_deps_; |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 266 | |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 267 | UniqueVector<LabelConfigPair> configs_; |
| 268 | UniqueVector<LabelConfigPair> all_dependent_configs_; |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame^] | 269 | UniqueVector<LabelConfigPair> public_configs_; |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 270 | UniqueVector<LabelTargetPair> forward_dependent_configs_; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 271 | |
brettw | 81db36a | 2014-08-29 22:52:36 | [diff] [blame] | 272 | std::set<Label> allow_circular_includes_from_; |
| 273 | |
[email protected] | 0a79fe4 | 2013-08-29 21:06:26 | [diff] [blame] | 274 | bool external_; |
| 275 | |
[email protected] | 7ff2f5d | 2013-10-08 21:30:34 | [diff] [blame] | 276 | // Static libraries and source sets from transitive deps. These things need |
[email protected] | 678b5b94 | 2014-05-30 16:30:21 | [diff] [blame] | 277 | // to be linked only with the end target (executable, shared library). Source |
| 278 | // sets do not get pushed beyond static library boundaries, and neither |
| 279 | // source sets nor static libraries get pushed beyond sahred library |
| 280 | // boundaries. |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 281 | UniqueVector<const Target*> inherited_libraries_; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 282 | |
[email protected] | 2ed04ae | 2013-10-07 20:17:16 | [diff] [blame] | 283 | // These libs and dirs are inherited from statically linked deps and all |
| 284 | // configs applying to this target. |
| 285 | OrderedSet<SourceDir> all_lib_dirs_; |
| 286 | OrderedSet<std::string> all_libs_; |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 287 | |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 288 | // All hard deps from this target and all dependencies. Filled in when this |
| 289 | // target is marked resolved. This will not include the current target. |
| 290 | std::set<const Target*> recursive_hard_deps_; |
| 291 | |
[email protected] | c0822d7f | 2013-08-13 17:10:56 | [diff] [blame] | 292 | ConfigValues config_values_; // Used for all binary targets. |
[email protected] | 2fbe101 | 2014-03-20 17:59:15 | [diff] [blame] | 293 | ActionValues action_values_; // Used for action[_foreach] targets. |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 294 | |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 295 | // Toolchain used by this target. Null until target is resolved. |
| 296 | const Toolchain* toolchain_; |
| 297 | |
| 298 | // Output files. Null until the target is resolved. |
| 299 | OutputFile link_output_file_; |
| 300 | OutputFile dependency_output_file_; |
| 301 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 302 | DISALLOW_COPY_AND_ASSIGN(Target); |
| 303 | }; |
| 304 | |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 305 | namespace BASE_HASH_NAMESPACE { |
| 306 | |
| 307 | #if defined(COMPILER_GCC) |
| 308 | template<> struct hash<const Target*> { |
| 309 | std::size_t operator()(const Target* t) const { |
| 310 | return reinterpret_cast<std::size_t>(t); |
| 311 | } |
| 312 | }; |
| 313 | #elif defined(COMPILER_MSVC) |
| 314 | inline size_t hash_value(const Target* t) { |
| 315 | return reinterpret_cast<size_t>(t); |
| 316 | } |
| 317 | #endif // COMPILER... |
| 318 | |
| 319 | } // namespace BASE_HASH_NAMESPACE |
| 320 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 321 | #endif // TOOLS_GN_TARGET_H_ |