OLD | NEW |
| (Empty) |
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" | |
17 #include "tools/gn/config_values.h" | |
18 #include "tools/gn/item.h" | |
19 #include "tools/gn/source_file.h" | |
20 | |
21 class InputFile; | |
22 class Settings; | |
23 class Token; | |
24 | |
25 class Target : public Item { | |
26 public: | |
27 enum OutputType { | |
28 NONE, | |
29 EXECUTABLE, | |
30 SHARED_LIBRARY, | |
31 STATIC_LIBRARY, | |
32 LOADABLE_MODULE, | |
33 COPY_FILES, | |
34 CUSTOM, | |
35 }; | |
36 typedef std::vector<SourceFile> FileList; | |
37 typedef std::vector<std::string> StringVector; | |
38 | |
39 Target(const Settings* settings, const Label& label); | |
40 virtual ~Target(); | |
41 | |
42 // Item overrides. | |
43 virtual Target* AsTarget() OVERRIDE; | |
44 virtual const Target* AsTarget() const OVERRIDE; | |
45 virtual void OnResolved() OVERRIDE; | |
46 | |
47 // This flag indicates if we've run the TargetGenerator for this target to | |
48 // fill out the rest of the values. Once we've done this, we save the | |
49 // location of the function that started the generating so that we can detect | |
50 // duplicate declarations. | |
51 bool HasBeenGenerated() const; | |
52 void SetGenerated(const Token* token); | |
53 | |
54 const Settings* settings() const { return settings_; } | |
55 | |
56 OutputType output_type() const { return output_type_; } | |
57 void set_output_type(OutputType t) { output_type_ = t; } | |
58 | |
59 bool IsLinkable() const; | |
60 | |
61 const FileList& sources() const { return sources_; } | |
62 void swap_in_sources(FileList* s) { sources_.swap(*s); } | |
63 | |
64 const FileList& data() const { return data_; } | |
65 void swap_in_data(FileList* d) { data_.swap(*d); } | |
66 | |
67 const std::vector<const Target*>& deps() const { return deps_; } | |
68 void swap_in_deps(std::vector<const Target*>* d) { deps_.swap(*d); } | |
69 | |
70 // List of configs that this class inherits settings from. | |
71 const std::vector<const Config*>& configs() const { return configs_; } | |
72 void swap_in_configs(std::vector<const Config*>* c) { configs_.swap(*c); } | |
73 | |
74 // List of configs that all dependencies (direct and indirect) of this | |
75 // target get. These configs are not added to this target. | |
76 const std::vector<const Config*>& all_dependent_configs() const { | |
77 return all_dependent_configs_; | |
78 } | |
79 void swap_in_all_dependent_configs(std::vector<const Config*>* c) { | |
80 all_dependent_configs_.swap(*c); | |
81 } | |
82 | |
83 // List of configs that targets depending directly on this one get. These | |
84 // configs are not added to this target. | |
85 const std::vector<const Config*>& direct_dependent_configs() const { | |
86 return direct_dependent_configs_; | |
87 } | |
88 void swap_in_direct_dependent_configs(std::vector<const Config*>* c) { | |
89 direct_dependent_configs_.swap(*c); | |
90 } | |
91 | |
92 const std::set<const Target*>& inherited_libraries() const { | |
93 return inherited_libraries_; | |
94 } | |
95 | |
96 // This config represents the configuration set directly on this target. | |
97 ConfigValues& config_values() { return config_values_; } | |
98 const ConfigValues& config_values() const { return config_values_; } | |
99 | |
100 const SourceDir& destdir() const { return destdir_; } | |
101 void set_destdir(const SourceDir& d) { destdir_ = d; } | |
102 | |
103 const SourceFile& script() const { return script_; } | |
104 void set_script(const SourceFile& s) { script_ = s; } | |
105 | |
106 const std::vector<std::string>& script_args() const { return script_args_; } | |
107 void swap_in_script_args(std::vector<std::string>* sa) { | |
108 script_args_.swap(*sa); | |
109 } | |
110 | |
111 const FileList& outputs() const { return outputs_; } | |
112 void swap_in_outputs(FileList* s) { outputs_.swap(*s); } | |
113 | |
114 private: | |
115 const Settings* settings_; | |
116 OutputType output_type_; | |
117 | |
118 FileList sources_; | |
119 FileList data_; | |
120 std::vector<const Target*> deps_; | |
121 std::vector<const Config*> configs_; | |
122 std::vector<const Config*> all_dependent_configs_; | |
123 std::vector<const Config*> direct_dependent_configs_; | |
124 | |
125 // Libraries from transitive deps. Libraries need to be linked only | |
126 // with the end target (executable, shared library). These do not get | |
127 // pushed beyond shared library boundaries. | |
128 std::set<const Target*> inherited_libraries_; | |
129 | |
130 ConfigValues config_values_; | |
131 | |
132 SourceDir destdir_; | |
133 | |
134 // Script target stuff. | |
135 SourceFile script_; | |
136 std::vector<std::string> script_args_; | |
137 FileList outputs_; | |
138 | |
139 bool generated_; | |
140 const Token* generator_function_; // Who generated this: for error messages. | |
141 | |
142 DISALLOW_COPY_AND_ASSIGN(Target); | |
143 }; | |
144 | |
145 #endif // TOOLS_GN_TARGET_H_ | |
OLD | NEW |