[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / tools / gn / variables.cc
blobe7782d73bd7c81293cdc76574f3018b44d0fa207
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.
5 #include "tools/gn/variables.h"
7 namespace variables {
9 // Built-in variables ----------------------------------------------------------
11 const char kHostCpu[] = "host_cpu";
12 const char kHostCpu_HelpShort[] =
13 "host_cpu: [string] The processor architecture that GN is running on.";
14 const char kHostCpu_Help[] =
15 "host_cpu: The processor architecture that GN is running on.\n"
16 "\n"
17 " This is value is exposed so that cross-compile toolchains can\n"
18 " access the host architecture when needed.\n"
19 "\n"
20 " The value should generally be considered read-only, but it can be\n"
21 " overriden in order to handle unusual cases where there might\n"
22 " be multiple plausible values for the host architecture (e.g., if\n"
23 " you can do either 32-bit or 64-bit builds). The value is not used\n"
24 " internally by GN for any purpose.\n"
25 "\n"
26 "Some possible values:\n"
27 " - \"x64\"\n"
28 " - \"x86\"\n";
30 const char kHostOs[] = "host_os";
31 const char kHostOs_HelpShort[] =
32 "host_os: [string] The operating system that GN is running on.";
33 const char kHostOs_Help[] =
34 "host_os: [string] The operating system that GN is running on.\n"
35 "\n"
36 " This value is exposed so that cross-compiles can access the host\n"
37 " build system's settings.\n"
38 "\n"
39 " This value should generally be treated as read-only. It, however,\n"
40 " is not used internally by GN for any purpose.\n"
41 "\n"
42 "Some possible values:\n"
43 " - \"linux\"\n"
44 " - \"mac\"\n"
45 " - \"win\"\n";
47 const char kTargetCpu[] = "target_cpu";
48 const char kTargetCpu_HelpShort[] =
49 "target_cpu: [string] The desired cpu architecture for the build.";
50 const char kTargetCpu_Help[] =
51 "target_cpu: The desired cpu architecture for the build.\n"
52 "\n"
53 " This value should be used to indicate the desired architecture for\n"
54 " the primary objects of the build. It will match the cpu architecture\n"
55 " of the default toolchain.\n"
56 "\n"
57 " In many cases, this is the same as \"host_cpu\", but in the case\n"
58 " of cross-compiles, this can be set to something different. This \n"
59 " value is different from \"current_cpu\" in that it can be referenced\n"
60 " from inside any toolchain. This value can also be ignored if it is\n"
61 " not needed or meaningful for a project.\n"
62 "\n"
63 " This value is not used internally by GN for any purpose, so it\n"
64 " may be set to whatever value is needed for the build.\n"
65 " GN defaults this value to the empty string (\"\") and the\n"
66 " configuration files should set it to an appropriate value\n"
67 " (e.g., setting it to the value of \"host_cpu\") if it is not\n"
68 " overridden on the command line or in the args.gn file.\n"
69 "\n"
70 " Where practical, use one of the following list of common values:\n"
71 "\n"
72 "Possible values:\n"
73 " - \"x86\"\n"
74 " - \"x64\"\n"
75 " - \"arm\"\n"
76 " - \"arm64\"\n"
77 " - \"mipsel\"\n";
79 const char kTargetOs[] = "target_os";
80 const char kTargetOs_HelpShort[] =
81 "target_os: [string] The desired operating system for the build.";
82 const char kTargetOs_Help[] =
83 "target_os: The desired operating system for the build.\n"
84 "\n"
85 " This value should be used to indicate the desired operating system\n"
86 " for the primary object(s) of the build. It will match the OS of\n"
87 " the default toolchain.\n"
88 "\n"
89 " In many cases, this is the same as \"host_os\", but in the case of\n"
90 " cross-compiles, it may be different. This variable differs from\n"
91 " \"current_os\" in that it can be referenced from inside any\n"
92 " toolchain and will always return the initial value.\n"
93 "\n"
94 " This should be set to the most specific value possible. So,\n"
95 " \"android\" or \"chromeos\" should be used instead of \"linux\"\n"
96 " where applicable, even though Android and ChromeOS are both Linux\n"
97 " variants. This can mean that one needs to write\n"
98 "\n"
99 " if (target_os == \"android\" || target_os == \"linux\") {\n"
100 " # ...\n"
101 " }\n"
102 "\n"
103 " and so forth.\n"
104 "\n"
105 " This value is not used internally by GN for any purpose, so it\n"
106 " may be set to whatever value is needed for the build.\n"
107 " GN defaults this value to the empty string (\"\") and the\n"
108 " configuration files should set it to an appropriate value\n"
109 " (e.g., setting it to the value of \"host_os\") if it is not\n"
110 " set via the command line or in the args.gn file.\n"
111 "\n"
112 " Where practical, use one of the following list of common values:\n"
113 "\n"
114 "Possible values:\n"
115 " - \"android\"\n"
116 " - \"chromeos\"\n"
117 " - \"ios\"\n"
118 " - \"linux\"\n"
119 " - \"nacl\"\n"
120 " - \"mac\"\n"
121 " - \"win\"\n";
123 const char kCurrentCpu[] = "current_cpu";
124 const char kCurrentCpu_HelpShort[] =
125 "current_cpu: [string] The processor architecture of the current "
126 "toolchain.";
127 const char kCurrentCpu_Help[] =
128 "current_cpu: The processor architecture of the current toolchain.\n"
129 "\n"
130 " The build configuration usually sets this value based on the value\n"
131 " of \"host_cpu\" (see \"gn help host_cpu\") and then threads\n"
132 " this through the toolchain definitions to ensure that it always\n"
133 " reflects the appropriate value.\n"
134 "\n"
135 " This value is not used internally by GN for any purpose. It is\n"
136 " set it to the empty string (\"\") by default but is declared so\n"
137 " that it can be overridden on the command line if so desired.\n"
138 "\n"
139 " See \"gn help target_cpu\" for a list of common values returned.\n";
141 const char kCurrentOs[] = "current_os";
142 const char kCurrentOs_HelpShort[] =
143 "current_os: [string] The operating system of the current toolchain.";
144 const char kCurrentOs_Help[] =
145 "current_os: The operating system of the current toolchain.\n"
146 "\n"
147 " The build configuration usually sets this value based on the value\n"
148 " of \"target_os\" (see \"gn help target_os\"), and then threads this\n"
149 " through the toolchain definitions to ensure that it always reflects\n"
150 " the appropriate value.\n"
151 "\n"
152 " This value is not used internally by GN for any purpose. It is\n"
153 " set it to the empty string (\"\") by default but is declared so\n"
154 " that it can be overridden on the command line if so desired.\n"
155 "\n"
156 " See \"gn help target_os\" for a list of common values returned.\n";
158 const char kCurrentToolchain[] = "current_toolchain";
159 const char kCurrentToolchain_HelpShort[] =
160 "current_toolchain: [string] Label of the current toolchain.";
161 const char kCurrentToolchain_Help[] =
162 "current_toolchain: Label of the current toolchain.\n"
163 "\n"
164 " A fully-qualified label representing the current toolchain. You can\n"
165 " use this to make toolchain-related decisions in the build. See also\n"
166 " \"default_toolchain\".\n"
167 "\n"
168 "Example:\n"
169 "\n"
170 " if (current_toolchain == \"//build:64_bit_toolchain\") {\n"
171 " executable(\"output_thats_64_bit_only\") {\n"
172 " ...\n";
174 const char kDefaultToolchain[] = "default_toolchain";
175 const char kDefaultToolchain_HelpShort[] =
176 "default_toolchain: [string] Label of the default toolchain.";
177 const char kDefaultToolchain_Help[] =
178 "default_toolchain: [string] Label of the default toolchain.\n"
179 "\n"
180 " A fully-qualified label representing the default toolchain, which may\n"
181 " not necessarily be the current one (see \"current_toolchain\").\n";
183 const char kPythonPath[] = "python_path";
184 const char kPythonPath_HelpShort[] =
185 "python_path: [string] Absolute path of Python.";
186 const char kPythonPath_Help[] =
187 "python_path: Absolute path of Python.\n"
188 "\n"
189 " Normally used in toolchain definitions if running some command\n"
190 " requires Python. You will normally not need this when invoking scripts\n"
191 " since GN automatically finds it for you.\n";
193 const char kRootBuildDir[] = "root_build_dir";
194 const char kRootBuildDir_HelpShort[] =
195 "root_build_dir: [string] Directory where build commands are run.";
196 const char kRootBuildDir_Help[] =
197 "root_build_dir: [string] Directory where build commands are run.\n"
198 "\n"
199 " This is the root build output directory which will be the current\n"
200 " directory when executing all compilers and scripts.\n"
201 "\n"
202 " Most often this is used with rebase_path (see \"gn help rebase_path\")\n"
203 " to convert arguments to be relative to a script's current directory.\n";
205 const char kRootGenDir[] = "root_gen_dir";
206 const char kRootGenDir_HelpShort[] =
207 "root_gen_dir: [string] Directory for the toolchain's generated files.";
208 const char kRootGenDir_Help[] =
209 "root_gen_dir: Directory for the toolchain's generated files.\n"
210 "\n"
211 " Absolute path to the root of the generated output directory tree for\n"
212 " the current toolchain. An example would be \"//out/Debug/gen\" for the\n"
213 " default toolchain, or \"//out/Debug/arm/gen\" for the \"arm\"\n"
214 " toolchain.\n"
215 "\n"
216 " This is primarily useful for setting up include paths for generated\n"
217 " files. If you are passing this to a script, you will want to pass it\n"
218 " through rebase_path() (see \"gn help rebase_path\") to convert it\n"
219 " to be relative to the build directory.\n"
220 "\n"
221 " See also \"target_gen_dir\" which is usually a better location for\n"
222 " generated files. It will be inside the root generated dir.\n";
224 const char kRootOutDir[] = "root_out_dir";
225 const char kRootOutDir_HelpShort[] =
226 "root_out_dir: [string] Root directory for toolchain output files.";
227 const char kRootOutDir_Help[] =
228 "root_out_dir: [string] Root directory for toolchain output files.\n"
229 "\n"
230 " Absolute path to the root of the output directory tree for the current\n"
231 " toolchain. It will not have a trailing slash.\n"
232 "\n"
233 " For the default toolchain this will be the same as the root_build_dir.\n"
234 " An example would be \"//out/Debug\" for the default toolchain, or\n"
235 " \"//out/Debug/arm\" for the \"arm\" toolchain.\n"
236 "\n"
237 " This is primarily useful for setting up script calls. If you are\n"
238 " passing this to a script, you will want to pass it through\n"
239 " rebase_path() (see \"gn help rebase_path\") to convert it\n"
240 " to be relative to the build directory.\n"
241 "\n"
242 " See also \"target_out_dir\" which is usually a better location for\n"
243 " output files. It will be inside the root output dir.\n"
244 "\n"
245 "Example:\n"
246 "\n"
247 " action(\"myscript\") {\n"
248 " # Pass the output dir to the script.\n"
249 " args = [ \"-o\", rebase_path(root_out_dir, root_build_dir) ]\n"
250 " }\n";
252 const char kTargetGenDir[] = "target_gen_dir";
253 const char kTargetGenDir_HelpShort[] =
254 "target_gen_dir: [string] Directory for a target's generated files.";
255 const char kTargetGenDir_Help[] =
256 "target_gen_dir: Directory for a target's generated files.\n"
257 "\n"
258 " Absolute path to the target's generated file directory. This will be\n"
259 " the \"root_gen_dir\" followed by the relative path to the current\n"
260 " build file. If your file is in \"//tools/doom_melon\" then\n"
261 " target_gen_dir would be \"//out/Debug/gen/tools/doom_melon\". It will\n"
262 " not have a trailing slash.\n"
263 "\n"
264 " This is primarily useful for setting up include paths for generated\n"
265 " files. If you are passing this to a script, you will want to pass it\n"
266 " through rebase_path() (see \"gn help rebase_path\") to convert it\n"
267 " to be relative to the build directory.\n"
268 "\n"
269 " See also \"gn help root_gen_dir\".\n"
270 "\n"
271 "Example:\n"
272 "\n"
273 " action(\"myscript\") {\n"
274 " # Pass the generated output dir to the script.\n"
275 " args = [ \"-o\", rebase_path(target_gen_dir, root_build_dir) ]"
276 "\n"
277 " }\n";
279 const char kTargetOutDir[] = "target_out_dir";
280 const char kTargetOutDir_HelpShort[] =
281 "target_out_dir: [string] Directory for target output files.";
282 const char kTargetOutDir_Help[] =
283 "target_out_dir: [string] Directory for target output files.\n"
284 "\n"
285 " Absolute path to the target's generated file directory. If your\n"
286 " current target is in \"//tools/doom_melon\" then this value might be\n"
287 " \"//out/Debug/obj/tools/doom_melon\". It will not have a trailing\n"
288 " slash.\n"
289 "\n"
290 " This is primarily useful for setting up arguments for calling\n"
291 " scripts. If you are passing this to a script, you will want to pass it\n"
292 " through rebase_path() (see \"gn help rebase_path\") to convert it\n"
293 " to be relative to the build directory.\n"
294 "\n"
295 " See also \"gn help root_out_dir\".\n"
296 "\n"
297 "Example:\n"
298 "\n"
299 " action(\"myscript\") {\n"
300 " # Pass the output dir to the script.\n"
301 " args = [ \"-o\", rebase_path(target_out_dir, root_build_dir) ]"
302 "\n"
303 " }\n";
305 // Target variables ------------------------------------------------------------
307 #define COMMON_ORDERING_HELP \
308 "\n" \
309 "Ordering of flags and values\n" \
310 "\n" \
311 " 1. Those set on the current target (not in a config).\n" \
312 " 2. Those set on the \"configs\" on the target in order that the\n" \
313 " configs appear in the list.\n" \
314 " 3. Those set on the \"all_dependent_configs\" on the target in order\n" \
315 " that the configs appear in the list.\n" \
316 " 4. Those set on the \"public_configs\" on the target in order that\n" \
317 " those configs appear in the list.\n" \
318 " 5. all_dependent_configs pulled from dependencies, in the order of\n" \
319 " the \"deps\" list. This is done recursively. If a config appears\n" \
320 " more than once, only the first occurance will be used.\n" \
321 " 6. public_configs pulled from dependencies, in the order of the\n" \
322 " \"deps\" list. If a dependency is public, they will be applied\n" \
323 " recursively.\n"
325 const char kAllDependentConfigs[] = "all_dependent_configs";
326 const char kAllDependentConfigs_HelpShort[] =
327 "all_dependent_configs: [label list] Configs to be forced on dependents.";
328 const char kAllDependentConfigs_Help[] =
329 "all_dependent_configs: Configs to be forced on dependents.\n"
330 "\n"
331 " A list of config labels.\n"
332 "\n"
333 " All targets depending on this one, and recursively, all targets\n"
334 " depending on those, will have the configs listed in this variable\n"
335 " added to them. These configs will also apply to the current target.\n"
336 "\n"
337 " This addition happens in a second phase once a target and all of its\n"
338 " dependencies have been resolved. Therefore, a target will not see\n"
339 " these force-added configs in their \"configs\" variable while the\n"
340 " script is running, and then can not be removed. As a result, this\n"
341 " capability should generally only be used to add defines and include\n"
342 " directories necessary to compile a target's headers.\n"
343 "\n"
344 " See also \"public_configs\".\n"
345 COMMON_ORDERING_HELP;
347 const char kAllowCircularIncludesFrom[] = "allow_circular_includes_from";
348 const char kAllowCircularIncludesFrom_HelpShort[] =
349 "allow_circular_includes_from: [label list] Permit includes from deps.";
350 const char kAllowCircularIncludesFrom_Help[] =
351 "allow_circular_includes_from: Permit includes from deps.\n"
352 "\n"
353 " A list of target labels. Must be a subset of the target's \"deps\".\n"
354 " These targets will be permitted to include headers from the current\n"
355 " target despite the dependency going in the opposite direction.\n"
356 "\n"
357 "Tedious exposition\n"
358 "\n"
359 " Normally, for a file in target A to include a file from target B,\n"
360 " A must list B as a dependency. This invariant is enforced by the\n"
361 " \"gn check\" command (and the --check flag to \"gn gen\").\n"
362 "\n"
363 " Sometimes, two targets might be the same unit for linking purposes\n"
364 " (two source sets or static libraries that would always be linked\n"
365 " together in a final executable or shared library). In this case,\n"
366 " you want A to be able to include B's headers, and B to include A's\n"
367 " headers.\n"
368 "\n"
369 " This list, if specified, lists which of the dependencies of the\n"
370 " current target can include header files from the current target.\n"
371 " That is, if A depends on B, B can only include headers from A if it is\n"
372 " in A's allow_circular_includes_from list.\n"
373 "\n"
374 "Example\n"
375 "\n"
376 " source_set(\"a\") {\n"
377 " deps = [ \":b\", \":c\" ]\n"
378 " allow_circular_includes_from = [ \":b\" ]\n"
379 " ...\n"
380 " }\n";
382 const char kArgs[] = "args";
383 const char kArgs_HelpShort[] =
384 "args: [string list] Arguments passed to an action.";
385 const char kArgs_Help[] =
386 "args: Arguments passed to an action.\n"
387 "\n"
388 " For action and action_foreach targets, args is the list of arguments\n"
389 " to pass to the script. Typically you would use source expansion (see\n"
390 " \"gn help source_expansion\") to insert the source file names.\n"
391 "\n"
392 " See also \"gn help action\" and \"gn help action_foreach\".\n";
394 const char kCflags[] = "cflags";
395 const char kCflags_HelpShort[] =
396 "cflags: [string list] Flags passed to all C compiler variants.";
397 const char kCommonCflagsHelp[] =
398 "cflags*: Flags passed to the C compiler.\n"
399 "\n"
400 " A list of strings.\n"
401 "\n"
402 " \"cflags\" are passed to all invocations of the C, C++, Objective C,\n"
403 " and Objective C++ compilers.\n"
404 "\n"
405 " To target one of these variants individually, use \"cflags_c\",\n"
406 " \"cflags_cc\", \"cflags_objc\", and \"cflags_objcc\", respectively.\n"
407 " These variant-specific versions will be appended to the \"cflags\".\n"
408 COMMON_ORDERING_HELP;
409 const char* kCflags_Help = kCommonCflagsHelp;
411 const char kCflagsC[] = "cflags_c";
412 const char kCflagsC_HelpShort[] =
413 "cflags_c: [string list] Flags passed to the C compiler.";
414 const char* kCflagsC_Help = kCommonCflagsHelp;
416 const char kCflagsCC[] = "cflags_cc";
417 const char kCflagsCC_HelpShort[] =
418 "cflags_cc: [string list] Flags passed to the C++ compiler.";
419 const char* kCflagsCC_Help = kCommonCflagsHelp;
421 const char kCflagsObjC[] = "cflags_objc";
422 const char kCflagsObjC_HelpShort[] =
423 "cflags_objc: [string list] Flags passed to the Objective C compiler.";
424 const char* kCflagsObjC_Help = kCommonCflagsHelp;
426 const char kCflagsObjCC[] = "cflags_objcc";
427 const char kCflagsObjCC_HelpShort[] =
428 "cflags_objcc: [string list] Flags passed to the Objective C++ compiler.";
429 const char* kCflagsObjCC_Help = kCommonCflagsHelp;
431 const char kCheckIncludes[] = "check_includes";
432 const char kCheckIncludes_HelpShort[] =
433 "check_includes: [boolean] Controls whether a target's files are checked.";
434 const char kCheckIncludes_Help[] =
435 "check_includes: [boolean] Controls whether a target's files are checked.\n"
436 "\n"
437 " When true (the default), the \"gn check\" command (as well as\n"
438 " \"gn gen\" with the --check flag) will check this target's sources\n"
439 " and headers for proper dependencies.\n"
440 "\n"
441 " When false, the files in this target will be skipped by default.\n"
442 " This does not affect other targets that depend on the current target,\n"
443 " it just skips checking the includes of the current target's files.\n"
444 "\n"
445 "Controlling includes individually\n"
446 "\n"
447 " If only certain includes are problematic, you can annotate them\n"
448 " individually rather than disabling header checking on an entire\n"
449 " target. Add the string \"nogncheck\" to the include line:\n"
450 "\n"
451 " #include \"foo/something_weird.h\" // nogncheck (bug 12345)\n"
452 "\n"
453 " It is good form to include a reference to a bug (if the include is\n"
454 " improper, or some other comment expressing why the header checker\n"
455 " doesn't work for this particular case.\n"
456 "\n"
457 " The most common reason to need \"nogncheck\" is conditional includes.\n"
458 " The header checker does not understand the preprocessor, so may flag\n"
459 " some includes as improper even if the dependencies and #defines are\n"
460 " always matched correctly:\n"
461 "\n"
462 " #if defined(ENABLE_DOOM_MELON)\n"
463 " #include \"doom_melon/beam_controller.h\" // nogncheck\n"
464 " #endif\n"
465 "\n"
466 "Example\n"
467 "\n"
468 " source_set(\"busted_includes\") {\n"
469 " # This target's includes are messed up, exclude it from checking.\n"
470 " check_includes = false\n"
471 " ...\n"
472 " }\n";
474 const char kCompleteStaticLib[] = "complete_static_lib";
475 const char kCompleteStaticLib_HelpShort[] =
476 "complete_static_lib: [boolean] Links all deps into a static library.";
477 const char kCompleteStaticLib_Help[] =
478 "complete_static_lib: [boolean] Links all deps into a static library.\n"
479 "\n"
480 " A static library normally doesn't include code from dependencies, but\n"
481 " instead forwards the static libraries and source sets in its deps up\n"
482 " the dependency chain until a linkable target (an executable or shared\n"
483 " library) is reached. The final linkable target only links each static\n"
484 " library once, even if it appears more than once in its dependency\n"
485 " graph.\n"
486 "\n"
487 " In some cases the static library might be the final desired output.\n"
488 " For example, you may be producing a static library for distribution to\n"
489 " third parties. In this case, the static library should include code\n"
490 " for all dependencies in one complete package. Since GN does not unpack\n"
491 " static libraries to forward their contents up the dependency chain,\n"
492 " it is an error for complete static libraries to depend on other static\n"
493 " libraries.\n"
494 "\n"
495 "Example\n"
496 "\n"
497 " static_library(\"foo\") {\n"
498 " complete_static_lib = true\n"
499 " deps = [ \"bar\" ]\n"
500 " }\n";
502 const char kConfigs[] = "configs";
503 const char kConfigs_HelpShort[] =
504 "configs: [label list] Configs applying to this target or config.";
505 const char kConfigs_Help[] =
506 "configs: Configs applying to this target or config.\n"
507 "\n"
508 " A list of config labels.\n"
509 "\n"
510 "Configs on a target\n"
511 "\n"
512 " When used on a target, the include_dirs, defines, etc. in each config\n"
513 " are appended in the order they appear to the compile command for each\n"
514 " file in the target. They will appear after the include_dirs, defines,\n"
515 " etc. that the target sets directly.\n"
516 "\n"
517 " Since configs apply after the values set on a target, directly setting\n"
518 " a compiler flag will prepend it to the command line. If you want to\n"
519 " append a flag instead, you can put that flag in a one-off config and\n"
520 " append that config to the target's configs list.\n"
521 "\n"
522 " The build configuration script will generally set up the default\n"
523 " configs applying to a given target type (see \"set_defaults\").\n"
524 " When a target is being defined, it can add to or remove from this\n"
525 " list.\n"
526 "\n"
527 "Configs on a config\n"
528 "\n"
529 " It is possible to create composite configs by specifying configs on a\n"
530 " config. One might do this to forward values, or to factor out blocks\n"
531 " of settings from very large configs into more manageable named chunks.\n"
532 "\n"
533 " In this case, the composite config is expanded to be the concatenation\n"
534 " of its own values, and in order, the values from its sub-configs\n"
535 " *before* anything else happens. This has some ramifications:\n"
536 "\n"
537 " - A target has no visibility into a config's sub-configs. Target\n"
538 " code only sees the name of the composite config. It can't remove\n"
539 " sub-configs or opt in to only parts of it. The composite config may\n"
540 " not even be defined before the target is.\n"
541 "\n"
542 " - You can get duplication of values if a config is listed twice, say,\n"
543 " on a target and in a sub-config that also applies. In other cases,\n"
544 " the configs applying to a target are de-duped. It's expected that\n"
545 " if a config is listed as a sub-config that it is only used in that\n"
546 " context. (Note that it's possible to fix this and de-dupe, but it's\n"
547 " not normally relevant and complicates the implementation.)\n"
548 COMMON_ORDERING_HELP
549 "\n"
550 "Example\n"
551 "\n"
552 " # Configs on a target.\n"
553 " source_set(\"foo\") {\n"
554 " # Don't use the default RTTI config that BUILDCONFIG applied to us.\n"
555 " configs -= [ \"//build:no_rtti\" ]\n"
556 "\n"
557 " # Add some of our own settings.\n"
558 " configs += [ \":mysettings\" ]\n"
559 " }\n"
560 "\n"
561 " # Create a default_optimization config that forwards to one of a set\n"
562 " # of more specialized configs depending on build flags. This pattern\n"
563 " # is useful because it allows a target to opt in to either a default\n"
564 " # set, or a more specific set, while avoid duplicating the settings in\n"
565 " # two places.\n"
566 " config(\"super_optimization\") {\n"
567 " cflags = [ ... ]\n"
568 " }\n"
569 " config(\"default_optimization\") {\n"
570 " if (optimize_everything) {\n"
571 " configs = [ \":super_optimization\" ]\n"
572 " } else {\n"
573 " configs = [ \":no_optimization\" ]\n"
574 " }\n"
575 " }\n";
577 const char kData[] = "data";
578 const char kData_HelpShort[] =
579 "data: [file list] Runtime data file dependencies.";
580 const char kData_Help[] =
581 "data: Runtime data file dependencies.\n"
582 "\n"
583 " Lists files or directories required to run the given target. These are\n"
584 " typically data files or directories of data files. The paths are\n"
585 " interpreted as being relative to the current build file. Since these\n"
586 " are runtime dependencies, they do not affect which targets are built\n"
587 " or when. To declare input files to a script, use \"inputs\".\n"
588 "\n"
589 " Appearing in the \"data\" section does not imply any special handling\n"
590 " such as copying them to the output directory. This is just used for\n"
591 " declaring runtime dependencies. Runtime dependencies can be queried\n"
592 " using the \"runtime_deps\" category of \"gn desc\" or written during\n"
593 " build generation via \"--runtime-deps-list-file\".\n"
594 "\n"
595 " GN doesn't require data files to exist at build-time. So actions that\n"
596 " produce files that are in turn runtime dependencies can list those\n"
597 " generated files both in the \"outputs\" list as well as the \"data\"\n"
598 " list.\n"
599 "\n"
600 " By convention, directories are be listed with a trailing slash:\n"
601 " data = [ \"test/data/\" ]\n"
602 " However, no verification is done on these so GN doesn't enforce this.\n"
603 " The paths are just rebased and passed along when requested.\n"
604 "\n"
605 " See \"gn help runtime_deps\" for how these are used.\n";
607 const char kDataDeps[] = "data_deps";
608 const char kDataDeps_HelpShort[] =
609 "data_deps: [label list] Non-linked dependencies.";
610 const char kDataDeps_Help[] =
611 "data_deps: Non-linked dependencies.\n"
612 "\n"
613 " A list of target labels.\n"
614 "\n"
615 " Specifies dependencies of a target that are not actually linked into\n"
616 " the current target. Such dependencies will be built and will be\n"
617 " available at runtime.\n"
618 "\n"
619 " This is normally used for things like plugins or helper programs that\n"
620 " a target needs at runtime.\n"
621 "\n"
622 " See also \"gn help deps\" and \"gn help data\".\n"
623 "\n"
624 "Example:\n"
625 " executable(\"foo\") {\n"
626 " deps = [ \"//base\" ]\n"
627 " data_deps = [ \"//plugins:my_runtime_plugin\" ]\n"
628 " }\n";
630 const char kDefines[] = "defines";
631 const char kDefines_HelpShort[] =
632 "defines: [string list] C preprocessor defines.";
633 const char kDefines_Help[] =
634 "defines: C preprocessor defines.\n"
635 "\n"
636 " A list of strings\n"
637 "\n"
638 " These strings will be passed to the C/C++ compiler as #defines. The\n"
639 " strings may or may not include an \"=\" to assign a value.\n"
640 COMMON_ORDERING_HELP
641 "\n"
642 "Example:\n"
643 " defines = [ \"AWESOME_FEATURE\", \"LOG_LEVEL=3\" ]\n";
645 const char kDepfile[] = "depfile";
646 const char kDepfile_HelpShort[] =
647 "depfile: [string] File name for input dependencies for actions.";
648 const char kDepfile_Help[] =
649 "depfile: [string] File name for input dependencies for actions.\n"
650 "\n"
651 " If nonempty, this string specifies that the current action or\n"
652 " action_foreach target will generate the given \".d\" file containing\n"
653 " the dependencies of the input. Empty or unset means that the script\n"
654 " doesn't generate the files.\n"
655 "\n"
656 " The .d file should go in the target output directory. If you have more\n"
657 " than one source file that the script is being run over, you can use\n"
658 " the output file expansions described in \"gn help action_foreach\" to\n"
659 " name the .d file according to the input."
660 "\n"
661 " The format is that of a Makefile, and all of the paths should be\n"
662 " relative to the root build directory.\n"
663 "\n"
664 "Example:\n"
665 " action_foreach(\"myscript_target\") {\n"
666 " script = \"myscript.py\"\n"
667 " sources = [ ... ]\n"
668 "\n"
669 " # Locate the depfile in the output directory named like the\n"
670 " # inputs but with a \".d\" appended.\n"
671 " depfile = \"$relative_target_output_dir/{{source_name}}.d\"\n"
672 "\n"
673 " # Say our script uses \"-o <d file>\" to indicate the depfile.\n"
674 " args = [ \"{{source}}\", \"-o\", depfile ]\n"
675 " }\n";
677 const char kDeps[] = "deps";
678 const char kDeps_HelpShort[] =
679 "deps: [label list] Private linked dependencies.";
680 const char kDeps_Help[] =
681 "deps: Private linked dependencies.\n"
682 "\n"
683 " A list of target labels.\n"
684 "\n"
685 " Specifies private dependencies of a target. Shared and dynamic\n"
686 " libraries will be linked into the current target. Other target types\n"
687 " that can't be linked (like actions and groups) listed in \"deps\" will\n"
688 " be treated as \"data_deps\". Likewise, if the current target isn't\n"
689 " linkable, then all deps will be treated as \"data_deps\".\n"
690 "\n"
691 " These dependencies are private in that it does not grant dependent\n"
692 " targets the ability to include headers from the dependency, and direct\n"
693 " dependent configs are not forwarded.\n"
694 "\n"
695 " See also \"public_deps\" and \"data_deps\".\n";
697 // TODO(brettw) remove this, deprecated.
698 const char kForwardDependentConfigsFrom[] = "forward_dependent_configs_from";
699 const char kForwardDependentConfigsFrom_HelpShort[] =
700 "forward_dependent_configs_from: [label list] DEPRECATED.";
701 const char kForwardDependentConfigsFrom_Help[] =
702 "forward_dependent_configs_from\n"
703 "\n"
704 " A list of target labels.\n"
705 "\n"
706 " DEPRECATED. Use public_deps instead which will have the same effect.\n"
707 "\n"
708 " Exposes the public_configs from a private dependent target as\n"
709 " public_configs of the current one. Each label in this list\n"
710 " must also be in the deps.\n"
711 "\n"
712 " Generally you should use public_deps instead of this variable to\n"
713 " express the concept of exposing a dependency as part of a target's\n"
714 " public API. We're considering removing this variable.\n"
715 "\n"
716 "Discussion\n"
717 "\n"
718 " Sometimes you depend on a child library that exports some necessary\n"
719 " configuration via public_configs. If your target in turn exposes the\n"
720 " child library's headers in its public headers, it might mean that\n"
721 " targets that depend on you won't work: they'll be seeing the child\n"
722 " library's code but not the necessary configuration. This list\n"
723 " specifies which of your deps' direct dependent configs to expose as\n"
724 " your own.\n"
725 "\n"
726 "Examples\n"
727 "\n"
728 " If we use a given library \"a\" from our public headers:\n"
729 "\n"
730 " deps = [ \":a\", \":b\", ... ]\n"
731 " forward_dependent_configs_from = [ \":a\" ]\n"
732 "\n"
733 " This example makes a \"transparent\" target that forwards a dependency\n"
734 " to another:\n"
735 "\n"
736 " group(\"frob\") {\n"
737 " if (use_system_frob) {\n"
738 " deps = \":system_frob\"\n"
739 " } else {\n"
740 " deps = \"//third_party/fallback_frob\"\n"
741 " }\n"
742 " forward_dependent_configs_from = deps\n"
743 " }\n";
745 const char kIncludeDirs[] = "include_dirs";
746 const char kIncludeDirs_HelpShort[] =
747 "include_dirs: [directory list] Additional include directories.";
748 const char kIncludeDirs_Help[] =
749 "include_dirs: Additional include directories.\n"
750 "\n"
751 " A list of source directories.\n"
752 "\n"
753 " The directories in this list will be added to the include path for\n"
754 " the files in the affected target.\n"
755 COMMON_ORDERING_HELP
756 "\n"
757 "Example:\n"
758 " include_dirs = [ \"src/include\", \"//third_party/foo\" ]\n";
760 const char kInputs[] = "inputs";
761 const char kInputs_HelpShort[] =
762 "inputs: [file list] Additional compile-time dependencies.";
763 const char kInputs_Help[] =
764 "inputs: Additional compile-time dependencies.\n"
765 "\n"
766 " Inputs are compile-time dependencies of the current target. This means\n"
767 " that all inputs must be available before compiling any of the sources\n"
768 " or executing any actions.\n"
769 "\n"
770 " Inputs are typically only used for action and action_foreach targets.\n"
771 "\n"
772 "Inputs for actions\n"
773 "\n"
774 " For action and action_foreach targets, inputs should be the inputs to\n"
775 " script that don't vary. These should be all .py files that the script\n"
776 " uses via imports (the main script itself will be an implcit dependency\n"
777 " of the action so need not be listed).\n"
778 "\n"
779 " For action targets, inputs should be the entire set of inputs the\n"
780 " script needs. For action_foreach targets, inputs should be the set of\n"
781 " dependencies that don't change. These will be applied to each script\n"
782 " invocation over the sources.\n"
783 "\n"
784 " Note that another way to declare input dependencies from an action\n"
785 " is to have the action write a depfile (see \"gn help depfile\"). This\n"
786 " allows the script to dynamically write input dependencies, that might\n"
787 " not be known until actually executing the script. This is more\n"
788 " efficient than doing processing while running GN to determine the\n"
789 " inputs, and is easier to keep in-sync than hardcoding the list.\n"
790 "\n"
791 "Inputs for binary targets\n"
792 "\n"
793 " Any input dependencies will be resolved before compiling any sources.\n"
794 " Normally, all actions that a target depends on will be run before any\n"
795 " files in a target are compiled. So if you depend on generated headers,\n"
796 " you do not typically need to list them in the inputs section.\n"
797 "\n"
798 "Example\n"
799 "\n"
800 " action(\"myscript\") {\n"
801 " script = \"domything.py\"\n"
802 " inputs = [ \"input.data\" ]\n"
803 " }\n";
805 const char kLdflags[] = "ldflags";
806 const char kLdflags_HelpShort[] =
807 "ldflags: [string list] Flags passed to the linker.";
808 const char kLdflags_Help[] =
809 "ldflags: Flags passed to the linker.\n"
810 "\n"
811 " A list of strings.\n"
812 "\n"
813 " These flags are passed on the command-line to the linker and generally\n"
814 " specify various linking options. Most targets will not need these and\n"
815 " will use \"libs\" and \"lib_dirs\" instead.\n"
816 "\n"
817 " ldflags are NOT pushed to dependents, so applying ldflags to source\n"
818 " sets or static libraries will be a no-op. If you want to apply ldflags\n"
819 " to dependent targets, put them in a config and set it in the\n"
820 " all_dependent_configs or public_configs.\n"
821 COMMON_ORDERING_HELP;
823 #define COMMON_LIB_INHERITANCE_HELP \
824 "\n" \
825 " libs and lib_dirs work differently than other flags in two respects.\n" \
826 " First, then are inherited across static library boundaries until a\n" \
827 " shared library or executable target is reached. Second, they are\n" \
828 " uniquified so each one is only passed once (the first instance of it\n" \
829 " will be the one used).\n"
831 const char kLibDirs[] = "lib_dirs";
832 const char kLibDirs_HelpShort[] =
833 "lib_dirs: [directory list] Additional library directories.";
834 const char kLibDirs_Help[] =
835 "lib_dirs: Additional library directories.\n"
836 "\n"
837 " A list of directories.\n"
838 "\n"
839 " Specifies additional directories passed to the linker for searching\n"
840 " for the required libraries. If an item is not an absolute path, it\n"
841 " will be treated as being relative to the current build file.\n"
842 COMMON_LIB_INHERITANCE_HELP
843 COMMON_ORDERING_HELP
844 "\n"
845 "Example:\n"
846 " lib_dirs = [ \"/usr/lib/foo\", \"lib/doom_melon\" ]\n";
848 const char kLibs[] = "libs";
849 const char kLibs_HelpShort[] =
850 "libs: [string list] Additional libraries to link.";
851 const char kLibs_Help[] =
852 "libs: Additional libraries to link.\n"
853 "\n"
854 " A list of strings.\n"
855 "\n"
856 " These files will be passed to the linker, which will generally search\n"
857 " the library include path. Unlike a normal list of files, they will be\n"
858 " passed to the linker unmodified rather than being treated as file\n"
859 " names relative to the current build file. Generally you would set\n"
860 " the \"lib_dirs\" so your library is found. If you need to specify\n"
861 " a path, you can use \"rebase_path\" to convert a path to be relative\n"
862 " to the build directory.\n"
863 "\n"
864 " When constructing the linker command, the \"lib_prefix\" attribute of\n"
865 " the linker tool in the current toolchain will be prepended to each\n"
866 " library. So your BUILD file should not specify the switch prefix\n"
867 " (like \"-l\"). On Mac, libraries ending in \".framework\" will be\n"
868 " special-cased: the switch \"-framework\" will be prepended instead of\n"
869 " the lib_prefix, and the \".framework\" suffix will be trimmed.\n"
870 COMMON_LIB_INHERITANCE_HELP
871 COMMON_ORDERING_HELP
872 "\n"
873 "Examples:\n"
874 " On Windows:\n"
875 " libs = [ \"ctl3d.lib\" ]\n"
876 " On Linux:\n"
877 " libs = [ \"ld\" ]\n";
879 const char kOutputExtension[] = "output_extension";
880 const char kOutputExtension_HelpShort[] =
881 "output_extension: [string] Value to use for the output's file extension.";
882 const char kOutputExtension_Help[] =
883 "output_extension: Value to use for the output's file extension.\n"
884 "\n"
885 " Normally the file extension for a target is based on the target\n"
886 " type and the operating system, but in rare cases you will need to\n"
887 " override the name (for example to use \"libfreetype.so.6\" instead\n"
888 " of libfreetype.so on Linux).";
890 const char kOutputName[] = "output_name";
891 const char kOutputName_HelpShort[] =
892 "output_name: [string] Name for the output file other than the default.";
893 const char kOutputName_Help[] =
894 "output_name: Define a name for the output file other than the default.\n"
895 "\n"
896 " Normally the output name of a target will be based on the target name,\n"
897 " so the target \"//foo/bar:bar_unittests\" will generate an output\n"
898 " file such as \"bar_unittests.exe\" (using Windows as an example).\n"
899 "\n"
900 " Sometimes you will want an alternate name to avoid collisions or\n"
901 " if the internal name isn't appropriate for public distribution.\n"
902 "\n"
903 " The output name should have no extension or prefixes, these will be\n"
904 " added using the default system rules. For example, on Linux an output\n"
905 " name of \"foo\" will produce a shared library \"libfoo.so\".\n"
906 "\n"
907 " This variable is valid for all binary output target types.\n"
908 "\n"
909 "Example:\n"
910 " static_library(\"doom_melon\") {\n"
911 " output_name = \"fluffy_bunny\"\n"
912 " }\n";
914 const char kOutputs[] = "outputs";
915 const char kOutputs_HelpShort[] =
916 "outputs: [file list] Output files for actions and copy targets.";
917 const char kOutputs_Help[] =
918 "outputs: Output files for actions and copy targets.\n"
919 "\n"
920 " Outputs is valid for \"copy\", \"action\", and \"action_foreach\"\n"
921 " target types and indicates the resulting files. The values may contain\n"
922 " source expansions to generate the output names from the sources (see\n"
923 " \"gn help source_expansion\").\n"
924 "\n"
925 " For copy targets, the outputs is the destination for the copied\n"
926 " file(s). For actions, the outputs should be the list of files\n"
927 " generated by the script.\n";
929 const char kPrecompiledHeader[] = "precompiled_header";
930 const char kPrecompiledHeader_HelpShort[] =
931 "precompiled_header: [string] Header file to precompile.";
932 const char kPrecompiledHeader_Help[] =
933 "precompiled_header: [string] Header file to precompile.\n"
934 "\n"
935 " Precompiled headers will be used when a target specifies this\n"
936 " value, or a config applying to this target specifies this value.\n"
937 " In addition, the tool corresponding to the source files must also\n"
938 " specify precompiled headers (see \"gn help tool\"). The tool\n"
939 " will also specify what type of precompiled headers to use.\n"
940 "\n"
941 " The precompiled header/source variables can be specified on a target\n"
942 " or a config, but must be the same for all configs applying to a given\n"
943 " target since a target can only have one precompiled header.\n"
944 "\n"
945 "MSVC precompiled headers\n"
946 "\n"
947 " When using MSVC-style precompiled headers, the \"precompiled_header\"\n"
948 " value is a string corresponding to the header. This is NOT a path\n"
949 " to a file that GN recognises, but rather the exact string that appears\n"
950 " in quotes after an #include line in source code. The compiler will\n"
951 " match this string against includes or forced includes (/FI).\n"
952 "\n"
953 " MSVC also requires a source file to compile the header with. This must\n"
954 " be specified by the \"precompiled_source\" value. In contrast to the\n"
955 " header value, this IS a GN-style file name, and tells GN which source\n"
956 " file to compile to make the .pch file used for subsequent compiles.\n"
957 "\n"
958 " If you use both C and C++ sources, the precompiled header and source\n"
959 " file will be compiled using both tools. You will want to make sure\n"
960 " to wrap C++ includes in __cplusplus #ifdefs so the file will compile\n"
961 " in C mode.\n"
962 "\n"
963 " For example, if the toolchain specifies MSVC headers:\n"
964 "\n"
965 " toolchain(\"vc_x64\") {\n"
966 " ...\n"
967 " tool(\"cxx\") {\n"
968 " precompiled_header_type = \"msvc\"\n"
969 " ...\n"
970 "\n"
971 " You might make a config like this:\n"
972 "\n"
973 " config(\"use_precompiled_headers\") {\n"
974 " precompiled_header = \"build/precompile.h\"\n"
975 " precompiled_source = \"//build/precompile.cc\"\n"
976 "\n"
977 " # Either your source files should #include \"build/precompile.h\"\n"
978 " # first, or you can do this to force-include the header.\n"
979 " cflags = [ \"/FI$precompiled_header\" ]\n"
980 " }\n"
981 "\n"
982 " And then define a target that uses the config:\n"
983 "\n"
984 " executable(\"doom_melon\") {\n"
985 " configs += [ \":use_precompiled_headers\" ]\n"
986 " ...\n"
987 "\n";
989 const char kPrecompiledSource[] = "precompiled_source";
990 const char kPrecompiledSource_HelpShort[] =
991 "precompiled_source: [file name] Source file to precompile.";
992 const char kPrecompiledSource_Help[] =
993 "precompiled_source: [file name] Source file to precompile.\n"
994 "\n"
995 " The source file that goes along with the precompiled_header when\n"
996 " using \"msvc\"-style precompiled headers. It will be implicitly added\n"
997 " to the sources of the target. See \"gn help precompiled_header\".\n";
999 const char kPublic[] = "public";
1000 const char kPublic_HelpShort[] =
1001 "public: [file list] Declare public header files for a target.";
1002 const char kPublic_Help[] =
1003 "public: Declare public header files for a target.\n"
1004 "\n"
1005 " A list of files that other targets can include. These permissions are\n"
1006 " checked via the \"check\" command (see \"gn help check\").\n"
1007 "\n"
1008 " If no public files are declared, other targets (assuming they have\n"
1009 " visibility to depend on this target can include any file in the\n"
1010 " sources list. If this variable is defined on a target, dependent\n"
1011 " targets may only include files on this whitelist.\n"
1012 "\n"
1013 " Header file permissions are also subject to visibility. A target\n"
1014 " must be visible to another target to include any files from it at all\n"
1015 " and the public headers indicate which subset of those files are\n"
1016 " permitted. See \"gn help visibility\" for more.\n"
1017 "\n"
1018 " Public files are inherited through the dependency tree. So if there is\n"
1019 " a dependency A -> B -> C, then A can include C's public headers.\n"
1020 " However, the same is NOT true of visibility, so unless A is in C's\n"
1021 " visibility list, the include will be rejected.\n"
1022 "\n"
1023 " GN only knows about files declared in the \"sources\" and \"public\"\n"
1024 " sections of targets. If a file is included that is not known to the\n"
1025 " build, it will be allowed.\n"
1026 "\n"
1027 "Examples:\n"
1028 " These exact files are public:\n"
1029 " public = [ \"foo.h\", \"bar.h\" ]\n"
1030 "\n"
1031 " No files are public (no targets may include headers from this one):\n"
1032 " public = []\n";
1034 const char kPublicConfigs[] = "public_configs";
1035 const char kPublicConfigs_HelpShort[] =
1036 "public_configs: [label list] Configs applied to dependents.";
1037 const char kPublicConfigs_Help[] =
1038 "public_configs: Configs to be applied on dependents.\n"
1039 "\n"
1040 " A list of config labels.\n"
1041 "\n"
1042 " Targets directly depending on this one will have the configs listed in\n"
1043 " this variable added to them. These configs will also apply to the\n"
1044 " current target.\n"
1045 "\n"
1046 " This addition happens in a second phase once a target and all of its\n"
1047 " dependencies have been resolved. Therefore, a target will not see\n"
1048 " these force-added configs in their \"configs\" variable while the\n"
1049 " script is running, and then can not be removed. As a result, this\n"
1050 " capability should generally only be used to add defines and include\n"
1051 " directories necessary to compile a target's headers.\n"
1052 "\n"
1053 " See also \"all_dependent_configs\".\n"
1054 COMMON_ORDERING_HELP;
1056 const char kPublicDeps[] = "public_deps";
1057 const char kPublicDeps_HelpShort[] =
1058 "public_deps: [label list] Declare public dependencies.";
1059 const char kPublicDeps_Help[] =
1060 "public_deps: Declare public dependencies.\n"
1061 "\n"
1062 " Public dependencies are like private dependencies (\"deps\") but\n"
1063 " additionally express that the current target exposes the listed deps\n"
1064 " as part of its public API.\n"
1065 "\n"
1066 " This has several ramifications:\n"
1067 "\n"
1068 " - public_configs that are part of the dependency are forwarded\n"
1069 " to direct dependents.\n"
1070 "\n"
1071 " - Public headers in the dependency are usable by dependents\n"
1072 " (includes do not require a direct dependency or visibility).\n"
1073 "\n"
1074 " - If the current target is a shared library, other shared libraries\n"
1075 " that it publicly depends on (directly or indirectly) are\n"
1076 " propagated up the dependency tree to dependents for linking.\n"
1077 "\n"
1078 "Discussion\n"
1079 "\n"
1080 " Say you have three targets: A -> B -> C. C's visibility may allow\n"
1081 " B to depend on it but not A. Normally, this would prevent A from\n"
1082 " including any headers from C, and C's public_configs would apply\n"
1083 " only to B.\n"
1084 "\n"
1085 " If B lists C in its public_deps instead of regular deps, A will now\n"
1086 " inherit C's public_configs and the ability to include C's public\n"
1087 " headers.\n"
1088 "\n"
1089 " Generally if you are writing a target B and you include C's headers\n"
1090 " as part of B's public headers, or targets depending on B should\n"
1091 " consider B and C to be part of a unit, you should use public_deps\n"
1092 " instead of deps.\n"
1093 "\n"
1094 "Example\n"
1095 "\n"
1096 " # This target can include files from \"c\" but not from\n"
1097 " # \"super_secret_implementation_details\".\n"
1098 " executable(\"a\") {\n"
1099 " deps = [ \":b\" ]\n"
1100 " }\n"
1101 "\n"
1102 " shared_library(\"b\") {\n"
1103 " deps = [ \":super_secret_implementation_details\" ]\n"
1104 " public_deps = [ \":c\" ]\n"
1105 " }\n";
1107 const char kScript[] = "script";
1108 const char kScript_HelpShort[] =
1109 "script: [file name] Script file for actions.";
1110 const char kScript_Help[] =
1111 "script: Script file for actions.\n"
1112 "\n"
1113 " An absolute or buildfile-relative file name of a Python script to run\n"
1114 " for a action and action_foreach targets (see \"gn help action\" and\n"
1115 " \"gn help action_foreach\").\n";
1117 const char kSources[] = "sources";
1118 const char kSources_HelpShort[] =
1119 "sources: [file list] Source files for a target.";
1120 const char kSources_Help[] =
1121 "sources: Source files for a target\n"
1122 "\n"
1123 " A list of files relative to the current buildfile.\n";
1125 const char kTestonly[] = "testonly";
1126 const char kTestonly_HelpShort[] =
1127 "testonly: [boolean] Declares a target must only be used for testing.";
1128 const char kTestonly_Help[] =
1129 "testonly: Declares a target must only be used for testing.\n"
1130 "\n"
1131 " Boolean. Defaults to false.\n"
1132 "\n"
1133 " When a target is marked \"testonly = true\", it must only be depended\n"
1134 " on by other test-only targets. Otherwise, GN will issue an error\n"
1135 " that the depenedency is not allowed.\n"
1136 "\n"
1137 " This feature is intended to prevent accidentally shipping test code\n"
1138 " in a final product.\n"
1139 "\n"
1140 "Example\n"
1141 "\n"
1142 " source_set(\"test_support\") {\n"
1143 " testonly = true\n"
1144 " ...\n"
1145 " }\n";
1147 const char kVisibility[] = "visibility";
1148 const char kVisibility_HelpShort[] =
1149 "visibility: [label list] A list of labels that can depend on a target.";
1150 const char kVisibility_Help[] =
1151 "visibility: A list of labels that can depend on a target.\n"
1152 "\n"
1153 " A list of labels and label patterns that define which targets can\n"
1154 " depend on the current one. These permissions are checked via the\n"
1155 " \"check\" command (see \"gn help check\").\n"
1156 "\n"
1157 " If visibility is not defined, it defaults to public (\"*\").\n"
1158 "\n"
1159 " If visibility is defined, only the targets with labels that match it\n"
1160 " can depend on the current target. The empty list means no targets\n"
1161 " can depend on the current target.\n"
1162 "\n"
1163 " Tip: Often you will want the same visibility for all targets in a\n"
1164 " BUILD file. In this case you can just put the definition at the top,\n"
1165 " outside of any target, and the targets will inherit that scope and see\n"
1166 " the definition.\n"
1167 "\n"
1168 "Patterns\n"
1169 "\n"
1170 " See \"gn help label_pattern\" for more details on what types of\n"
1171 " patterns are supported. If a toolchain is specified, only targets\n"
1172 " in that toolchain will be matched. If a toolchain is not specified on\n"
1173 " a pattern, targets in all toolchains will be matched.\n"
1174 "\n"
1175 "Examples\n"
1176 "\n"
1177 " Only targets in the current buildfile (\"private\"):\n"
1178 " visibility = [ \":*\" ]\n"
1179 "\n"
1180 " No targets (used for targets that should be leaf nodes):\n"
1181 " visibility = []\n"
1182 "\n"
1183 " Any target (\"public\", the default):\n"
1184 " visibility = [ \"*\" ]\n"
1185 "\n"
1186 " All targets in the current directory and any subdirectory:\n"
1187 " visibility = [ \"./*\" ]\n"
1188 "\n"
1189 " Any target in \"//bar/BUILD.gn\":\n"
1190 " visibility = [ \"//bar:*\" ]\n"
1191 "\n"
1192 " Any target in \"//bar/\" or any subdirectory thereof:\n"
1193 " visibility = [ \"//bar/*\" ]\n"
1194 "\n"
1195 " Just these specific targets:\n"
1196 " visibility = [ \":mything\", \"//foo:something_else\" ]\n"
1197 "\n"
1198 " Any target in the current directory and any subdirectory thereof, plus\n"
1199 " any targets in \"//bar/\" and any subdirectory thereof.\n"
1200 " visibility = [ \"./*\", \"//bar/*\" ]\n";
1202 // -----------------------------------------------------------------------------
1204 VariableInfo::VariableInfo()
1205 : help_short(""),
1206 help("") {
1209 VariableInfo::VariableInfo(const char* in_help_short, const char* in_help)
1210 : help_short(in_help_short),
1211 help(in_help) {
1214 #define INSERT_VARIABLE(var) \
1215 info_map[k##var] = VariableInfo(k##var##_HelpShort, k##var##_Help);
1217 const VariableInfoMap& GetBuiltinVariables() {
1218 static VariableInfoMap info_map;
1219 if (info_map.empty()) {
1220 INSERT_VARIABLE(CurrentCpu)
1221 INSERT_VARIABLE(CurrentOs)
1222 INSERT_VARIABLE(CurrentToolchain)
1223 INSERT_VARIABLE(DefaultToolchain)
1224 INSERT_VARIABLE(HostCpu)
1225 INSERT_VARIABLE(HostOs)
1226 INSERT_VARIABLE(PythonPath)
1227 INSERT_VARIABLE(RootBuildDir)
1228 INSERT_VARIABLE(RootGenDir)
1229 INSERT_VARIABLE(RootOutDir)
1230 INSERT_VARIABLE(TargetCpu)
1231 INSERT_VARIABLE(TargetOs)
1232 INSERT_VARIABLE(TargetGenDir)
1233 INSERT_VARIABLE(TargetOutDir)
1235 return info_map;
1238 const VariableInfoMap& GetTargetVariables() {
1239 static VariableInfoMap info_map;
1240 if (info_map.empty()) {
1241 INSERT_VARIABLE(AllDependentConfigs)
1242 INSERT_VARIABLE(AllowCircularIncludesFrom)
1243 INSERT_VARIABLE(Args)
1244 INSERT_VARIABLE(Cflags)
1245 INSERT_VARIABLE(CflagsC)
1246 INSERT_VARIABLE(CflagsCC)
1247 INSERT_VARIABLE(CflagsObjC)
1248 INSERT_VARIABLE(CflagsObjCC)
1249 INSERT_VARIABLE(CheckIncludes)
1250 INSERT_VARIABLE(CompleteStaticLib)
1251 INSERT_VARIABLE(Configs)
1252 INSERT_VARIABLE(Data)
1253 INSERT_VARIABLE(DataDeps)
1254 INSERT_VARIABLE(Defines)
1255 INSERT_VARIABLE(Depfile)
1256 INSERT_VARIABLE(Deps)
1257 INSERT_VARIABLE(ForwardDependentConfigsFrom)
1258 INSERT_VARIABLE(IncludeDirs)
1259 INSERT_VARIABLE(Inputs)
1260 INSERT_VARIABLE(Ldflags)
1261 INSERT_VARIABLE(Libs)
1262 INSERT_VARIABLE(LibDirs)
1263 INSERT_VARIABLE(OutputExtension)
1264 INSERT_VARIABLE(OutputName)
1265 INSERT_VARIABLE(Outputs)
1266 INSERT_VARIABLE(PrecompiledHeader)
1267 INSERT_VARIABLE(PrecompiledSource)
1268 INSERT_VARIABLE(Public)
1269 INSERT_VARIABLE(PublicConfigs)
1270 INSERT_VARIABLE(PublicDeps)
1271 INSERT_VARIABLE(Script)
1272 INSERT_VARIABLE(Sources)
1273 INSERT_VARIABLE(Testonly)
1274 INSERT_VARIABLE(Visibility)
1276 return info_map;
1279 #undef INSERT_VARIABLE
1281 } // namespace variables