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_ptr.h" | 19 #include "tools/gn/label_ptr.h" |
20 #include "tools/gn/lib_file.h" | 20 #include "tools/gn/lib_file.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/toolchain.h" |
24 #include "tools/gn/unique_vector.h" | 25 #include "tools/gn/unique_vector.h" |
25 | 26 |
26 class DepsIteratorRange; | 27 class DepsIteratorRange; |
27 class InputFile; | 28 class InputFile; |
28 class Settings; | 29 class Settings; |
29 class Token; | 30 class Token; |
30 class Toolchain; | 31 class Toolchain; |
31 | 32 |
32 class Target : public Item { | 33 class Target : public Item { |
33 public: | 34 public: |
(...skipping 25 matching lines...) Expand all Loading... |
59 static const char* GetStringForOutputType(OutputType type); | 60 static const char* GetStringForOutputType(OutputType type); |
60 | 61 |
61 // Item overrides. | 62 // Item overrides. |
62 Target* AsTarget() override; | 63 Target* AsTarget() override; |
63 const Target* AsTarget() const override; | 64 const Target* AsTarget() const override; |
64 bool OnResolved(Err* err) override; | 65 bool OnResolved(Err* err) override; |
65 | 66 |
66 OutputType output_type() const { return output_type_; } | 67 OutputType output_type() const { return output_type_; } |
67 void set_output_type(OutputType t) { output_type_ = t; } | 68 void set_output_type(OutputType t) { output_type_ = t; } |
68 | 69 |
| 70 // True for targets that compile source code (all types of libaries and |
| 71 // executables). |
| 72 bool IsBinary() const; |
| 73 |
69 // Can be linked into other targets. | 74 // Can be linked into other targets. |
70 bool IsLinkable() const; | 75 bool IsLinkable() const; |
71 | 76 |
72 // True if the target links dependencies rather than propogated up the graph. | 77 // True if the target links dependencies rather than propogated up the graph. |
73 // This is also true of action and copy steps even though they don't link | 78 // This is also true of action and copy steps even though they don't link |
74 // dependencies, because they also don't propogate libraries up. | 79 // dependencies, because they also don't propogate libraries up. |
75 bool IsFinal() const; | 80 bool IsFinal() const; |
76 | 81 |
77 // Will be the empty string to use the target label as the output name. | 82 // Will be the empty string to use the target label as the output name. |
78 // See GetComputedOutputName(). | 83 // See GetComputedOutputName(). |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // These are only known once the target is resolved and will be empty before | 243 // These are only known once the target is resolved and will be empty before |
239 // that. This is a cache of the files to prevent every target that depends on | 244 // that. This is a cache of the files to prevent every target that depends on |
240 // a given library from recomputing the same pattern. | 245 // a given library from recomputing the same pattern. |
241 const OutputFile& link_output_file() const { | 246 const OutputFile& link_output_file() const { |
242 return link_output_file_; | 247 return link_output_file_; |
243 } | 248 } |
244 const OutputFile& dependency_output_file() const { | 249 const OutputFile& dependency_output_file() const { |
245 return dependency_output_file_; | 250 return dependency_output_file_; |
246 } | 251 } |
247 | 252 |
| 253 // Computes the set of output files resulting from compiling the given source |
| 254 // file. If the file can be compiled and the tool exists, fills the outputs |
| 255 // in and writes the tool type to computed_tool_type. If the file is not |
| 256 // compilable, returns false. |
| 257 // |
| 258 // The function can succeed with a "NONE" tool type for object files which |
| 259 // are just passed to the output. The output will always be overwritten, not |
| 260 // appended to. |
| 261 bool GetOutputFilesForSource(const SourceFile& source, |
| 262 Toolchain::ToolType* computed_tool_type, |
| 263 std::vector<OutputFile>* outputs) const; |
| 264 |
248 private: | 265 private: |
249 FRIEND_TEST_ALL_PREFIXES(Target, ResolvePrecompiledHeaders); | 266 FRIEND_TEST_ALL_PREFIXES(Target, ResolvePrecompiledHeaders); |
250 | 267 |
251 // Pulls necessary information from dependencies to this one when all | 268 // Pulls necessary information from dependencies to this one when all |
252 // dependencies have been resolved. | 269 // dependencies have been resolved. |
253 void PullDependentTargetConfigsFrom(const Target* dep); | 270 void PullDependentTargetConfigsFrom(const Target* dep); |
254 void PullDependentTargetConfigs(); | 271 void PullDependentTargetConfigs(); |
255 void PullDependentTargetLibsFrom(const Target* dep, bool is_public); | 272 void PullDependentTargetLibsFrom(const Target* dep, bool is_public); |
256 void PullDependentTargetLibs(); | 273 void PullDependentTargetLibs(); |
257 void PullRecursiveHardDeps(); | 274 void PullRecursiveHardDeps(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 337 |
321 // Output files. Empty until the target is resolved. | 338 // Output files. Empty until the target is resolved. |
322 std::vector<OutputFile> computed_outputs_; | 339 std::vector<OutputFile> computed_outputs_; |
323 OutputFile link_output_file_; | 340 OutputFile link_output_file_; |
324 OutputFile dependency_output_file_; | 341 OutputFile dependency_output_file_; |
325 | 342 |
326 DISALLOW_COPY_AND_ASSIGN(Target); | 343 DISALLOW_COPY_AND_ASSIGN(Target); |
327 }; | 344 }; |
328 | 345 |
329 #endif // TOOLS_GN_TARGET_H_ | 346 #endif // TOOLS_GN_TARGET_H_ |
OLD | NEW |