Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: tools/gn/variables.cc

Issue 22290010: Add support for data deps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove switch Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/variables.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "tools/gn/variables.h"
6
7 namespace variables {
8
9 // Built-in variables ----------------------------------------------------------
10
11 extern const char kCurrentToolchain[] = "current_toolchain";
12 extern const char kCurrentToolchain_HelpShort[] =
13 "current_toolchain: [string] Label of the current toolchain.";
14 extern const char kCurrentToolchain_Help[] =
15 "current_toolchain: Label of the current toolchain.\n"
16 "\n"
17 " A fully-qualified label representing the current toolchain. You can\n"
18 " use this to make toolchain-related decisions in the build. See also\n"
19 " \"default_toolchain\".\n"
20 "\n"
21 "Example:\n"
22 "\n"
23 " if (current_toolchain == \"//build:64_bit_toolchain\") {\n"
24 " executable(\"output_thats_64_bit_only\") {\n"
25 " ...\n";
26
27 extern const char kDefaultToolchain[] = "default_toolchain";
28 extern const char kDefaultToolchain_HelpShort[] =
29 "default_toolchain: [string] Label of the default toolchain.";
30 extern const char kDefaultToolchain_Help[] =
31 "default_toolchain: [string] Label of the default toolchain.\n"
32 "\n"
33 " A fully-qualified label representing the default toolchain, which may\n"
34 " not necessarily be the current one (see \"current_toolchain\").\n";
35
36 extern const char kPythonPath[] = "python_path";
37 extern const char kPythonPath_HelpShort[] =
38 "python_path: [string] Absolute path of Python.";
39 extern const char kPythonPath_Help[] =
40 "python_path: Absolute path of Python.\n"
41 "\n"
42 " Normally used in toolchain definitions if running some command\n"
43 " requires Python. You will normally not need this when invoking scripts\n"
44 " since GN automatically finds it for you.\n";
45
46 extern const char kRelativeRootGenDir[] = "relative_root_gen_dir";
47 extern const char kRelativeRootGenDir_HelpShort[] =
48 "relative_root_gen_dir: [string] Relative root dir for generated files.";
49 extern const char kRelativeRootGenDir_Help[] =
50 "relative_root_gen_dir: Relative root for generated files.\n"
51 "\n"
52 " Relative path from the directory of the current build file to the\n"
53 " root of the generated file directory hierarchy for the current\n"
54 " toolchain.\n"
55 "\n"
56 " Generally scripts should use \"relative_target_output_dir\" instead.\n"
57 "\n"
58 "Example:\n"
59 "\n"
60 " If your current build file is in \"//tools\", you might write\n"
61 " args = [ \"$relative_root_gen_dir/output.txt\" ]\n";
62
63 extern const char kRelativeRootOutputDir[] = "relative_root_output_dir";
64 extern const char kRelativeRootOutputDir_HelpShort[] =
65 "relative_root_output_dir: [string] Relative dir for output files.";
66 extern const char kRelativeRootOutputDir_Help[] =
67 "relative_root_output_dir: Relative dir for output files.\n"
68 "\n"
69 " Relative path from the directory of the current build file to the\n"
70 " current toolchain's root build output directory.\n"
71 "\n"
72 " Generally scripts should use \"relative_target_output_dir\" instead.\n";
73
74 extern const char kRelativeTargetGenDir[] = "relative_target_gen_dir";
75 extern const char kRelativeTargetGenDir_HelpShort[] =
76 "relative_target_gen_dir: [string] Relative dir for generated files.";
77 extern const char kRelativeTargetGenDir_Help[] =
78 "relative_target_gen_dir: Relative dir for generated files.\n"
79 "\n"
80 " Relative path from the directory of the current build file to the\n"
81 " current target's generated file directory.\n"
82 "\n"
83 " Normally used when invoking scripts (the current directory of which is\n"
84 " that of the invoking buildfile) that need to write files.\n"
85 "\n"
86 " Scripts generating final rather than intermetiate files should use the\n"
87 " \"relative_target_output_dir\" instead.\n"
88 "\n"
89 "Example:\n"
90 "\n"
91 " If your current build file is in \"//tools\", you might write\n"
92 " args = [ \"$relative_root_gen_dir/output.txt\" ]\n";
93
94 extern const char kRelativeTargetOutputDir[] = "relative_target_output_dir";
95 extern const char kRelativeTargetOutputDir_HelpShort[] =
96 "relative_target_output_dir: [string] Relative dir for build results.";
97 extern const char kRelativeTargetOutputDir_Help[] =
98 "relative_target_output_dir: Relative dir for build results."
99 "\n"
100 " Relative path from the directory of the current build file to the\n"
101 " current target's generated file directory.\n"
102 "\n"
103 " Normally used when invoking scripts (the current directory of which is\n"
104 " that of the invoking buildfile) that need to write files.\n"
105 "\n"
106 " Scripts generating intermediate files rather than final output files\n"
107 " should use the \"relative_target_output_dir\" instead.\n"
108 "\n"
109 "Example:\n"
110 "\n"
111 " If your current build file is in \"//tools\", you might write\n"
112 " args = [ \"$relative_target_output_dir/final.lib\" ]\n";
113
114 // Target variables ------------------------------------------------------------
115
116 const char kAllDependentConfigs[] = "all_dependent_configs";
117 const char kAllDependentConfigs_HelpShort[] =
118 "all_dependent_configs: [label list] Configs to be forced on dependents.";
119 const char kAllDependentConfigs_Help[] =
120 "all_dependent_configs: Configs to be forced on dependents.\n"
121 "\n"
122 " A list of config labels.\n"
123 "\n"
124 " All targets depending on this one, and recursively, all targets\n"
125 " depending on those, will have the configs listed in this variable\n"
126 " added to them.\n"
127 "\n"
128 " This addition happens in a second phase once a target and all of its\n"
129 " dependencies have been resolved. Therefore, a target will not see\n"
130 " these force-added configs in their \"configs\" variable while the\n"
131 " script is running, and then can not be removed. As a result, this\n"
132 " capability should generally only be used to add defines and include\n"
133 " directories necessary to compile a target's headers.\n"
134 "\n"
135 " See also \"direct_dependent_configs\".\n";
136
137 const char kCflags[] = "cflags";
138 const char kCflags_HelpShort[] =
139 "cflags: [string list] Flags passed to all C compiler variants.";
140 // Avoid writing long help for each variant.
141 const char kCommonCflagsHelp[] =
142 "cflags*: Flags passed to the C compiler.\n"
143 "\n"
144 " A list of strings.\n"
145 "\n"
146 " \"cflags\" are passed to all invocations of the C, C++, Objective C,\n"
147 " and Objective C++ compilers.\n"
148 "\n"
149 " To target one of these variants individually, use \"cflags_c\",\n"
150 " \"cflags_cc\", \"cflags_objc\", and \"cflags_objcc\", respectively.\n"
151 " These variant-specific versions will be appended to the \"cflags\".\n";
152 const char* kCflags_Help = kCommonCflagsHelp;
153
154 const char kCflagsC[] = "cflags_c";
155 const char kCflagsC_HelpShort[] =
156 "cflags_c: [string list] Flags passed to the C compiler.";
157 const char* kCflagsC_Help = kCommonCflagsHelp;
158
159 const char kCflagsCC[] = "cflags_cc";
160 const char kCflagsCC_HelpShort[] =
161 "cflags_cc: [string list] Flags passed to the C++ compiler.";
162 const char* kCflagsCC_Help = kCommonCflagsHelp;
163
164 const char kCflagsObjC[] = "cflags_objc";
165 const char kCflagsObjC_HelpShort[] =
166 "cflags_objc: [string list] Flags passed to the Objective C compiler.";
167 const char* kCflagsObjC_Help = kCommonCflagsHelp;
168
169 const char kCflagsObjCC[] = "cflags_objcc";
170 const char kCflagsObjCC_HelpShort[] =
171 "cflags_objcc: [string list] Flags passed to the Objective C++ compiler.";
172 const char* kCflagsObjCC_Help = kCommonCflagsHelp;
173
174 const char kConfigs[] = "configs";
175 const char kConfigs_HelpShort[] =
176 "configs: [label list] Configs applying to this target.";
177 const char kConfigs_Help[] =
178 "configs: Configs applying to this target.\n"
179 "\n"
180 " A list of config labels.\n"
181 "\n"
182 " The includes, defines, etc. in each config are appended in the order\n"
183 " they appear to the compile command for each file in the target. They\n"
184 " will appear after the includes, defines, etc. that the target sets\n"
185 " directly.\n"
186 "\n"
187 " The build configuration script will generally set up the default\n"
188 " configs applying to a given target type (see \"set_defaults\").\n"
189 " When a target is being defined, it can add to or remove from this\n"
190 " list.\n"
191 "\n"
192 "Example:\n"
193 " static_library(\"foo\") {\n"
194 " configs -= \"//build:no_rtti\" # Don't use the default RTTI config.\n"
195 " configs += \":mysettings\" # Add some of our own settings.\n"
196 " }\n";
197
198 const char kDatadeps[] = "datadeps";
199 const char kDatadeps_HelpShort[] =
200 "datadeps: [label list] Non-linked dependencies.";
201 const char kDatadeps_Help[] =
202 "datadeps: Non-linked dependencies.\n"
203 "\n"
204 " A list of target labels.\n"
205 "\n"
206 " Specifies dependencies of a target that are not actually linked into\n"
207 " the current target. Such dependencies will built and will be available\n"
208 " at runtime.\n"
209 "\n"
210 " This is normally used for things like plugins or helper programs that\n"
211 " a target needs at runtime.\n"
212 "\n"
213 " See also \"deps\".\n";
214
215 const char kDefines[] = "defines";
216 const char kDefines_HelpShort[] =
217 "defines: [string list] C preprocessor defines.";
218 const char kDefines_Help[] =
219 "defines: C preprocessor defines.\n"
220 "\n"
221 " A list of strings\n"
222 "\n"
223 " These strings will be passed to the C/C++ compiler as #defines. The\n"
224 " strings may or may not include an \"=\" to assign a value.\n"
225 "\n"
226 "Example:\n"
227 " defines = [ \"AWESOME_FEATURE\", \"LOG_LEVEL=3\" ]\n";
228
229 const char kDeps[] = "deps";
230 const char kDeps_HelpShort[] =
231 "deps: [label list] Linked dependencies.";
232 const char kDeps_Help[] =
233 "deps: Linked dependencies.\n"
234 "\n"
235 " A list of target labels.\n"
236 "\n"
237 " Specifies dependencies of a target. Shared and dynamic libraries will\n"
238 " be linked into the current target. Other target types that can't be\n"
239 " linked (like custom scripts and groups) listed in \"deps\" will be\n"
240 " treated as \"datadeps\". Likewise, if the current target isn't\n"
241 " linkable, then all deps will be treated as \"datadeps\".\n"
242 "\n"
243 " See also \"datadeps\".\n";
244
245 const char kDirectDependentConfigs[] = "direct_dependent_configs";
246 const char kDirectDependentConfigs_HelpShort[] =
247 "direct_dependent_configs: [label list] Configs to be forced on "
248 "dependents.";
249 const char kDirectDependentConfigs_Help[] =
250 "direct_dependent_configs: Configs to be forced on dependents.\n"
251 "\n"
252 " A list of config labels.\n"
253 "\n"
254 " Targets directly referencing this one will have the configs listed in\n"
255 " this variable added to them.\n"
256 "\n"
257 " This addition happens in a second phase once a target and all of its\n"
258 " dependencies have been resolved. Therefore, a target will not see\n"
259 " these force-added configs in their \"configs\" variable while the\n"
260 " script is running, and then can not be removed. As a result, this\n"
261 " capability should generally only be used to add defines and include\n"
262 " directories necessary to compile a target's headers.\n"
263 "\n"
264 " See also \"all_dependent_configs\".\n";
265
266 const char kLdflags[] = "ldflags";
267 const char kLdflags_HelpShort[] =
268 "ldflags: [string list] Flags passed to the linker.";
269 const char kLdflags_Help[] =
270 "ldflags: Flags passed to the linker.\n"
271 "\n"
272 " A list of strings.\n"
273 "\n"
274 " These flags are passed on the command-line to the linker.\n";
275
276 const char kSources[] = "sources";
277 const char kSources_HelpShort[] =
278 "sources: [file list] Source files for a target.";
279 const char kSources_Help[] =
280 "sources: Source files for a target\n"
281 "\n"
282 " A list of files relative to the current buildfile.\n";
283
284 // -----------------------------------------------------------------------------
285
286 VariableInfo::VariableInfo()
287 : help_short(NULL),
288 help(NULL) {
289 }
290
291 VariableInfo::VariableInfo(const char* in_help_short, const char* in_help)
292 : help_short(in_help_short),
293 help(in_help) {
294 }
295
296 #define INSERT_VARIABLE(var) \
297 info_map[k##var] = VariableInfo(k##var##_HelpShort, k##var##_Help);
298
299 const VariableInfoMap& GetBuiltinVariables() {
300 static VariableInfoMap info_map;
301 if (info_map.empty()) {
302 INSERT_VARIABLE(CurrentToolchain)
303 INSERT_VARIABLE(DefaultToolchain)
304 INSERT_VARIABLE(PythonPath)
305 INSERT_VARIABLE(RelativeRootGenDir)
306 INSERT_VARIABLE(RelativeRootOutputDir)
307 INSERT_VARIABLE(RelativeTargetGenDir)
308 INSERT_VARIABLE(RelativeTargetOutputDir)
309 }
310 return info_map;
311 }
312
313 const VariableInfoMap& GetTargetVariables() {
314 static VariableInfoMap info_map;
315 if (info_map.empty()) {
316 INSERT_VARIABLE(AllDependentConfigs)
317 INSERT_VARIABLE(Cflags)
318 INSERT_VARIABLE(CflagsC)
319 INSERT_VARIABLE(CflagsCC)
320 INSERT_VARIABLE(CflagsObjC)
321 INSERT_VARIABLE(CflagsObjCC)
322 INSERT_VARIABLE(Configs)
323 INSERT_VARIABLE(Datadeps)
324 INSERT_VARIABLE(Deps)
325 INSERT_VARIABLE(DirectDependentConfigs)
326 INSERT_VARIABLE(Ldflags)
327 INSERT_VARIABLE(Sources)
328 }
329 return info_map;
330 }
331
332 #undef INSERT_VARIABLE
333
334 } // namespace variables
OLDNEW
« no previous file with comments | « tools/gn/variables.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698