[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 | |
brettw | 3dab5fe | 2015-06-29 23:00:15 | [diff] [blame] | 12 | #include "base/gtest_prod_util.h" |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 13 | #include "base/logging.h" |
tfarina | f51a763e | 2015-08-10 00:55:38 | [diff] [blame] | 14 | #include "base/macros.h" |
[email protected] | 2fbe101 | 2014-03-20 17:59:15 | [diff] [blame] | 15 | #include "tools/gn/action_values.h" |
sdefresne | 1232aae | 2016-03-10 20:16:36 | [diff] [blame] | 16 | #include "tools/gn/bundle_data.h" |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 17 | #include "tools/gn/config_values.h" |
brettw | 54d76753 | 2015-04-16 17:40:49 | [diff] [blame] | 18 | #include "tools/gn/inherited_libraries.h" |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 19 | #include "tools/gn/item.h" |
brettw | 81aa4e8f | 2016-01-26 18:11:28 | [diff] [blame] | 20 | #include "tools/gn/label_pattern.h" |
[email protected] | 68d1dd3 | 2013-11-01 21:59:51 | [diff] [blame] | 21 | #include "tools/gn/label_ptr.h" |
agrieve | f865ab8f | 2015-12-22 03:04:02 | [diff] [blame] | 22 | #include "tools/gn/lib_file.h" |
[email protected] | b1e468f | 2013-09-10 22:58:02 | [diff] [blame] | 23 | #include "tools/gn/ordered_set.h" |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 24 | #include "tools/gn/output_file.h" |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 25 | #include "tools/gn/source_file.h" |
brettw | 65e8985 | 2016-01-20 23:58:12 | [diff] [blame] | 26 | #include "tools/gn/toolchain.h" |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 27 | #include "tools/gn/unique_vector.h" |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 28 | |
brettw | a09df11 | 2014-09-27 22:27:10 | [diff] [blame] | 29 | class DepsIteratorRange; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 30 | class InputFile; |
| 31 | class Settings; |
| 32 | class Token; |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 33 | class Toolchain; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 34 | |
| 35 | class Target : public Item { |
| 36 | public: |
| 37 | enum OutputType { |
[email protected] | c0822d7f | 2013-08-13 17:10:56 | [diff] [blame] | 38 | UNKNOWN, |
| 39 | GROUP, |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 40 | EXECUTABLE, |
| 41 | SHARED_LIBRARY, |
andybons | 027840d | 2015-10-14 18:49:30 | [diff] [blame] | 42 | LOADABLE_MODULE, |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 43 | STATIC_LIBRARY, |
[email protected] | 7ff2f5d | 2013-10-08 21:30:34 | [diff] [blame] | 44 | SOURCE_SET, |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 45 | COPY_FILES, |
[email protected] | 2fbe101 | 2014-03-20 17:59:15 | [diff] [blame] | 46 | ACTION, |
| 47 | ACTION_FOREACH, |
sdefresne | db6b992c | 2016-03-04 16:32:19 | [diff] [blame] | 48 | BUNDLE_DATA, |
sdefresne | 1232aae | 2016-03-10 20:16:36 | [diff] [blame] | 49 | CREATE_BUNDLE, |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 50 | }; |
brettw | a09df11 | 2014-09-27 22:27:10 | [diff] [blame] | 51 | |
| 52 | enum DepsIterationType { |
| 53 | DEPS_ALL, // Iterates through all public, private, and data deps. |
| 54 | DEPS_LINKED, // Iterates through all non-data dependencies. |
| 55 | }; |
| 56 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 57 | typedef std::vector<SourceFile> FileList; |
| 58 | typedef std::vector<std::string> StringVector; |
| 59 | |
| 60 | Target(const Settings* settings, const Label& label); |
Viet-Trung Luu | 50df3ed | 2014-10-22 05:00:12 | [diff] [blame] | 61 | ~Target() override; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 62 | |
[email protected] | ac1128e | 2013-08-23 00:26:56 | [diff] [blame] | 63 | // Returns a string naming the output type. |
| 64 | static const char* GetStringForOutputType(OutputType type); |
| 65 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 66 | // Item overrides. |
Viet-Trung Luu | 50df3ed | 2014-10-22 05:00:12 | [diff] [blame] | 67 | Target* AsTarget() override; |
| 68 | const Target* AsTarget() const override; |
| 69 | bool OnResolved(Err* err) override; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 70 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 71 | OutputType output_type() const { return output_type_; } |
| 72 | void set_output_type(OutputType t) { output_type_ = t; } |
| 73 | |
brettw | 65e8985 | 2016-01-20 23:58:12 | [diff] [blame] | 74 | // True for targets that compile source code (all types of libaries and |
| 75 | // executables). |
| 76 | bool IsBinary() const; |
| 77 | |
cmasone | a426cf93 | 2014-09-13 00:51:47 | [diff] [blame] | 78 | // Can be linked into other targets. |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 79 | bool IsLinkable() const; |
| 80 | |
brettw | 374d4fd | 2015-11-14 00:57:03 | [diff] [blame] | 81 | // True if the target links dependencies rather than propogated up the graph. |
| 82 | // This is also true of action and copy steps even though they don't link |
| 83 | // dependencies, because they also don't propogate libraries up. |
cmasone | a426cf93 | 2014-09-13 00:51:47 | [diff] [blame] | 84 | bool IsFinal() const; |
| 85 | |
[email protected] | b5c19e3 | 2013-09-10 23:01:25 | [diff] [blame] | 86 | // 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] | 87 | // See GetComputedOutputName(). |
[email protected] | b5c19e3 | 2013-09-10 23:01:25 | [diff] [blame] | 88 | const std::string& output_name() const { return output_name_; } |
| 89 | void set_output_name(const std::string& name) { output_name_ = name; } |
| 90 | |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 91 | // Returns the output name for this target, which is the output_name if |
brettw | 2a642a1 | 2016-04-07 23:51:12 | [diff] [blame] | 92 | // specified, or the target label if not. |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 93 | // |
| 94 | // Because this depends on the tool for this target, the toolchain must |
| 95 | // have been set before calling. |
brettw | 2a642a1 | 2016-04-07 23:51:12 | [diff] [blame] | 96 | std::string GetComputedOutputName() const; |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 97 | |
brettw | 2a642a1 | 2016-04-07 23:51:12 | [diff] [blame] | 98 | bool output_prefix_override() const { return output_prefix_override_; } |
| 99 | void set_output_prefix_override(bool prefix_override) { |
| 100 | output_prefix_override_ = prefix_override; |
| 101 | } |
| 102 | |
brettw | f2eba7f | 2016-04-14 18:14:45 | [diff] [blame] | 103 | // Desired output directory for the final output. This will be used for |
| 104 | // the {{output_dir}} substitution in the tool if it is specified. If |
| 105 | // is_null, the tool default will be used. |
| 106 | const SourceDir& output_dir() const { return output_dir_; } |
| 107 | void set_output_dir(const SourceDir& dir) { output_dir_ = dir; } |
| 108 | |
brettw | 2a642a1 | 2016-04-07 23:51:12 | [diff] [blame] | 109 | // The output extension is really a tri-state: unset (output_extension_set |
| 110 | // is false and the string is empty, meaning the default extension should be |
| 111 | // used), the output extension is set but empty (output should have no |
| 112 | // extension) and the output extension is set but nonempty (use the given |
| 113 | // extension). |
[email protected] | b9473ee | 2014-02-28 21:51:10 | [diff] [blame] | 114 | const std::string& output_extension() const { return output_extension_; } |
| 115 | void set_output_extension(const std::string& extension) { |
| 116 | output_extension_ = extension; |
brettw | 2a642a1 | 2016-04-07 23:51:12 | [diff] [blame] | 117 | output_extension_set_ = true; |
| 118 | } |
| 119 | bool output_extension_set() const { |
| 120 | return output_extension_set_; |
[email protected] | b9473ee | 2014-02-28 21:51:10 | [diff] [blame] | 121 | } |
| 122 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 123 | const FileList& sources() const { return sources_; } |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 124 | FileList& sources() { return sources_; } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 125 | |
[email protected] | 126d8b5 | 2014-04-07 22:17:35 | [diff] [blame] | 126 | // Set to true when all sources are public. This is the default. In this case |
| 127 | // the public headers list should be empty. |
| 128 | bool all_headers_public() const { return all_headers_public_; } |
| 129 | void set_all_headers_public(bool p) { all_headers_public_ = p; } |
| 130 | |
| 131 | // When all_headers_public is false, this is the list of public headers. It |
| 132 | // could be empty which would mean no headers are public. |
| 133 | const FileList& public_headers() const { return public_headers_; } |
| 134 | FileList& public_headers() { return public_headers_; } |
| 135 | |
brettw | 81db36a | 2014-08-29 22:52:36 | [diff] [blame] | 136 | // Whether this target's includes should be checked by "gn check". |
| 137 | bool check_includes() const { return check_includes_; } |
| 138 | void set_check_includes(bool ci) { check_includes_ = ci; } |
| 139 | |
cmasone | a426cf93 | 2014-09-13 00:51:47 | [diff] [blame] | 140 | // Whether this static_library target should have code linked in. |
| 141 | bool complete_static_lib() const { return complete_static_lib_; } |
| 142 | void set_complete_static_lib(bool complete) { |
| 143 | DCHECK_EQ(STATIC_LIBRARY, output_type_); |
| 144 | complete_static_lib_ = complete; |
| 145 | } |
| 146 | |
Brett Wilson | 85423a0 | 2014-09-02 19:29:42 | [diff] [blame] | 147 | bool testonly() const { return testonly_; } |
| 148 | void set_testonly(bool value) { testonly_ = value; } |
| 149 | |
agrieve | 0f8ad42 | 2016-03-31 22:00:07 | [diff] [blame] | 150 | OutputFile write_runtime_deps_output() const { |
| 151 | return write_runtime_deps_output_; |
| 152 | } |
| 153 | void set_write_runtime_deps_output(const OutputFile& value) { |
| 154 | write_runtime_deps_output_ = value; |
| 155 | } |
| 156 | |
[email protected] | 234be520 | 2013-09-11 20:44:02 | [diff] [blame] | 157 | // Compile-time extra dependencies. |
[email protected] | 61a6fca | 2014-06-17 20:26:53 | [diff] [blame] | 158 | const FileList& inputs() const { return inputs_; } |
| 159 | FileList& inputs() { return inputs_; } |
[email protected] | 234be520 | 2013-09-11 20:44:02 | [diff] [blame] | 160 | |
brettw | e903c0f | 2015-06-03 22:40:17 | [diff] [blame] | 161 | // Runtime dependencies. These are "file-like things" that can either be |
| 162 | // directories or files. They do not need to exist, these are just passed as |
| 163 | // runtime dependencies to external test systems as necessary. |
| 164 | const std::vector<std::string>& data() const { return data_; } |
| 165 | std::vector<std::string>& data() { return data_; } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 166 | |
sdefresne | 1232aae | 2016-03-10 20:16:36 | [diff] [blame] | 167 | // Information about the bundle. Only valid for CREATE_BUNDLE target after |
| 168 | // they have been resolved. |
| 169 | const BundleData& bundle_data() const { return bundle_data_; } |
| 170 | BundleData& bundle_data() { return bundle_data_; } |
| 171 | |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 172 | // Returns true if targets depending on this one should have an order |
| 173 | // dependency. |
| 174 | bool hard_dep() const { |
| 175 | return output_type_ == ACTION || |
| 176 | output_type_ == ACTION_FOREACH || |
sdefresne | 1232aae | 2016-03-10 20:16:36 | [diff] [blame] | 177 | output_type_ == COPY_FILES || |
| 178 | output_type_ == CREATE_BUNDLE; |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 179 | } |
[email protected] | 234be520 | 2013-09-11 20:44:02 | [diff] [blame] | 180 | |
brettw | a09df11 | 2014-09-27 22:27:10 | [diff] [blame] | 181 | // Returns the iterator range which can be used in range-based for loops |
| 182 | // to iterate over multiple types of deps in one loop: |
| 183 | // for (const auto& pair : target->GetDeps(Target::DEPS_ALL)) ... |
| 184 | DepsIteratorRange GetDeps(DepsIterationType type) const; |
| 185 | |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame] | 186 | // Linked private dependencies. |
| 187 | const LabelTargetVector& private_deps() const { return private_deps_; } |
| 188 | LabelTargetVector& private_deps() { return private_deps_; } |
| 189 | |
| 190 | // Linked public dependencies. |
| 191 | const LabelTargetVector& public_deps() const { return public_deps_; } |
| 192 | LabelTargetVector& public_deps() { return public_deps_; } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 193 | |
[email protected] | 4441041b | 2013-08-06 21:11:06 | [diff] [blame] | 194 | // Non-linked dependencies. |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame] | 195 | const LabelTargetVector& data_deps() const { return data_deps_; } |
| 196 | LabelTargetVector& data_deps() { return data_deps_; } |
[email protected] | 4441041b | 2013-08-06 21:11:06 | [diff] [blame] | 197 | |
[email protected] | 08035b9 | 2014-05-13 19:40:56 | [diff] [blame] | 198 | // List of configs that this class inherits settings from. Once a target is |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame] | 199 | // resolved, this will also list all-dependent and public configs. |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 200 | const UniqueVector<LabelConfigPair>& configs() const { return configs_; } |
| 201 | UniqueVector<LabelConfigPair>& configs() { return configs_; } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 202 | |
| 203 | // List of configs that all dependencies (direct and indirect) of this |
[email protected] | 62a61063 | 2013-08-21 23:45:23 | [diff] [blame] | 204 | // target get. These configs are not added to this target. Note that due |
| 205 | // to the way this is computed, there may be duplicates in this list. |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 206 | const UniqueVector<LabelConfigPair>& all_dependent_configs() const { |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 207 | return all_dependent_configs_; |
| 208 | } |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 209 | UniqueVector<LabelConfigPair>& all_dependent_configs() { |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 210 | return all_dependent_configs_; |
| 211 | } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 212 | |
| 213 | // List of configs that targets depending directly on this one get. These |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame] | 214 | // configs are also added to this target. |
| 215 | const UniqueVector<LabelConfigPair>& public_configs() const { |
| 216 | return public_configs_; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 217 | } |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame] | 218 | UniqueVector<LabelConfigPair>& public_configs() { |
| 219 | return public_configs_; |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 220 | } |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 221 | |
brettw | 81db36a | 2014-08-29 22:52:36 | [diff] [blame] | 222 | // Dependencies that can include files from this target. |
| 223 | const std::set<Label>& allow_circular_includes_from() const { |
| 224 | return allow_circular_includes_from_; |
| 225 | } |
| 226 | std::set<Label>& allow_circular_includes_from() { |
| 227 | return allow_circular_includes_from_; |
| 228 | } |
| 229 | |
brettw | 54d76753 | 2015-04-16 17:40:49 | [diff] [blame] | 230 | const InheritedLibraries& inherited_libraries() const { |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 231 | return inherited_libraries_; |
| 232 | } |
| 233 | |
| 234 | // This config represents the configuration set directly on this target. |
| 235 | ConfigValues& config_values() { return config_values_; } |
| 236 | const ConfigValues& config_values() const { return config_values_; } |
| 237 | |
[email protected] | 2fbe101 | 2014-03-20 17:59:15 | [diff] [blame] | 238 | ActionValues& action_values() { return action_values_; } |
| 239 | const ActionValues& action_values() const { return action_values_; } |
[email protected] | c0822d7f | 2013-08-13 17:10:56 | [diff] [blame] | 240 | |
[email protected] | 2ed04ae | 2013-10-07 20:17:16 | [diff] [blame] | 241 | const OrderedSet<SourceDir>& all_lib_dirs() const { return all_lib_dirs_; } |
agrieve | f865ab8f | 2015-12-22 03:04:02 | [diff] [blame] | 242 | const OrderedSet<LibFile>& all_libs() const { return all_libs_; } |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 243 | |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 244 | const std::set<const Target*>& recursive_hard_deps() const { |
| 245 | return recursive_hard_deps_; |
| 246 | } |
| 247 | |
brettw | 81aa4e8f | 2016-01-26 18:11:28 | [diff] [blame] | 248 | std::vector<LabelPattern>& assert_no_deps() { |
| 249 | return assert_no_deps_; |
| 250 | } |
| 251 | const std::vector<LabelPattern>& assert_no_deps() const { |
| 252 | return assert_no_deps_; |
| 253 | } |
| 254 | |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 255 | // The toolchain is only known once this target is resolved (all if its |
| 256 | // dependencies are known). They will be null until then. Generally, this can |
| 257 | // only be used during target writing. |
| 258 | const Toolchain* toolchain() const { return toolchain_; } |
| 259 | |
| 260 | // Sets the toolchain. The toolchain must include a tool for this target |
| 261 | // or the error will be set and the function will return false. Unusually, |
| 262 | // this function's "err" output is optional since this is commonly used |
| 263 | // frequently by unit tests which become needlessly verbose. |
tfarina | 02633587 | 2015-01-13 03:35:39 | [diff] [blame] | 264 | bool SetToolchain(const Toolchain* toolchain, Err* err = nullptr); |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 265 | |
brettw | 56affab | 2015-06-04 22:01:03 | [diff] [blame] | 266 | // Once this target has been resolved, all outputs from the target will be |
| 267 | // listed here. This will include things listed in the "outputs" for an |
| 268 | // action or a copy step, and the output library or executable file(s) from |
| 269 | // binary targets. |
| 270 | // |
| 271 | // It will NOT include stamp files and object files. |
| 272 | const std::vector<OutputFile>& computed_outputs() const { |
| 273 | return computed_outputs_; |
| 274 | } |
| 275 | |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 276 | // Returns outputs from this target. The link output file is the one that |
| 277 | // other targets link to when they depend on this target. This will only be |
| 278 | // valid for libraries and will be empty for all other target types. |
| 279 | // |
| 280 | // The dependency output file is the file that should be used to express |
| 281 | // a dependency on this one. It could be the same as the link output file |
| 282 | // (this will be the case for static libraries). For shared libraries it |
| 283 | // could be the same or different than the link output file, depending on the |
| 284 | // system. For actions this will be the stamp file. |
| 285 | // |
| 286 | // These are only known once the target is resolved and will be empty before |
| 287 | // that. This is a cache of the files to prevent every target that depends on |
| 288 | // a given library from recomputing the same pattern. |
| 289 | const OutputFile& link_output_file() const { |
| 290 | return link_output_file_; |
| 291 | } |
| 292 | const OutputFile& dependency_output_file() const { |
| 293 | return dependency_output_file_; |
| 294 | } |
brettw | 15e0e74f | 2016-07-26 18:00:24 | [diff] [blame] | 295 | |
| 296 | // The subset of computed_outputs that are considered runtime outputs. |
| 297 | const std::vector<OutputFile>& runtime_outputs() const { |
| 298 | return runtime_outputs_; |
Nico Weber | e3398c1 | 2016-02-11 02:25:20 | [diff] [blame] | 299 | } |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 300 | |
brettw | 65e8985 | 2016-01-20 23:58:12 | [diff] [blame] | 301 | // Computes the set of output files resulting from compiling the given source |
| 302 | // file. If the file can be compiled and the tool exists, fills the outputs |
| 303 | // in and writes the tool type to computed_tool_type. If the file is not |
| 304 | // compilable, returns false. |
| 305 | // |
| 306 | // The function can succeed with a "NONE" tool type for object files which |
| 307 | // are just passed to the output. The output will always be overwritten, not |
| 308 | // appended to. |
| 309 | bool GetOutputFilesForSource(const SourceFile& source, |
| 310 | Toolchain::ToolType* computed_tool_type, |
| 311 | std::vector<OutputFile>* outputs) const; |
| 312 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 313 | private: |
brettw | 3dab5fe | 2015-06-29 23:00:15 | [diff] [blame] | 314 | FRIEND_TEST_ALL_PREFIXES(Target, ResolvePrecompiledHeaders); |
| 315 | |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 316 | // Pulls necessary information from dependencies to this one when all |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 317 | // dependencies have been resolved. |
brettw | 567cb688 | 2015-12-11 18:38:26 | [diff] [blame] | 318 | void PullDependentTargetConfigs(); |
| 319 | void PullDependentTargetLibsFrom(const Target* dep, bool is_public); |
| 320 | void PullDependentTargetLibs(); |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 321 | void PullRecursiveHardDeps(); |
sdefresne | 1232aae | 2016-03-10 20:16:36 | [diff] [blame] | 322 | void PullRecursiveBundleData(); |
[email protected] | 8499f51f | 2014-04-24 23:43:02 | [diff] [blame] | 323 | |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 324 | // Fills the link and dependency output files when a target is resolved. |
| 325 | void FillOutputFiles(); |
| 326 | |
brettw | 3dab5fe | 2015-06-29 23:00:15 | [diff] [blame] | 327 | // Checks precompiled headers from configs and makes sure the resulting |
| 328 | // values are in config_values_. |
| 329 | bool ResolvePrecompiledHeaders(Err* err); |
| 330 | |
Brett Wilson | 85423a0 | 2014-09-02 19:29:42 | [diff] [blame] | 331 | // Validates the given thing when a target is resolved. |
| 332 | bool CheckVisibility(Err* err) const; |
| 333 | bool CheckTestonly(Err* err) const; |
brettw | 81aa4e8f | 2016-01-26 18:11:28 | [diff] [blame] | 334 | bool CheckAssertNoDeps(Err* err) const; |
brettw | 56affab | 2015-06-04 22:01:03 | [diff] [blame] | 335 | void CheckSourcesGenerated() const; |
| 336 | void CheckSourceGenerated(const SourceFile& source) const; |
Brett Wilson | 85423a0 | 2014-09-02 19:29:42 | [diff] [blame] | 337 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 338 | OutputType output_type_; |
[email protected] | b5c19e3 | 2013-09-10 23:01:25 | [diff] [blame] | 339 | std::string output_name_; |
brettw | 2a642a1 | 2016-04-07 23:51:12 | [diff] [blame] | 340 | bool output_prefix_override_; |
brettw | f2eba7f | 2016-04-14 18:14:45 | [diff] [blame] | 341 | SourceDir output_dir_; |
[email protected] | b9473ee | 2014-02-28 21:51:10 | [diff] [blame] | 342 | std::string output_extension_; |
brettw | 2a642a1 | 2016-04-07 23:51:12 | [diff] [blame] | 343 | bool output_extension_set_; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 344 | |
| 345 | FileList sources_; |
[email protected] | 126d8b5 | 2014-04-07 22:17:35 | [diff] [blame] | 346 | bool all_headers_public_; |
| 347 | FileList public_headers_; |
brettw | 81db36a | 2014-08-29 22:52:36 | [diff] [blame] | 348 | bool check_includes_; |
cmasone | a426cf93 | 2014-09-13 00:51:47 | [diff] [blame] | 349 | bool complete_static_lib_; |
Brett Wilson | 85423a0 | 2014-09-02 19:29:42 | [diff] [blame] | 350 | bool testonly_; |
[email protected] | 61a6fca | 2014-06-17 20:26:53 | [diff] [blame] | 351 | FileList inputs_; |
brettw | e903c0f | 2015-06-03 22:40:17 | [diff] [blame] | 352 | std::vector<std::string> data_; |
sdefresne | 1232aae | 2016-03-10 20:16:36 | [diff] [blame] | 353 | BundleData bundle_data_; |
agrieve | 0f8ad42 | 2016-03-31 22:00:07 | [diff] [blame] | 354 | OutputFile write_runtime_deps_output_; |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 355 | |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame] | 356 | LabelTargetVector private_deps_; |
| 357 | LabelTargetVector public_deps_; |
| 358 | LabelTargetVector data_deps_; |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 359 | |
brettw | 567cb688 | 2015-12-11 18:38:26 | [diff] [blame] | 360 | // See getters for more info. |
[email protected] | 8fc5618 | 2014-08-06 21:44:33 | [diff] [blame] | 361 | UniqueVector<LabelConfigPair> configs_; |
| 362 | UniqueVector<LabelConfigPair> all_dependent_configs_; |
brettw | c2e821a3 | 2014-09-17 01:07:14 | [diff] [blame] | 363 | UniqueVector<LabelConfigPair> public_configs_; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 364 | |
brettw | 81db36a | 2014-08-29 22:52:36 | [diff] [blame] | 365 | std::set<Label> allow_circular_includes_from_; |
| 366 | |
brettw | 54d76753 | 2015-04-16 17:40:49 | [diff] [blame] | 367 | // Static libraries, shared libraries, and source sets from transitive deps |
| 368 | // that need to be linked. |
| 369 | InheritedLibraries inherited_libraries_; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 370 | |
[email protected] | 2ed04ae | 2013-10-07 20:17:16 | [diff] [blame] | 371 | // These libs and dirs are inherited from statically linked deps and all |
| 372 | // configs applying to this target. |
| 373 | OrderedSet<SourceDir> all_lib_dirs_; |
agrieve | f865ab8f | 2015-12-22 03:04:02 | [diff] [blame] | 374 | OrderedSet<LibFile> all_libs_; |
[email protected] | 3c1274d | 2013-09-10 22:21:21 | [diff] [blame] | 375 | |
[email protected] | ef348fe | 2014-05-01 18:31:31 | [diff] [blame] | 376 | // All hard deps from this target and all dependencies. Filled in when this |
| 377 | // target is marked resolved. This will not include the current target. |
| 378 | std::set<const Target*> recursive_hard_deps_; |
| 379 | |
brettw | 81aa4e8f | 2016-01-26 18:11:28 | [diff] [blame] | 380 | std::vector<LabelPattern> assert_no_deps_; |
| 381 | |
brettw | 3dab5fe | 2015-06-29 23:00:15 | [diff] [blame] | 382 | // Used for all binary targets. The precompiled header values in this struct |
| 383 | // will be resolved to the ones to use for this target, if precompiled |
| 384 | // headers are used. |
| 385 | ConfigValues config_values_; |
| 386 | |
| 387 | // Used for action[_foreach] targets. |
| 388 | ActionValues action_values_; |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 389 | |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 390 | // Toolchain used by this target. Null until target is resolved. |
| 391 | const Toolchain* toolchain_; |
| 392 | |
brettw | 56affab | 2015-06-04 22:01:03 | [diff] [blame] | 393 | // Output files. Empty until the target is resolved. |
| 394 | std::vector<OutputFile> computed_outputs_; |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 395 | OutputFile link_output_file_; |
| 396 | OutputFile dependency_output_file_; |
brettw | 15e0e74f | 2016-07-26 18:00:24 | [diff] [blame] | 397 | std::vector<OutputFile> runtime_outputs_; |
[email protected] | 0dfcae7 | 2014-08-19 22:52:16 | [diff] [blame] | 398 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 399 | DISALLOW_COPY_AND_ASSIGN(Target); |
| 400 | }; |
| 401 | |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 402 | #endif // TOOLS_GN_TARGET_H_ |