• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "gn/variables.h"
6 
7 #include "gn/rust_variables.h"
8 #include "gn/swift_variables.h"
9 
10 namespace variables {
11 
12 // Built-in variables ----------------------------------------------------------
13 
14 const char kGnVersion[] = "gn_version";
15 const char kGnVersion_HelpShort[] = "gn_version: [number] The version of gn.";
16 const char kGnVersion_Help[] =
17     R"(gn_version: [number] The version of gn.
18 
19   Corresponds to the number printed by `gn --version`.
20 
21 Example
22 
23   assert(gn_version >= 1700, "need GN version 1700 for the frobulate feature")
24 )";
25 
26 const char kHostCpu[] = "host_cpu";
27 const char kHostCpu_HelpShort[] =
28     "host_cpu: [string] The processor architecture that GN is running on.";
29 const char kHostCpu_Help[] =
30     R"(host_cpu: The processor architecture that GN is running on.
31 
32   This is value is exposed so that cross-compile toolchains can access the host
33   architecture when needed.
34 
35   The value should generally be considered read-only, but it can be overridden
36   in order to handle unusual cases where there might be multiple plausible
37   values for the host architecture (e.g., if you can do either 32-bit or 64-bit
38   builds). The value is not used internally by GN for any purpose.
39 
40 Some possible values
41 
42   - "x64"
43   - "x86"
44 )";
45 
46 const char kHostOs[] = "host_os";
47 const char kHostOs_HelpShort[] =
48     "host_os: [string] The operating system that GN is running on.";
49 const char kHostOs_Help[] =
50     R"(host_os: [string] The operating system that GN is running on.
51 
52   This value is exposed so that cross-compiles can access the host build
53   system's settings.
54 
55   This value should generally be treated as read-only. It, however, is not used
56   internally by GN for any purpose.
57 
58 Some possible values
59 
60   - "linux"
61   - "mac"
62   - "win"
63 )";
64 
65 const char kInvoker[] = "invoker";
66 const char kInvoker_HelpShort[] =
67     "invoker: [string] The invoking scope inside a template.";
68 const char kInvoker_Help[] =
69     R"(invoker: [string] The invoking scope inside a template.
70 
71   Inside a template invocation, this variable refers to the scope of the
72   invoker of the template. Outside of template invocations, this variable is
73   undefined.
74 
75   All of the variables defined inside the template invocation are accessible as
76   members of the "invoker" scope. This is the way that templates read values
77   set by the callers.
78 
79   This is often used with "defined" to see if a value is set on the invoking
80   scope.
81 
82   See "gn help template" for more examples.
83 
84 Example
85 
86   template("my_template") {
87     print(invoker.sources)       # Prints [ "a.cc", "b.cc" ]
88     print(defined(invoker.foo))  # Prints false.
89     print(defined(invoker.bar))  # Prints true.
90   }
91 
92   my_template("doom_melon") {
93     sources = [ "a.cc", "b.cc" ]
94     bar = 123
95   }
96 )";
97 
98 const char kTargetCpu[] = "target_cpu";
99 const char kTargetCpu_HelpShort[] =
100     "target_cpu: [string] The desired cpu architecture for the build.";
101 const char kTargetCpu_Help[] =
102     R"(target_cpu: The desired cpu architecture for the build.
103 
104   This value should be used to indicate the desired architecture for the
105   primary objects of the build. It will match the cpu architecture of the
106   default toolchain, but not necessarily the current toolchain.
107 
108   In many cases, this is the same as "host_cpu", but in the case of
109   cross-compiles, this can be set to something different. This value is
110   different from "current_cpu" in that it does not change based on the current
111   toolchain. When writing rules, "current_cpu" should be used rather than
112   "target_cpu" most of the time.
113 
114   This value is not used internally by GN for any purpose, so it may be set to
115   whatever value is needed for the build. GN defaults this value to the empty
116   string ("") and the configuration files should set it to an appropriate value
117   (e.g., setting it to the value of "host_cpu") if it is not overridden on the
118   command line or in the args.gn file.
119 
120 Possible values
121 
122   - "x86"
123   - "x64"
124   - "arm"
125   - "arm64"
126   - "mipsel"
127   - "mips64el"
128   - "s390x"
129   - "ppc64"
130   - "riscv32"
131   - "riscv64"
132   - "e2k"
133   - "loong64"
134 )";
135 
136 const char kTargetName[] = "target_name";
137 const char kTargetName_HelpShort[] =
138     "target_name: [string] The name of the current target.";
139 const char kTargetName_Help[] =
140     R"(target_name: [string] The name of the current target.
141 
142   Inside a target or template invocation, this variable refers to the name
143   given to the target or template invocation. Outside of these, this variable
144   is undefined.
145 
146   This is most often used in template definitions to name targets defined in
147   the template based on the name of the invocation. This is necessary both to
148   ensure generated targets have unique names and to generate a target with the
149   exact name of the invocation that other targets can depend on.
150 
151   Be aware that this value will always reflect the innermost scope. So when
152   defining a target inside a template, target_name will refer to the target
153   rather than the template invocation. To get the name of the template
154   invocation in this case, you should save target_name to a temporary variable
155   outside of any target definitions.
156 
157   See "gn help template" for more examples.
158 
159 Example
160 
161   executable("doom_melon") {
162     print(target_name)    # Prints "doom_melon".
163   }
164 
165   template("my_template") {
166     print(target_name)    # Prints "space_ray" when invoked below.
167 
168     executable(target_name + "_impl") {
169       print(target_name)  # Prints "space_ray_impl".
170     }
171   }
172 
173   my_template("space_ray") {
174   }
175 )";
176 
177 const char kTargetOs[] = "target_os";
178 const char kTargetOs_HelpShort[] =
179     "target_os: [string] The desired operating system for the build.";
180 const char kTargetOs_Help[] =
181     R"(target_os: The desired operating system for the build.
182 
183   This value should be used to indicate the desired operating system for the
184   primary object(s) of the build. It will match the OS of the default
185   toolchain.
186 
187   In many cases, this is the same as "host_os", but in the case of
188   cross-compiles, it may be different. This variable differs from "current_os"
189   in that it can be referenced from inside any toolchain and will always return
190   the initial value.
191 
192   This should be set to the most specific value possible. So, "android" or
193   "chromeos" should be used instead of "linux" where applicable, even though
194   Android and ChromeOS are both Linux variants. This can mean that one needs to
195   write
196 
197       if (target_os == "android" || target_os == "linux") {
198           # ...
199       }
200 
201   and so forth.
202 
203   This value is not used internally by GN for any purpose, so it may be set to
204   whatever value is needed for the build. GN defaults this value to the empty
205   string ("") and the configuration files should set it to an appropriate value
206   (e.g., setting it to the value of "host_os") if it is not set via the command
207   line or in the args.gn file.
208 
209 Possible values
210 
211   - "android"
212   - "chromeos"
213   - "ios"
214   - "linux"
215   - "nacl"
216   - "mac"
217   - "win"
218 )";
219 
220 const char kCurrentCpu[] = "current_cpu";
221 const char kCurrentCpu_HelpShort[] =
222     "current_cpu: [string] The processor architecture of the current "
223     "toolchain.";
224 const char kCurrentCpu_Help[] =
225     R"(current_cpu: The processor architecture of the current toolchain.
226 
227   The build configuration usually sets this value based on the value of
228   "host_cpu" (see "gn help host_cpu") and then threads this through the
229   toolchain definitions to ensure that it always reflects the appropriate
230   value.
231 
232   This value is not used internally by GN for any purpose. It is set to the
233   empty string ("") by default but is declared so that it can be overridden on
234   the command line if so desired.
235 
236   See "gn help target_cpu" for a list of common values returned.)";
237 
238 const char kCurrentOs[] = "current_os";
239 const char kCurrentOs_HelpShort[] =
240     "current_os: [string] The operating system of the current toolchain.";
241 const char kCurrentOs_Help[] =
242     R"(current_os: The operating system of the current toolchain.
243 
244   The build configuration usually sets this value based on the value of
245   "target_os" (see "gn help target_os"), and then threads this through the
246   toolchain definitions to ensure that it always reflects the appropriate
247   value.
248 
249   This value is not used internally by GN for any purpose. It is set to the
250   empty string ("") by default but is declared so that it can be overridden on
251   the command line if so desired.
252 
253   See "gn help target_os" for a list of common values returned.
254 )";
255 
256 const char kCurrentToolchain[] = "current_toolchain";
257 const char kCurrentToolchain_HelpShort[] =
258     "current_toolchain: [string] Label of the current toolchain.";
259 const char kCurrentToolchain_Help[] =
260     R"(current_toolchain: Label of the current toolchain.
261 
262   A fully-qualified label representing the current toolchain. You can use this
263   to make toolchain-related decisions in the build. See also
264   "default_toolchain".
265 
266 Example
267 
268   if (current_toolchain == "//build:64_bit_toolchain") {
269     executable("output_thats_64_bit_only") {
270       ...
271 )";
272 
273 const char kDefaultToolchain[] = "default_toolchain";
274 const char kDefaultToolchain_HelpShort[] =
275     "default_toolchain: [string] Label of the default toolchain.";
276 const char kDefaultToolchain_Help[] =
277     R"(default_toolchain: [string] Label of the default toolchain.
278 
279   A fully-qualified label representing the default toolchain, which may not
280   necessarily be the current one (see "current_toolchain").
281 )";
282 
283 const char kPythonPath[] = "python_path";
284 const char kPythonPath_HelpShort[] =
285     "python_path: [string] Absolute path of Python.";
286 const char kPythonPath_Help[] =
287     R"(python_path: Absolute path of Python.
288 
289   Normally used in toolchain definitions if running some command requires
290   Python. You will normally not need this when invoking scripts since GN
291   automatically finds it for you.
292 )";
293 
294 const char kRootBuildDir[] = "root_build_dir";
295 const char kRootBuildDir_HelpShort[] =
296     "root_build_dir: [string] Directory where build commands are run.";
297 const char kRootBuildDir_Help[] =
298     R"(root_build_dir: [string] Directory where build commands are run.
299 
300   This is the root build output directory which will be the current directory
301   when executing all compilers and scripts.
302 
303   Most often this is used with rebase_path (see "gn help rebase_path") to
304   convert arguments to be relative to a script's current directory.
305 )";
306 
307 const char kRootGenDir[] = "root_gen_dir";
308 const char kRootGenDir_HelpShort[] =
309     "root_gen_dir: [string] Directory for the toolchain's generated files.";
310 const char kRootGenDir_Help[] =
311     R"(root_gen_dir: Directory for the toolchain's generated files.
312 
313   Absolute path to the root of the generated output directory tree for the
314   current toolchain. An example would be "//out/Debug/gen" for the default
315   toolchain, or "//out/Debug/arm/gen" for the "arm" toolchain.
316 
317   This is primarily useful for setting up include paths for generated files. If
318   you are passing this to a script, you will want to pass it through
319   rebase_path() (see "gn help rebase_path") to convert it to be relative to the
320   build directory.
321 
322   See also "target_gen_dir" which is usually a better location for generated
323   files. It will be inside the root generated dir.
324 )";
325 
326 const char kRootOutDir[] = "root_out_dir";
327 const char kRootOutDir_HelpShort[] =
328     "root_out_dir: [string] Root directory for toolchain output files.";
329 const char kRootOutDir_Help[] =
330     R"(root_out_dir: [string] Root directory for toolchain output files.
331 
332   Absolute path to the root of the output directory tree for the current
333   toolchain. It will not have a trailing slash.
334 
335   For the default toolchain this will be the same as the root_build_dir. An
336   example would be "//out/Debug" for the default toolchain, or
337   "//out/Debug/arm" for the "arm" toolchain.
338 
339   This is primarily useful for setting up script calls. If you are passing this
340   to a script, you will want to pass it through rebase_path() (see "gn help
341   rebase_path") to convert it to be relative to the build directory.
342 
343   See also "target_out_dir" which is usually a better location for output
344   files. It will be inside the root output dir.
345 
346 Example
347 
348   action("myscript") {
349     # Pass the output dir to the script.
350     args = [ "-o", rebase_path(root_out_dir, root_build_dir) ]
351   }
352 )";
353 
354 const char kTargetGenDir[] = "target_gen_dir";
355 const char kTargetGenDir_HelpShort[] =
356     "target_gen_dir: [string] Directory for a target's generated files.";
357 const char kTargetGenDir_Help[] =
358     R"(target_gen_dir: Directory for a target's generated files.
359 
360   Absolute path to the target's generated file directory. This will be the
361   "root_gen_dir" followed by the relative path to the current build file. If
362   your file is in "//tools/doom_melon" then target_gen_dir would be
363   "//out/Debug/gen/tools/doom_melon". It will not have a trailing slash.
364 
365   This is primarily useful for setting up include paths for generated files. If
366   you are passing this to a script, you will want to pass it through
367   rebase_path() (see "gn help rebase_path") to convert it to be relative to the
368   build directory.
369 
370   See also "gn help root_gen_dir".
371 
372 Example
373 
374   action("myscript") {
375     # Pass the generated output dir to the script.
376     args = [ "-o", rebase_path(target_gen_dir, root_build_dir) ]
377   }
378 )";
379 
380 const char kTargetOutDir[] = "target_out_dir";
381 const char kTargetOutDir_HelpShort[] =
382     "target_out_dir: [string] Directory for target output files.";
383 const char kTargetOutDir_Help[] =
384     R"(target_out_dir: [string] Directory for target output files.
385 
386   Absolute path to the target's generated file directory. If your current
387   target is in "//tools/doom_melon" then this value might be
388   "//out/Debug/obj/tools/doom_melon". It will not have a trailing slash.
389 
390   This is primarily useful for setting up arguments for calling scripts. If you
391   are passing this to a script, you will want to pass it through rebase_path()
392   (see "gn help rebase_path") to convert it to be relative to the build
393   directory.
394 
395   See also "gn help root_out_dir".
396 
397 Example
398 
399   action("myscript") {
400     # Pass the output dir to the script.
401     args = [ "-o", rebase_path(target_out_dir, root_build_dir) ]
402   }
403 )";
404 
405 // Target variables ------------------------------------------------------------
406 
407 #define COMMON_ORDERING_HELP                                                 \
408   "\n"                                                                       \
409   "Ordering of flags and values\n"                                           \
410   "\n"                                                                       \
411   "  1. Those set on the current target (not in a config).\n"                \
412   "  2. Those set on the \"configs\" on the target in order that the\n"      \
413   "     configs appear in the list.\n"                                       \
414   "  3. Those set on the \"all_dependent_configs\" on the target in order\n" \
415   "     that the configs appear in the list.\n"                              \
416   "  4. Those set on the \"public_configs\" on the target in order that\n"   \
417   "     those configs appear in the list.\n"                                 \
418   "  5. all_dependent_configs pulled from dependencies, in the order of\n"   \
419   "     the \"deps\" list. This is done recursively. If a config appears\n"  \
420   "     more than once, only the first occurrence will be used.\n"           \
421   "  6. public_configs pulled from dependencies, in the order of the\n"      \
422   "     \"deps\" list. If a dependency is public, they will be applied\n"    \
423   "     recursively.\n"
424 
425 const char kAllDependentConfigs[] = "all_dependent_configs";
426 const char kAllDependentConfigs_HelpShort[] =
427     "all_dependent_configs: [label list] Configs to be forced on dependents.";
428 const char kAllDependentConfigs_Help[] =
429     R"(all_dependent_configs: Configs to be forced on dependents.
430 
431   A list of config labels.
432 
433   All targets depending on this one, and recursively, all targets depending on
434   those, will have the configs listed in this variable added to them. These
435   configs will also apply to the current target.
436 
437   This addition happens in a second phase once a target and all of its
438   dependencies have been resolved. Therefore, a target will not see these
439   force-added configs in their "configs" variable while the script is running,
440   and they can not be removed. As a result, this capability should generally
441   only be used to add defines and include directories necessary to compile a
442   target's headers.
443 
444   See also "public_configs".
445 )" COMMON_ORDERING_HELP;
446 
447 const char kAllowCircularIncludesFrom[] = "allow_circular_includes_from";
448 const char kAllowCircularIncludesFrom_HelpShort[] =
449     "allow_circular_includes_from: [label list] Permit includes from deps.";
450 const char kAllowCircularIncludesFrom_Help[] =
451     R"(allow_circular_includes_from: Permit includes from deps.
452 
453   A list of target labels. Must be a subset of the target's "deps". These
454   targets will be permitted to include headers from the current target despite
455   the dependency going in the opposite direction.
456 
457   When you use this, both targets must be included in a final binary for it to
458   link. To keep linker errors from happening, it is good practice to have all
459   external dependencies depend only on one of the two targets, and to set the
460   visibility on the other to enforce this. Thus the targets will always be
461   linked together in any output.
462 
463 Details
464 
465   Normally, for a file in target A to include a file from target B, A must list
466   B as a dependency. This invariant is enforced by the "gn check" command (and
467   the --check flag to "gn gen" -- see "gn help check").
468 
469   Sometimes, two targets might be the same unit for linking purposes (two
470   source sets or static libraries that would always be linked together in a
471   final executable or shared library) and they each include headers from the
472   other: you want A to be able to include B's headers, and B to include A's
473   headers. This is not an ideal situation but is sometimes unavoidable.
474 
475   This list, if specified, lists which of the dependencies of the current
476   target can include header files from the current target. That is, if A
477   depends on B, B can only include headers from A if it is in A's
478   allow_circular_includes_from list. Normally includes must follow the
479   direction of dependencies, this flag allows them to go in the opposite
480   direction.
481 
482 Danger
483 
484   In the above example, A's headers are likely to include headers from A's
485   dependencies. Those dependencies may have public_configs that apply flags,
486   defines, and include paths that make those headers work properly.
487 
488   With allow_circular_includes_from, B can include A's headers, and
489   transitively from A's dependencies, without having the dependencies that
490   would bring in the public_configs those headers need. The result may be
491   errors or inconsistent builds.
492 
493   So when you use allow_circular_includes_from, make sure that any compiler
494   settings, flags, and include directories are the same between both targets
495   (consider putting such things in a shared config they can both reference).
496   Make sure the dependencies are also the same (you might consider a group to
497   collect such dependencies they both depend on).
498 
499 Example
500 
501   source_set("a") {
502     deps = [ ":b", ":a_b_shared_deps" ]
503     allow_circular_includes_from = [ ":b" ]
504     ...
505   }
506 
507   source_set("b") {
508     deps = [ ":a_b_shared_deps" ]
509     # Sources here can include headers from a despite lack of deps.
510     ...
511   }
512 
513   group("a_b_shared_deps") {
514     public_deps = [ ":c" ]
515   }
516 )";
517 
518 const char kGenDeps[] = "gen_deps";
519 const char kGenDeps_HelpShort[] =
520     "gen_deps: [label list] "
521     "Declares targets that should generate when this one does.";
522 const char kGenDeps_Help[] =
523     R"(gen_deps: Declares targets that should generate when this one does.
524 
525   A list of target labels.
526 
527   Not all GN targets that get evaluated are actually turned into ninja targets
528   (see "gn help execution"). If this target is generated, then any targets in
529   the "gen_deps" list will also be generated, regardless of the usual critera.
530 
531   Since "gen_deps" are not build time dependencies, there can be cycles between
532   "deps" and "gen_deps" or within "gen_deps" itself.
533 )";
534 
535 const char kArflags[] = "arflags";
536 const char kArflags_HelpShort[] =
537     "arflags: [string list] Arguments passed to static_library archiver.";
538 const char kArflags_Help[] =
539     R"(arflags: Arguments passed to static_library archiver.
540 
541   A list of flags passed to the archive/lib command that creates static
542   libraries.
543 
544   arflags are NOT pushed to dependents, so applying arflags to source sets or
545   any other target type will be a no-op. As with ldflags, you could put the
546   arflags in a config and set that as a public or "all dependent" config, but
547   that will likely not be what you want. If you have a chain of static
548   libraries dependent on each other, this can cause the flags to propagate up
549   to other static libraries. Due to the nature of how arflags are typically
550   used, you will normally want to apply them directly on static_library targets
551   themselves.
552 )" COMMON_ORDERING_HELP;
553 
554 const char kArgs[] = "args";
555 const char kArgs_HelpShort[] =
556     "args: [string list] Arguments passed to an action.";
557 const char kArgs_Help[] =
558     R"(args: (target variable) Arguments passed to an action.
559 
560   For action and action_foreach targets, args is the list of arguments to pass
561   to the script. Typically you would use source expansion (see "gn help
562   source_expansion") to insert the source file names.
563 
564   Args can also expand the substitution patterns corresponding to config
565   variables in the same way that compiler tools (see "gn help tool") do. These
566   allow actions that run compiler or compiler-like tools to access the results
567   of propagating configs through the build graph. For example:
568 
569   args = [ "{{defines}}", "{{include_dirs}}", "{{rustenv}}", "--input-file",
570            "{{source}}" ]
571 
572   See also "gn help action" and "gn help action_foreach".
573 )";
574 
575 const char kAssertNoDeps[] = "assert_no_deps";
576 const char kAssertNoDeps_HelpShort[] =
577     "assert_no_deps: [label pattern list] Ensure no deps on these targets.";
578 const char kAssertNoDeps_Help[] =
579     R"(assert_no_deps: Ensure no deps on these targets.
580 
581   A list of label patterns.
582 
583   This list is a list of patterns that must not match any of the transitive
584   dependencies of the target. These include all public, private, and data
585   dependencies, and cross shared library boundaries. This allows you to express
586   that undesirable code isn't accidentally added to downstream dependencies in
587   a way that might otherwise be difficult to notice.
588 
589   Checking does not cross executable boundaries. If a target depends on an
590   executable, it's assumed that the executable is a tool that is producing part
591   of the build rather than something that is linked and distributed. This
592   allows assert_no_deps to express what is distributed in the final target
593   rather than depend on the internal build steps (which may include
594   non-distributable code).
595 
596   See "gn help label_pattern" for the format of the entries in the list. These
597   patterns allow blacklisting individual targets or whole directory
598   hierarchies.
599 
600   Sometimes it is desirable to enforce that many targets have no dependencies
601   on a target or set of targets. One efficient way to express this is to create
602   a group with the assert_no_deps rule on it, and make that group depend on all
603   targets you want to apply that assertion to.
604 
605 Example
606 
607   executable("doom_melon") {
608     deps = [ "//foo:bar" ]
609     ...
610     assert_no_deps = [
611       "//evil/*",  # Don't link any code from the evil directory.
612       "//foo:test_support",  # This target is also disallowed.
613     ]
614   }
615 )";
616 
617 const char kBundleRootDir[] = "bundle_root_dir";
618 const char kBundleRootDir_HelpShort[] =
619     "bundle_root_dir: Expansion of {{bundle_root_dir}} in create_bundle.";
620 const char kBundleRootDir_Help[] =
621     R"(bundle_root_dir: Expansion of {{bundle_root_dir}} in create_bundle.
622 
623   A string corresponding to a path in root_build_dir.
624 
625   This string is used by the "create_bundle" target to expand the
626   {{bundle_root_dir}} of the "bundle_data" target it depends on. This must
627   correspond to a path under root_build_dir.
628 
629 Example
630 
631   bundle_data("info_plist") {
632     sources = [ "Info.plist" ]
633     outputs = [ "{{bundle_contents_dir}}/Info.plist" ]
634   }
635 
636   create_bundle("doom_melon.app") {
637     deps = [ ":info_plist" ]
638     bundle_root_dir = "${root_build_dir}/doom_melon.app"
639     bundle_contents_dir = "${bundle_root_dir}/Contents"
640     bundle_resources_dir = "${bundle_contents_dir}/Resources"
641     bundle_executable_dir = "${bundle_contents_dir}/MacOS"
642   }
643 )";
644 
645 const char kBundleContentsDir[] = "bundle_contents_dir";
646 const char kBundleContentsDir_HelpShort[] =
647     "bundle_contents_dir: "
648     "Expansion of {{bundle_contents_dir}} in create_bundle.";
649 const char kBundleContentsDir_Help[] =
650     R"(bundle_contents_dir: Expansion of {{bundle_contents_dir}} in
651                              create_bundle.
652 
653   A string corresponding to a path in $root_build_dir.
654 
655   This string is used by the "create_bundle" target to expand the
656   {{bundle_contents_dir}} of the "bundle_data" target it depends on. This must
657   correspond to a path under "bundle_root_dir".
658 
659   See "gn help bundle_root_dir" for examples.
660 )";
661 
662 const char kBundleResourcesDir[] = "bundle_resources_dir";
663 const char kBundleResourcesDir_HelpShort[] =
664     "bundle_resources_dir: "
665     "Expansion of {{bundle_resources_dir}} in create_bundle.";
666 const char kBundleResourcesDir_Help[] =
667     R"(bundle_resources_dir
668 
669   bundle_resources_dir: Expansion of {{bundle_resources_dir}} in
670                         create_bundle.
671 
672   A string corresponding to a path in $root_build_dir.
673 
674   This string is used by the "create_bundle" target to expand the
675   {{bundle_resources_dir}} of the "bundle_data" target it depends on. This must
676   correspond to a path under "bundle_root_dir".
677 
678   See "gn help bundle_root_dir" for examples.
679 )";
680 
681 const char kBundleDepsFilter[] = "bundle_deps_filter";
682 const char kBundleDepsFilter_HelpShort[] =
683     "bundle_deps_filter: [label list] A list of labels that are filtered out.";
684 const char kBundleDepsFilter_Help[] =
685     R"(bundle_deps_filter: [label list] A list of labels that are filtered out.
686 
687   A list of target labels.
688 
689   This list contains target label patterns that should be filtered out when
690   creating the bundle. Any target matching one of those label will be removed
691   from the dependencies of the create_bundle target.
692 
693   This is mostly useful when creating application extension bundle as the
694   application extension has access to runtime resources from the application
695   bundle and thus do not require a second copy.
696 
697   See "gn help create_bundle" for more information.
698 
699 Example
700 
701   create_bundle("today_extension") {
702     deps = [
703       "//base"
704     ]
705     bundle_root_dir = "$root_out_dir/today_extension.appex"
706     bundle_deps_filter = [
707       # The extension uses //base but does not use any function calling into
708       # third_party/icu and thus does not need the icudtl.dat file.
709       "//third_party/icu:icudata",
710     ]
711   }
712 )";
713 
714 const char kBundleExecutableDir[] = "bundle_executable_dir";
715 const char kBundleExecutableDir_HelpShort[] =
716     "bundle_executable_dir: "
717     "Expansion of {{bundle_executable_dir}} in create_bundle";
718 const char kBundleExecutableDir_Help[] =
719     R"(bundle_executable_dir
720 
721   bundle_executable_dir: Expansion of {{bundle_executable_dir}} in
722                          create_bundle.
723 
724   A string corresponding to a path in $root_build_dir.
725 
726   This string is used by the "create_bundle" target to expand the
727   {{bundle_executable_dir}} of the "bundle_data" target it depends on. This
728   must correspond to a path under "bundle_root_dir".
729 
730   See "gn help bundle_root_dir" for examples.
731 )";
732 
733 const char kXcassetCompilerFlags[] = "xcasset_compiler_flags";
734 const char kXcassetCompilerFlags_HelpShort[] =
735     "xcasset_compiler_flags: [string list] Flags passed to xcassets compiler";
736 const char kXcassetCompilerFlags_Help[] =
737     R"(xcasset_compiler_flags: Flags passed to xcassets compiler.
738 
739   A list of strings.
740 
741   Valid for create_bundle target. Those flags are directly passed to
742   xcassets compiler, corresponding to {{xcasset_compiler_flags}} substitution
743   in compile_xcassets tool.
744 )";
745 
746 const char kCflags[] = "cflags";
747 const char kCflags_HelpShort[] =
748     "cflags: [string list] Flags passed to all C compiler variants.";
749 const char kCommonCflagsHelp[] =
750     R"(cflags*: Flags passed to the C compiler.
751 
752   A list of strings.
753 
754   "cflags" are passed to all invocations of the C, C++, Objective C, and
755   Objective C++ compilers.
756 
757   To target one of these variants individually, use "cflags_c", "cflags_cc",
758   "cflags_objc", and "cflags_objcc", respectively. These variant-specific
759   versions of cflags* will be appended on the compiler command line after
760   "cflags".
761 
762   See also "asmflags" for flags for assembly-language files and "swiftflags"
763   for swift files.
764 )" COMMON_ORDERING_HELP;
765 const char* kCflags_Help = kCommonCflagsHelp;
766 
767 const char kAsmflags[] = "asmflags";
768 const char kAsmflags_HelpShort[] =
769     "asmflags: [string list] Flags passed to the assembler.";
770 const char* kAsmflags_Help =
771     R"(asmflags: Flags passed to the assembler.
772 
773   A list of strings.
774 
775   "asmflags" are passed to any invocation of a tool that takes an .asm or .S
776   file as input.
777 )" COMMON_ORDERING_HELP;
778 
779 const char kCflagsC[] = "cflags_c";
780 const char kCflagsC_HelpShort[] =
781     "cflags_c: [string list] Flags passed to the C compiler.";
782 const char* kCflagsC_Help = kCommonCflagsHelp;
783 
784 const char kCflagsCC[] = "cflags_cc";
785 const char kCflagsCC_HelpShort[] =
786     "cflags_cc: [string list] Flags passed to the C++ compiler.";
787 const char* kCflagsCC_Help = kCommonCflagsHelp;
788 
789 const char kCflagsObjC[] = "cflags_objc";
790 const char kCflagsObjC_HelpShort[] =
791     "cflags_objc: [string list] Flags passed to the Objective C compiler.";
792 const char* kCflagsObjC_Help = kCommonCflagsHelp;
793 
794 const char kCflagsObjCC[] = "cflags_objcc";
795 const char kCflagsObjCC_HelpShort[] =
796     "cflags_objcc: [string list] Flags passed to the Objective C++ compiler.";
797 const char* kCflagsObjCC_Help = kCommonCflagsHelp;
798 
799 const char kCheckIncludes[] = "check_includes";
800 const char kCheckIncludes_HelpShort[] =
801     "check_includes: [boolean] Controls whether a target's files are checked.";
802 const char kCheckIncludes_Help[] =
803     R"(check_includes: [boolean] Controls whether a target's files are checked.
804 
805   When true (the default), the "gn check" command (as well as "gn gen" with the
806   --check flag) will check this target's sources and headers for proper
807   dependencies.
808 
809   When false, the files in this target will be skipped by default. This does
810   not affect other targets that depend on the current target, it just skips
811   checking the includes of the current target's files.
812 
813   If there are a few conditionally included headers that trip up checking, you
814   can exclude headers individually by annotating them with "nogncheck" (see "gn
815   help nogncheck").
816 
817   The topic "gn help check" has general information on how checking works and
818   advice on how to pass a check in problematic cases.
819 
820 Example
821 
822   source_set("busted_includes") {
823     # This target's includes are messed up, exclude it from checking.
824     check_includes = false
825     ...
826   }
827 )";
828 
829 const char kCodeSigningArgs[] = "code_signing_args";
830 const char kCodeSigningArgs_HelpShort[] =
831     "code_signing_args: [string list] Arguments passed to code signing script.";
832 const char kCodeSigningArgs_Help[] =
833     R"(code_signing_args: [string list] Arguments passed to code signing script.
834 
835   For create_bundle targets, code_signing_args is the list of arguments to pass
836   to the code signing script. Typically you would use source expansion (see "gn
837   help source_expansion") to insert the source file names.
838 
839   See also "gn help create_bundle".
840 )";
841 
842 const char kCodeSigningScript[] = "code_signing_script";
843 const char kCodeSigningScript_HelpShort[] =
844     "code_signing_script: [file name] Script for code signing.";
845 const char kCodeSigningScript_Help[] =
846     R"(code_signing_script: [file name] Script for code signing."
847 
848   An absolute or buildfile-relative file name of a Python script to run for a
849   create_bundle target to perform code signing step.
850 
851   See also "gn help create_bundle".
852 )";
853 
854 const char kCodeSigningSources[] = "code_signing_sources";
855 const char kCodeSigningSources_HelpShort[] =
856     "code_signing_sources: [file list] Sources for code signing step.";
857 const char kCodeSigningSources_Help[] =
858     R"(code_signing_sources: [file list] Sources for code signing step.
859 
860   A list of files used as input for code signing script step of a create_bundle
861   target. Non-absolute paths will be resolved relative to the current build
862   file.
863 
864   See also "gn help create_bundle".
865 )";
866 
867 const char kCodeSigningOutputs[] = "code_signing_outputs";
868 const char kCodeSigningOutputs_HelpShort[] =
869     "code_signing_outputs: [file list] Output files for code signing step.";
870 const char kCodeSigningOutputs_Help[] =
871     R"(code_signing_outputs: [file list] Output files for code signing step.
872 
873   Outputs from the code signing step of a create_bundle target. Must refer to
874   files in the build directory.
875 
876   See also "gn help create_bundle".
877 )";
878 
879 const char kCompleteStaticLib[] = "complete_static_lib";
880 const char kCompleteStaticLib_HelpShort[] =
881     "complete_static_lib: [boolean] Links all deps into a static library.";
882 const char kCompleteStaticLib_Help[] =
883     R"(complete_static_lib: [boolean] Links all deps into a static library.
884 
885   A static library normally doesn't include code from dependencies, but instead
886   forwards the static libraries and source sets in its deps up the dependency
887   chain until a linkable target (an executable or shared library) is reached.
888   The final linkable target only links each static library once, even if it
889   appears more than once in its dependency graph.
890 
891   In some cases the static library might be the final desired output. For
892   example, you may be producing a static library for distribution to third
893   parties. In this case, the static library should include code for all
894   dependencies in one complete package. However, complete static libraries
895   themselves are never linked into other complete static libraries. All
896   complete static libraries are for distribution and linking them in would
897   cause code duplication in this case. If the static library is not for
898   distribution, it should not be complete.
899 
900   GN treats non-complete static libraries as source sets when they are linked
901   into complete static libraries. This is done because some tools like AR do
902   not handle dependent static libraries properly. This makes it easier to write
903   "alink" rules.
904 
905   In rare cases it makes sense to list a header in more than one target if it
906   could be considered conceptually a member of both. libraries.
907 
908 Example
909 
910   static_library("foo") {
911     complete_static_lib = true
912     deps = [ "bar" ]
913   }
914 )";
915 
916 const char kConfigs[] = "configs";
917 const char kConfigs_HelpShort[] =
918     "configs: [label list] Configs applying to this target or config.";
919 const char kConfigs_Help[] =
920     R"(configs: Configs applying to this target or config.
921 
922   A list of config labels.
923 
924 Configs on a target
925 
926   When used on a target, the include_dirs, defines, etc. in each config are
927   appended in the order they appear to the compile command for each file in the
928   target. They will appear after the include_dirs, defines, etc. that the
929   target sets directly.
930 
931   Since configs apply after the values set on a target, directly setting a
932   compiler flag will prepend it to the command line. If you want to append a
933   flag instead, you can put that flag in a one-off config and append that
934   config to the target's configs list.
935 
936   The build configuration script will generally set up the default configs
937   applying to a given target type (see "set_defaults"). When a target is being
938   defined, it can add to or remove from this list.
939 
940 Configs on a config
941 
942   It is possible to create composite configs by specifying configs on a config.
943   One might do this to forward values, or to factor out blocks of settings from
944   very large configs into more manageable named chunks.
945 
946   In this case, the composite config is expanded to be the concatenation of its
947   own values, and in order, the values from its sub-configs *before* anything
948   else happens. This has some ramifications:
949 
950    - A target has no visibility into a config's sub-configs. Target code only
951      sees the name of the composite config. It can't remove sub-configs or opt
952      in to only parts of it. The composite config may not even be defined
953      before the target is.
954 
955    - You can get duplication of values if a config is listed twice, say, on a
956      target and in a sub-config that also applies. In other cases, the configs
957      applying to a target are de-duped. It's expected that if a config is
958      listed as a sub-config that it is only used in that context. (Note that
959      it's possible to fix this and de-dupe, but it's not normally relevant and
960      complicates the implementation.)
961 )" COMMON_ORDERING_HELP
962     R"(
963 Example
964 
965   # Configs on a target.
966   source_set("foo") {
967     # Don't use the default RTTI config that BUILDCONFIG applied to us.
968     configs -= [ "//build:no_rtti" ]
969 
970     # Add some of our own settings.
971     configs += [ ":mysettings" ]
972   }
973 
974   # Create a default_optimization config that forwards to one of a set of more
975   # specialized configs depending on build flags. This pattern is useful
976   # because it allows a target to opt in to either a default set, or a more
977   # specific set, while avoid duplicating the settings in two places.
978   config("super_optimization") {
979     cflags = [ ... ]
980   }
981   config("default_optimization") {
982     if (optimize_everything) {
983       configs = [ ":super_optimization" ]
984     } else {
985       configs = [ ":no_optimization" ]
986     }
987   }
988 )";
989 
990 const char kData[] = "data";
991 const char kData_HelpShort[] =
992     "data: [file list] Runtime data file dependencies.";
993 const char kData_Help[] =
994     R"(data: Runtime data file dependencies.
995 
996   Lists files or directories required to run the given target. These are
997   typically data files or directories of data files. The paths are interpreted
998   as being relative to the current build file. Since these are runtime
999   dependencies, they do not affect which targets are built or when. To declare
1000   input files to a script, use "inputs".
1001 
1002   Appearing in the "data" section does not imply any special handling such as
1003   copying them to the output directory. This is just used for declaring runtime
1004   dependencies. Runtime dependencies can be queried using the "runtime_deps"
1005   category of "gn desc" or written during build generation via
1006   "--runtime-deps-list-file".
1007 
1008   GN doesn't require data files to exist at build-time. So actions that produce
1009   files that are in turn runtime dependencies can list those generated files
1010   both in the "outputs" list as well as the "data" list.
1011 
1012   By convention, directories are listed with a trailing slash:
1013     data = [ "test/data/" ]
1014   However, no verification is done on these so GN doesn't enforce this. The
1015   paths are just rebased and passed along when requested.
1016 
1017   Note: On iOS and macOS, create_bundle targets will not be recursed into when
1018   gathering data. See "gn help create_bundle" for details.
1019 
1020   See "gn help runtime_deps" for how these are used.
1021 )";
1022 
1023 const char kDataDeps[] = "data_deps";
1024 const char kDataDeps_HelpShort[] =
1025     "data_deps: [label list] Non-linked dependencies.";
1026 const char kDataDeps_Help[] =
1027     R"(data_deps: Non-linked dependencies.
1028 
1029   A list of target labels.
1030 
1031   Specifies dependencies of a target that are not actually linked into the
1032   current target. Such dependencies will be built and will be available at
1033   runtime.
1034 
1035   This is normally used for things like plugins or helper programs that a
1036   target needs at runtime.
1037 
1038   Note: On iOS and macOS, create_bundle targets will not be recursed into when
1039   gathering data_deps. See "gn help create_bundle" for details.
1040 
1041   See also "gn help deps" and "gn help data".
1042 
1043 Example
1044 
1045   executable("foo") {
1046     deps = [ "//base" ]
1047     data_deps = [ "//plugins:my_runtime_plugin" ]
1048   }
1049 )";
1050 
1051 const char kDataKeys[] = "data_keys";
1052 const char kDataKeys_HelpShort[] =
1053     "data_keys: [string list] Keys from which to collect metadata.";
1054 const char kDataKeys_Help[] =
1055     R"(data_keys: Keys from which to collect metadata.
1056 
1057   These keys are used to identify metadata to collect. If a walked target
1058   defines this key in its metadata, its value will be appended to the resulting
1059   collection.
1060 
1061   See "gn help generated_file".
1062 )";
1063 
1064 const char kDefines[] = "defines";
1065 const char kDefines_HelpShort[] =
1066     "defines: [string list] C preprocessor defines.";
1067 const char kDefines_Help[] =
1068     R"(defines: C preprocessor defines.
1069 
1070   A list of strings
1071 
1072   These strings will be passed to the C/C++ compiler as #defines. The strings
1073   may or may not include an "=" to assign a value.
1074 )" COMMON_ORDERING_HELP
1075     R"(
1076 Example
1077 
1078   defines = [ "AWESOME_FEATURE", "LOG_LEVEL=3" ]
1079 )";
1080 
1081 const char kDepfile[] = "depfile";
1082 const char kDepfile_HelpShort[] =
1083     "depfile: [string] File name for input dependencies for actions.";
1084 const char kDepfile_Help[] =
1085     R"(depfile: [string] File name for input dependencies for actions.
1086 
1087   If nonempty, this string specifies that the current action or action_foreach
1088   target will generate the given ".d" file containing the dependencies of the
1089   input. Empty or unset means that the script doesn't generate the files.
1090 
1091   A depfile should be used only when a target depends on files that are not
1092   already specified by a target's inputs and sources. Likewise, depfiles should
1093   specify only those dependencies not already included in sources or inputs.
1094 
1095   The .d file should go in the target output directory. If you have more than
1096   one source file that the script is being run over, you can use the output
1097   file expansions described in "gn help action_foreach" to name the .d file
1098   according to the input.
1099 
1100   The format is that of a Makefile and all paths must be relative to the root
1101   build directory. Only one output may be listed and it must match the first
1102   output of the action.
1103 
1104   Although depfiles are created by an action, they should not be listed in the
1105   action's "outputs" unless another target will use the file as an input.
1106 
1107 Example
1108 
1109   action_foreach("myscript_target") {
1110     script = "myscript.py"
1111     sources = [ ... ]
1112 
1113     # Locate the depfile in the output directory named like the
1114     # inputs but with a ".d" appended.
1115     depfile = "$relative_target_output_dir/{{source_name}}.d"
1116 
1117     # Say our script uses "-o <d file>" to indicate the depfile.
1118     args = [ "{{source}}", "-o", depfile ]
1119   }
1120 )";
1121 
1122 const char kDeps[] = "deps";
1123 const char kDeps_HelpShort[] =
1124     "deps: [label list] Private linked dependencies.";
1125 const char kDeps_Help[] =
1126     R"(deps: Private linked dependencies.
1127 
1128   A list of target labels.
1129 
1130   Specifies private dependencies of a target. Private dependencies are
1131   propagated up the dependency tree and linked to dependent targets, but do not
1132   grant the ability to include headers from the dependency. Public configs are
1133   not forwarded.
1134 
1135 Details of dependency propagation
1136 
1137   Source sets, shared libraries, and non-complete static libraries will be
1138   propagated up the dependency tree across groups, non-complete static
1139   libraries and source sets.
1140 
1141   Executables, shared libraries, and complete static libraries will link all
1142   propagated targets and stop propagation. Actions and copy steps also stop
1143   propagation, allowing them to take a library as an input but not force
1144   dependents to link to it.
1145 
1146   Propagation of all_dependent_configs and public_configs happens independently
1147   of target type. all_dependent_configs are always propagated across all types
1148   of targets, and public_configs are always propagated across public deps of
1149   all types of targets.
1150 
1151   Data dependencies are propagated differently. See "gn help data_deps" and
1152   "gn help runtime_deps".
1153 
1154   See also "public_deps".
1155 )";
1156 
1157 const char kExterns[] = "externs";
1158 const char kExterns_HelpShort[] =
1159     "externs: [scope] Set of Rust crate-dependency pairs.";
1160 const char kExterns_Help[] =
1161     R"(externs: [scope] Set of Rust crate-dependency pairs.
1162 
1163   A list, each value being a scope indicating a pair of crate name and the path
1164   to the Rust library.
1165 
1166   These libraries will be passed as `--extern crate_name=path` to compiler
1167   invocation containing the current target.
1168 
1169 Examples
1170 
1171     executable("foo") {
1172       sources = [ "main.rs" ]
1173       externs = [{
1174         crate_name = "bar",
1175         path = "path/to/bar.rlib"
1176       }]
1177     }
1178 
1179   This target would compile the `foo` crate with the following `extern` flag:
1180   `--extern bar=path/to/bar.rlib`.
1181 )";
1182 
1183 const char kFriend[] = "friend";
1184 const char kFriend_HelpShort[] =
1185     "friend: [label pattern list] Allow targets to include private headers.";
1186 const char kFriend_Help[] =
1187     R"(friend: Allow targets to include private headers.
1188 
1189   A list of label patterns (see "gn help label_pattern") that allow dependent
1190   targets to include private headers. Applies to all binary targets.
1191 
1192   Normally if a target lists headers in the "public" list (see "gn help
1193   public"), other headers are implicitly marked as private. Private headers
1194   can not be included by other targets, even with a public dependency path.
1195   The "gn check" function performs this validation.
1196 
1197   A friend declaration allows one or more targets to include private headers.
1198   This is useful for things like unit tests that are closely associated with a
1199   target and require internal knowledge without opening up all headers to be
1200   included by all dependents.
1201 
1202   A friend target does not allow that target to include headers when no
1203   dependency exists. A public dependency path must still exist between two
1204   targets to include any headers from a destination target. The friend
1205   annotation merely allows the use of headers that would otherwise be
1206   prohibited because they are private.
1207 
1208   The friend annotation is matched only against the target containing the file
1209   with the include directive. Friend annotations are not propagated across
1210   public or private dependencies. Friend annotations do not affect visibility.
1211 
1212 Example
1213 
1214   static_library("lib") {
1215     # This target can include our private headers.
1216     friend = [ ":unit_tests" ]
1217 
1218     public = [
1219       "public_api.h",  # Normal public API for dependent targets.
1220     ]
1221 
1222     # Private API and sources.
1223     sources = [
1224       "a_source_file.cc",
1225 
1226       # Normal targets that depend on this one won't be able to include this
1227       # because this target defines a list of "public" headers. Without the
1228       # "public" list, all headers are implicitly public.
1229       "private_api.h",
1230     ]
1231   }
1232 
1233   executable("unit_tests") {
1234     sources = [
1235       # This can include "private_api.h" from the :lib target because it
1236       # depends on that target and because of the friend annotation.
1237       "my_test.cc",
1238     ]
1239 
1240     deps = [
1241       ":lib",  # Required for the include to be allowed.
1242     ]
1243   }
1244 )";
1245 
1246 const char kFrameworkDirs[] = "framework_dirs";
1247 const char kFrameworkDirs_HelpShort[] =
1248     "framework_dirs: [directory list] Additional framework search directories.";
1249 const char kFrameworkDirs_Help[] =
1250     R"(framework_dirs: [directory list] Additional framework search directories.
1251 
1252   A list of source directories.
1253 
1254   The directories in this list will be added to the framework search path for
1255   the files in the affected target.
1256 )" COMMON_ORDERING_HELP
1257     R"(
1258 Example
1259 
1260   framework_dirs = [ "src/include", "//third_party/foo" ]
1261 )";
1262 
1263 const char kFrameworks[] = "frameworks";
1264 const char kFrameworks_HelpShort[] =
1265     "frameworks: [name list] Name of frameworks that must be linked.";
1266 const char kFrameworks_Help[] =
1267     R"(frameworks: [name list] Name of frameworks that must be linked.
1268 
1269   A list of framework names.
1270 
1271   The frameworks named in that list will be linked with any dynamic link
1272   type target.
1273 )" COMMON_ORDERING_HELP
1274     R"(
1275 Example
1276 
1277   frameworks = [ "Foundation.framework", "Foo.framework" ]
1278 )";
1279 
1280 const char kIncludeDirs[] = "include_dirs";
1281 const char kIncludeDirs_HelpShort[] =
1282     "include_dirs: [directory list] Additional include directories.";
1283 const char kIncludeDirs_Help[] =
1284     R"(include_dirs: Additional include directories.
1285 
1286   A list of source directories.
1287 
1288   The directories in this list will be added to the include path for the files
1289   in the affected target.
1290 )" COMMON_ORDERING_HELP
1291     R"(
1292 Example
1293 
1294   include_dirs = [ "src/include", "//third_party/foo" ]
1295 )";
1296 
1297 const char kInputs[] = "inputs";
1298 const char kInputs_HelpShort[] =
1299     "inputs: [file list] Additional compile-time dependencies.";
1300 const char kInputs_Help[] =
1301     R"(inputs: Additional compile-time dependencies.
1302 
1303   Inputs are compile-time dependencies of the current target. This means that
1304   all inputs must be available before compiling any of the sources or executing
1305   any actions.
1306 
1307   Inputs are typically only used for action and action_foreach targets.
1308 
1309 Inputs for actions
1310 
1311   For action and action_foreach targets, inputs should be the inputs to script
1312   that don't vary. These should be all .py files that the script uses via
1313   imports (the main script itself will be an implicit dependency of the action
1314   so need not be listed).
1315 
1316   For action targets, inputs and sources are treated the same, but from a style
1317   perspective, it's recommended to follow the same rule as action_foreach and
1318   put helper files in the inputs, and the data used by the script (if any) in
1319   sources.
1320 
1321   Note that another way to declare input dependencies from an action is to have
1322   the action write a depfile (see "gn help depfile"). This allows the script to
1323   dynamically write input dependencies, that might not be known until actually
1324   executing the script. This is more efficient than doing processing while
1325   running GN to determine the inputs, and is easier to keep in-sync than
1326   hardcoding the list.
1327 
1328 Script input gotchas
1329 
1330   It may be tempting to write a script that enumerates all files in a directory
1331   as inputs. Don't do this! Even if you specify all the files in the inputs or
1332   sources in the GN target (or worse, enumerate the files in an exec_script
1333   call when running GN, which will be slow), the dependencies will be broken.
1334 
1335   The problem happens if a file is ever removed because the inputs are not
1336   listed on the command line to the script. Because the script hasn't changed
1337   and all inputs are up to date, the script will not re-run and you will get a
1338   stale build. Instead, either list all inputs on the command line to the
1339   script, or if there are many, create a separate list file that the script
1340   reads. As long as this file is listed in the inputs, the build will detect
1341   when it has changed in any way and the action will re-run.
1342 
1343 Inputs for binary targets
1344 
1345   Any input dependencies will be resolved before compiling any sources or
1346   linking the target. Normally, all actions that a target depends on will be run
1347   before any files in a target are compiled. So if you depend on generated
1348   headers, you do not typically need to list them in the inputs section.
1349 
1350   Inputs for binary targets will be treated as implicit dependencies, meaning
1351   that changes in any of the inputs will force all sources in the target to be
1352   recompiled. If an input only applies to a subset of source files, you may
1353   want to split those into a separate target to avoid unnecessary recompiles.
1354 
1355 Example
1356 
1357   action("myscript") {
1358     script = "domything.py"
1359     inputs = [ "input.data" ]
1360   }
1361 )";
1362 
1363 const char kLdflags[] = "ldflags";
1364 const char kLdflags_HelpShort[] =
1365     "ldflags: [string list] Flags passed to the linker.";
1366 const char kLdflags_Help[] =
1367     R"(ldflags: Flags passed to the linker.
1368 
1369   A list of strings.
1370 
1371   These flags are passed on the command-line to the linker and generally
1372   specify various linking options. Most targets will not need these and will
1373   use "libs" and "lib_dirs" instead.
1374 
1375   ldflags are NOT pushed to dependents, so applying ldflags to source sets or
1376   static libraries will be a no-op. If you want to apply ldflags to dependent
1377   targets, put them in a config and set it in the all_dependent_configs or
1378   public_configs.
1379 )" COMMON_ORDERING_HELP;
1380 
1381 #define COMMON_LIB_INHERITANCE_HELP                                          \
1382   "\n"                                                                       \
1383   "  libs and lib_dirs work differently than other flags in two respects.\n" \
1384   "  First, they are inherited across static library boundaries until a\n"   \
1385   "  shared library or executable target is reached. Second, they are\n"     \
1386   "  uniquified so each one is only passed once (the first instance of it\n" \
1387   "  will be the one used).\n"
1388 
1389 #define LIBS_AND_LIB_DIRS_ORDERING_HELP                                  \
1390   "\n"                                                                   \
1391   "  For \"libs\" and \"lib_dirs\" only, the values propagated from\n"   \
1392   "  dependencies (as described above) are applied last assuming they\n" \
1393   "  are not already in the list.\n"
1394 
1395 const char kLibDirs[] = "lib_dirs";
1396 const char kLibDirs_HelpShort[] =
1397     "lib_dirs: [directory list] Additional library directories.";
1398 const char kLibDirs_Help[] =
1399     R"(lib_dirs: Additional library directories.
1400 
1401   A list of directories.
1402 
1403   Specifies additional directories passed to the linker for searching for the
1404   required libraries. If an item is not an absolute path, it will be treated as
1405   being relative to the current build file.
1406 )" COMMON_LIB_INHERITANCE_HELP COMMON_ORDERING_HELP
1407         LIBS_AND_LIB_DIRS_ORDERING_HELP
1408     R"(
1409 Example
1410 
1411   lib_dirs = [ "/usr/lib/foo", "lib/doom_melon" ]
1412 )";
1413 
1414 const char kLibs[] = "libs";
1415 const char kLibs_HelpShort[] =
1416     "libs: [string list] Additional libraries to link.";
1417 const char kLibs_Help[] =
1418     R"(libs: Additional libraries to link.
1419 
1420   A list of library names or library paths.
1421 
1422   These libraries will be linked into the final binary (executable or shared
1423   library) containing the current target.
1424 )" COMMON_LIB_INHERITANCE_HELP
1425     R"(
1426 Types of libs
1427 
1428   There are several different things that can be expressed in libs:
1429 
1430   File paths
1431       Values containing '/' will be treated as references to files in the
1432       checkout. They will be rebased to be relative to the build directory and
1433       specified in the "libs" for linker tools. This facility should be used
1434       for libraries that are checked in to the version control. For libraries
1435       that are generated by the build, use normal GN deps to link them.
1436 
1437   System libraries
1438       Values not containing '/' will be treated as system library names. These
1439       will be passed unmodified to the linker and prefixed with the
1440       "lib_switch" attribute of the linker tool. Generally you would set the
1441       "lib_dirs" so the given library is found. Your BUILD.gn file should not
1442       specify the switch (like "-l"): this will be encoded in the "lib_switch"
1443       of the tool.
1444 )" COMMON_ORDERING_HELP LIBS_AND_LIB_DIRS_ORDERING_HELP
1445     R"(
1446 Examples
1447 
1448   On Windows:
1449     libs = [ "ctl3d.lib" ]
1450 
1451   On Linux:
1452     libs = [ "ld" ]
1453 )";
1454 
1455 const char kMetadata[] = "metadata";
1456 const char kMetadata_HelpShort[] = "metadata: [scope] Metadata of this target.";
1457 const char kMetadata_Help[] =
1458     R"(metadata: Metadata of this target.
1459 
1460   Metadata is a collection of keys and values relating to a particular target.
1461   Values must be lists, allowing for sane and predictable collection behavior.
1462   Generally, these keys will include three types of lists: lists of ordinary
1463   strings, lists of filenames intended to be rebased according to their
1464   particular source directory, and lists of target labels intended to be used
1465   as barriers to the walk. Verification of these categories occurs at walk time,
1466   not creation time (since it is not clear until the walk which values are
1467   intended for which purpose).
1468 
1469 Example
1470 
1471   group("doom_melon") {
1472     metadata = {
1473       # These keys are not built in to GN but are interpreted when consuming
1474       # metadata.
1475       my_barrier = []
1476       my_files = [ "a.txt", "b.txt" ]
1477     }
1478   }
1479 )";
1480 
1481 const char kOutputExtension[] = "output_extension";
1482 const char kOutputExtension_HelpShort[] =
1483     "output_extension: [string] Value to use for the output's file extension.";
1484 const char kOutputExtension_Help[] =
1485     R"(output_extension: Value to use for the output's file extension.
1486 
1487   Normally the file extension for a target is based on the target type and the
1488   operating system, but in rare cases you will need to override the name (for
1489   example to use "libfreetype.so.6" instead of libfreetype.so on Linux).
1490 
1491   This value should not include a leading dot. If undefined, the default
1492   specified on the tool will be used. If set to the empty string, no output
1493   extension will be used.
1494 
1495   The output_extension will be used to set the "{{output_extension}}" expansion
1496   which the linker tool will generally use to specify the output file name. See
1497   "gn help tool".
1498 
1499 Example
1500 
1501   shared_library("freetype") {
1502     if (is_linux) {
1503       # Call the output "libfreetype.so.6"
1504       output_extension = "so.6"
1505     }
1506     ...
1507   }
1508 
1509   # On Windows, generate a "mysettings.cpl" control panel applet. Control panel
1510   # applets are actually special shared libraries.
1511   if (is_win) {
1512     shared_library("mysettings") {
1513       output_extension = "cpl"
1514       ...
1515     }
1516   }
1517 )";
1518 
1519 const char kOutputDir[] = "output_dir";
1520 const char kOutputDir_HelpShort[] =
1521     "output_dir: [directory] Directory to put output file in.";
1522 const char kOutputDir_Help[] =
1523     R"(output_dir: [directory] Directory to put output file in.
1524 
1525   For library and executable targets, overrides the directory for the final
1526   output. This must be in the root_build_dir or a child thereof.
1527 
1528   This should generally be in the root_out_dir or a subdirectory thereof (the
1529   root_out_dir will be the same as the root_build_dir for the default
1530   toolchain, and will be a subdirectory for other toolchains). Not putting the
1531   output in a subdirectory of root_out_dir can result in collisions between
1532   different toolchains, so you will need to take steps to ensure that your
1533   target is only present in one toolchain.
1534 
1535   Normally the toolchain specifies the output directory for libraries and
1536   executables (see "gn help tool"). You will have to consult that for the
1537   default location. The default location will be used if output_dir is
1538   undefined or empty.
1539 
1540 Example
1541 
1542   shared_library("doom_melon") {
1543     output_dir = "$root_out_dir/plugin_libs"
1544     ...
1545   }
1546 )";
1547 
1548 const char kOutputName[] = "output_name";
1549 const char kOutputName_HelpShort[] =
1550     "output_name: [string] Name for the output file other than the default.";
1551 const char kOutputName_Help[] =
1552     R"(output_name: Define a name for the output file other than the default.
1553 
1554   Normally the output name of a target will be based on the target name, so the
1555   target "//foo/bar:bar_unittests" will generate an output file such as
1556   "bar_unittests.exe" (using Windows as an example).
1557 
1558   Sometimes you will want an alternate name to avoid collisions or if the
1559   internal name isn't appropriate for public distribution.
1560 
1561   The output name should have no extension or prefixes, these will be added
1562   using the default system rules. For example, on Linux an output name of "foo"
1563   will produce a shared library "libfoo.so". There is no way to override the
1564   output prefix of a linker tool on a per- target basis. If you need more
1565   flexibility, create a copy target to produce the file you want.
1566 
1567   This variable is valid for all binary output target types.
1568 
1569 Example
1570 
1571   static_library("doom_melon") {
1572     output_name = "fluffy_bunny"
1573   }
1574 )";
1575 
1576 const char kOutputPrefixOverride[] = "output_prefix_override";
1577 const char kOutputPrefixOverride_HelpShort[] =
1578     "output_prefix_override: [boolean] Don't use prefix for output name.";
1579 const char kOutputPrefixOverride_Help[] =
1580     R"(output_prefix_override: Don't use prefix for output name.
1581 
1582   A boolean that overrides the output prefix for a target. Defaults to false.
1583 
1584   Some systems use prefixes for the names of the final target output file. The
1585   normal example is "libfoo.so" on Linux for a target named "foo".
1586 
1587   The output prefix for a given target type is specified on the linker tool
1588   (see "gn help tool"). Sometimes this prefix is undesired.
1589 
1590   See also "gn help output_extension".
1591 
1592 Example
1593 
1594   shared_library("doom_melon") {
1595     # Normally this will produce "libdoom_melon.so" on Linux. Setting this flag
1596     # will produce "doom_melon.so".
1597     output_prefix_override = true
1598     ...
1599   }
1600 )";
1601 
1602 const char kPartialInfoPlist[] = "partial_info_plist";
1603 const char kPartialInfoPlist_HelpShort[] =
1604     "partial_info_plist: [filename] Path plist from asset catalog compiler.";
1605 const char kPartialInfoPlist_Help[] =
1606     R"(partial_info_plist: [filename] Path plist from asset catalog compiler.
1607 
1608   Valid for create_bundle target, corresponds to the path for the partial
1609   Info.plist created by the asset catalog compiler that needs to be merged
1610   with the application Info.plist (usually done by the code signing script).
1611 
1612   The file will be generated regardless of whether the asset compiler has
1613   been invoked or not. See "gn help create_bundle".
1614 )";
1615 
1616 const char kOutputs[] = "outputs";
1617 const char kOutputs_HelpShort[] =
1618     "outputs: [file list] Output files for actions and copy targets.";
1619 const char kOutputs_Help[] =
1620     R"(outputs: Output files for actions and copy targets.
1621 
1622   Outputs is valid for "copy", "action", and "action_foreach" target types and
1623   indicates the resulting files. Outputs must always refer to files in the
1624   build directory.
1625 
1626   copy
1627     Copy targets should have exactly one entry in the outputs list. If there is
1628     exactly one source, this can be a literal file name or a source expansion.
1629     If there is more than one source, this must contain a source expansion to
1630     map a single input name to a single output name. See "gn help copy".
1631 
1632   action_foreach
1633     Action_foreach targets must always use source expansions to map input files
1634     to output files. There can be more than one output, which means that each
1635     invocation of the script will produce a set of files (presumably based on
1636     the name of the input file). See "gn help action_foreach".
1637 
1638   action
1639     Action targets (excluding action_foreach) must list literal output file(s)
1640     with no source expansions. See "gn help action".
1641 )";
1642 
1643 const char kPool[] = "pool";
1644 const char kPool_HelpShort[] =
1645     "pool: [string] Label of the pool used by the action.";
1646 const char kPool_Help[] =
1647     R"(pool: Label of the pool used by the action.
1648 
1649   A fully-qualified label representing the pool that will be used for the
1650   action. Pools are defined using the pool() {...} declaration.
1651 
1652 Example
1653 
1654   action("action") {
1655     pool = "//build:custom_pool"
1656     ...
1657   }
1658 )";
1659 
1660 const char kPrecompiledHeader[] = "precompiled_header";
1661 const char kPrecompiledHeader_HelpShort[] =
1662     "precompiled_header: [string] Header file to precompile.";
1663 const char kPrecompiledHeader_Help[] =
1664     R"(precompiled_header: [string] Header file to precompile.
1665 
1666   Precompiled headers will be used when a target specifies this value, or a
1667   config applying to this target specifies this value. In addition, the tool
1668   corresponding to the source files must also specify precompiled headers (see
1669   "gn help tool"). The tool will also specify what type of precompiled headers
1670   to use, by setting precompiled_header_type to either "gcc" or "msvc".
1671 
1672   The precompiled header/source variables can be specified on a target or a
1673   config, but must be the same for all configs applying to a given target since
1674   a target can only have one precompiled header.
1675 
1676   If you use both C and C++ sources, the precompiled header and source file
1677   will be compiled once per language. You will want to make sure to wrap C++
1678   includes in __cplusplus #ifdefs so the file will compile in C mode.
1679 
1680 GCC precompiled headers
1681 
1682   When using GCC-style precompiled headers, "precompiled_source" contains the
1683   path of a .h file that is precompiled and then included by all source files
1684   in targets that set "precompiled_source".
1685 
1686   The value of "precompiled_header" is not used with GCC-style precompiled
1687   headers.
1688 
1689 MSVC precompiled headers
1690 
1691   When using MSVC-style precompiled headers, the "precompiled_header" value is
1692   a string corresponding to the header. This is NOT a path to a file that GN
1693   recognises, but rather the exact string that appears in quotes after
1694   an #include line in source code. The compiler will match this string against
1695   includes or forced includes (/FI).
1696 
1697   MSVC also requires a source file to compile the header with. This must be
1698   specified by the "precompiled_source" value. In contrast to the header value,
1699   this IS a GN-style file name, and tells GN which source file to compile to
1700   make the .pch file used for subsequent compiles.
1701 
1702   For example, if the toolchain specifies MSVC headers:
1703 
1704     toolchain("vc_x64") {
1705       ...
1706       tool("cxx") {
1707         precompiled_header_type = "msvc"
1708         ...
1709 
1710   You might make a config like this:
1711 
1712     config("use_precompiled_headers") {
1713       precompiled_header = "build/precompile.h"
1714       precompiled_source = "//build/precompile.cc"
1715 
1716       # Either your source files should #include "build/precompile.h"
1717       # first, or you can do this to force-include the header.
1718       cflags = [ "/FI$precompiled_header" ]
1719     }
1720 
1721   And then define a target that uses the config:
1722 
1723     executable("doom_melon") {
1724       configs += [ ":use_precompiled_headers" ]
1725       ...
1726 )";
1727 
1728 const char kPrecompiledHeaderType[] = "precompiled_header_type";
1729 const char kPrecompiledHeaderType_HelpShort[] =
1730     "precompiled_header_type: [string] \"gcc\" or \"msvc\".";
1731 const char kPrecompiledHeaderType_Help[] =
1732     R"(precompiled_header_type: [string] "gcc" or "msvc".
1733 
1734   See "gn help precompiled_header".
1735 )";
1736 
1737 const char kPrecompiledSource[] = "precompiled_source";
1738 const char kPrecompiledSource_HelpShort[] =
1739     "precompiled_source: [file name] Source file to precompile.";
1740 const char kPrecompiledSource_Help[] =
1741     R"(precompiled_source: [file name] Source file to precompile.
1742 
1743   The source file that goes along with the precompiled_header when using
1744   "msvc"-style precompiled headers. It will be implicitly added to the sources
1745   of the target. See "gn help precompiled_header".
1746 )";
1747 
1748 const char kProductType[] = "product_type";
1749 const char kProductType_HelpShort[] =
1750     "product_type: [string] Product type for Xcode projects.";
1751 const char kProductType_Help[] =
1752     R"(product_type: Product type for Xcode projects.
1753 
1754   Correspond to the type of the product of a create_bundle target. Only
1755   meaningful to Xcode (used as part of the Xcode project generation).
1756 
1757   When generating Xcode project files, only create_bundle target with a
1758   non-empty product_type will have a corresponding target in Xcode project.
1759 )";
1760 
1761 const char kPublic[] = "public";
1762 const char kPublic_HelpShort[] =
1763     "public: [file list] Declare public header files for a target.";
1764 const char kPublic_Help[] =
1765     R"(public: Declare public header files for a target.
1766 
1767   A list of files that other targets can include. These permissions are checked
1768   via the "check" command (see "gn help check").
1769 
1770   If no public files are declared, other targets (assuming they have visibility
1771   to depend on this target) can include any file in the sources list. If this
1772   variable is defined on a target, dependent targets may only include files on
1773   this whitelist unless that target is marked as a friend (see "gn help
1774   friend").
1775 
1776   Header file permissions are also subject to visibility. A target must be
1777   visible to another target to include any files from it at all and the public
1778   headers indicate which subset of those files are permitted. See "gn help
1779   visibility" for more.
1780 
1781   Public files are inherited through the dependency tree. So if there is a
1782   dependency A -> B -> C, then A can include C's public headers. However, the
1783   same is NOT true of visibility, so unless A is in C's visibility list, the
1784   include will be rejected.
1785 
1786   GN only knows about files declared in the "sources" and "public" sections of
1787   targets. If a file is included that is not known to the build, it will be
1788   allowed.
1789 
1790   It is common for test targets to need to include private headers for their
1791   associated code. In this case, list the test target in the "friend" list of
1792   the target that owns the private header to allow the inclusion. See
1793   "gn help friend" for more.
1794 
1795   When a binary target has no explicit or implicit public headers (a "public"
1796   list is defined but is empty), GN assumes that the target can not propagate
1797   any compile-time dependencies up the dependency tree. In this case, the build
1798   can be parallelized more efficiently.
1799   Say there are dependencies:
1800     A (shared library) -> B (shared library) -> C (action).
1801   Normally C must complete before any source files in A can compile (because
1802   there might be generated includes). But when B explicitly declares no public
1803   headers, C can execute in parallel with A's compile steps. C must still be
1804   complete before any dependents link.
1805 
1806 Examples
1807 
1808   These exact files are public:
1809     public = [ "foo.h", "bar.h" ]
1810 
1811   No files are public (no targets may include headers from this one):
1812     # This allows starting compilation in dependent targets earlier.
1813     public = []
1814 )";
1815 
1816 const char kPublicConfigs[] = "public_configs";
1817 const char kPublicConfigs_HelpShort[] =
1818     "public_configs: [label list] Configs applied to dependents.";
1819 const char kPublicConfigs_Help[] =
1820     R"(public_configs: Configs to be applied on dependents.
1821 
1822   A list of config labels.
1823 
1824   Targets directly depending on this one will have the configs listed in this
1825   variable added to them. These configs will also apply to the current target.
1826   Generally, public configs are used to apply defines and include directories
1827   necessary to compile this target's header files.
1828 
1829   See also "gn help all_dependent_configs".
1830 
1831 Propagation of public configs
1832 
1833   Public configs are applied to all targets that depend directly on this one.
1834   These dependent targets can further push this target's public configs
1835   higher in the dependency tree by depending on it via public_deps (see "gn
1836   help public_deps").
1837 
1838     static_library("toplevel") {
1839       # This target will get "my_config" applied to it. However, since this
1840       # target uses "deps" and not "public_deps", targets that depend on this
1841       # one won't get it.
1842       deps = [ ":intermediate" ]
1843     }
1844 
1845     static_library("intermediate") {
1846       # Depending on "lower" in any way will apply "my_config" to this target.
1847       # Additionall, since this target depends on "lower" via public_deps,
1848       # targets that depend on this one will also get "my_config".
1849       public_deps = [ ":lower" ]
1850     }
1851 
1852     static_library("lower") {
1853       # This will get applied to all targets that depend on this one.
1854       public_configs = [ ":my_config" ]
1855     }
1856 
1857   Public config propagation happens in a second phase once a target and all of
1858   its dependencies have been resolved. Therefore, a target will not see these
1859   force-added configs in their "configs" variable while the script is running,
1860   and they can not be removed. As a result, this capability should generally
1861   only be used to add defines and include directories rather than setting
1862   complicated flags that some targets may not want.
1863 
1864   Public configs may or may not be propagated across toolchain boundaries
1865   depending on the value of the propagates_configs flag (see "gn help
1866   toolchain") on the toolchain of the target declaring the public_config.
1867 
1868 Avoiding applying public configs to this target
1869 
1870   If you want the config to apply to targets that depend on this one, but NOT
1871   this one, define an extra layer of indirection using a group:
1872 
1873     # External targets depend on this group.
1874     group("my_target") {
1875       # Config to apply to all targets that depend on this one.
1876       public_configs = [ ":external_settings" ]
1877       deps = [ ":internal_target" ]
1878     }
1879 
1880     # Internal target to actually compile the sources.
1881     static_library("internal_target") {
1882       # Force all external targets to depend on the group instead of directly
1883       # on this so the "external_settings" config will get applied.
1884       visibility = [ ":my_target" ]
1885       ...
1886     }
1887 
1888 )" COMMON_ORDERING_HELP;
1889 
1890 const char kPublicDeps[] = "public_deps";
1891 const char kPublicDeps_HelpShort[] =
1892     "public_deps: [label list] Declare public dependencies.";
1893 const char kPublicDeps_Help[] =
1894     R"(public_deps: Declare public dependencies.
1895 
1896   Public dependencies are like private dependencies (see "gn help deps") but
1897   additionally express that the current target exposes the listed deps as part
1898   of its public API.
1899 
1900   This has several ramifications:
1901 
1902     - public_configs that are part of the dependency are forwarded to direct
1903       dependents.
1904 
1905     - Public headers in the dependency are usable by dependents (includes do
1906       not require a direct dependency or visibility).
1907 
1908     - If the current target is a shared library, other shared libraries that it
1909       publicly depends on (directly or indirectly) are propagated up the
1910       dependency tree to dependents for linking.
1911 
1912   See also "gn help public_configs".
1913 
1914 Discussion
1915 
1916   Say you have three targets: A -> B -> C. C's visibility may allow B to depend
1917   on it but not A. Normally, this would prevent A from including any headers
1918   from C, and C's public_configs would apply only to B.
1919 
1920   If B lists C in its public_deps instead of regular deps, A will now inherit
1921   C's public_configs and the ability to include C's public headers.
1922 
1923   Generally if you are writing a target B and you include C's headers as part
1924   of B's public headers, or targets depending on B should consider B and C to
1925   be part of a unit, you should use public_deps instead of deps.
1926 
1927 Example
1928 
1929   # This target can include files from "c" but not from
1930   # "super_secret_implementation_details".
1931   executable("a") {
1932     deps = [ ":b" ]
1933   }
1934 
1935   shared_library("b") {
1936     deps = [ ":super_secret_implementation_details" ]
1937     public_deps = [ ":c" ]
1938   }
1939 )";
1940 
1941 const char kRebase[] = "rebase";
1942 const char kRebase_HelpShort[] =
1943     "rebase: [boolean] Rebase collected metadata as files.";
1944 const char kRebase_Help[] =
1945     R"(rebase: Rebase collected metadata as files.
1946 
1947   A boolean that triggers a rebase of collected metadata strings based on their
1948   declared file. Defaults to false.
1949 
1950   Metadata generally declares files as strings relative to the local build file.
1951   However, this data is often used in other contexts, and so setting this flag
1952   will force the metadata collection to be rebased according to the local build
1953   file's location and thus allow the filename to be used anywhere.
1954 
1955   Setting this flag will raise an error if any target's specified metadata is
1956   not a string value.
1957 
1958   See also "gn help generated_file".
1959 )";
1960 
1961 const char kResponseFileContents[] = "response_file_contents";
1962 const char kResponseFileContents_HelpShort[] =
1963     "response_file_contents: [string list] Contents of .rsp file for actions.";
1964 const char kResponseFileContents_Help[] =
1965     R"*(response_file_contents: Contents of a response file for actions.
1966 
1967   Sometimes the arguments passed to a script can be too long for the system's
1968   command-line capabilities. This is especially the case on Windows where the
1969   maximum command-line length is less than 8K. A response file allows you to
1970   pass an unlimited amount of data to a script in a temporary file for an
1971   action or action_foreach target.
1972 
1973   If the response_file_contents variable is defined and non-empty, the list
1974   will be treated as script args (including possibly substitution patterns)
1975   that will be written to a temporary file at build time. The name of the
1976   temporary file will be substituted for "{{response_file_name}}" in the script
1977   args.
1978 
1979   The response file contents will always be quoted and escaped according to
1980   Unix shell rules. To parse the response file, the Python script should use
1981   "shlex.split(file_contents)".
1982 
1983 Example
1984 
1985   action("process_lots_of_files") {
1986     script = "process.py",
1987     inputs = [ ... huge list of files ... ]
1988 
1989     # Write all the inputs to a response file for the script. Also,
1990     # make the paths relative to the script working directory.
1991     response_file_contents = rebase_path(inputs, root_build_dir)
1992 
1993     # The script expects the name of the response file in --file-list.
1994     args = [
1995       "--enable-foo",
1996       "--file-list={{response_file_name}}",
1997     ]
1998   }
1999 )*";
2000 
2001 const char kScript[] = "script";
2002 const char kScript_HelpShort[] = "script: [file name] Script file for actions.";
2003 const char kScript_Help[] =
2004     R"(script: Script file for actions.
2005 
2006   An absolute or buildfile-relative file name of a Python script to run for a
2007   action and action_foreach targets (see "gn help action" and "gn help
2008   action_foreach").
2009 )";
2010 
2011 const char kSources[] = "sources";
2012 const char kSources_HelpShort[] =
2013     "sources: [file list] Source files for a target.";
2014 const char kSources_Help[] =
2015     R"(sources: Source files for a target
2016 
2017   A list of files. Non-absolute paths will be resolved relative to the current
2018   build file.
2019 
2020 Sources for binary targets
2021 
2022   For binary targets (source sets, executables, and libraries), the known file
2023   types will be compiled with the associated tools. Unknown file types and
2024   headers will be skipped. However, you should still list all C/C+ header files
2025   so GN knows about the existence of those files for the purposes of include
2026   checking.
2027 
2028   As a special case, a file ending in ".def" will be treated as a Windows
2029   module definition file. It will be appended to the link line with a
2030   preceding "/DEF:" string. There must be at most one .def file in a target
2031   and they do not cross dependency boundaries (so specifying a .def file in a
2032   static library or source set will have no effect on the executable or shared
2033   library they're linked into).
2034 
2035   For Rust targets that do not specify a crate_root, then the crate_root will
2036   look for a lib.rs file (or main.rs for executable) or a single file in
2037   sources, if sources contains only one file.
2038 
2039 Sources for non-binary targets
2040 
2041   action_foreach
2042     The sources are the set of files that the script will be executed over. The
2043     script will run once per file.
2044 
2045   action
2046     The sources will be treated the same as inputs. See "gn help inputs" for
2047     more information and usage advice.
2048 
2049   copy
2050     The source are the source files to copy.
2051 )";
2052 
2053 const char kSwiftflags[] = "swiftflags";
2054 const char kSwiftflags_HelpShort[] =
2055     "swiftflags: [string list] Flags passed to the swift compiler.";
2056 const char* kSwiftflags_Help =
2057     R"(swiftflags: Flags passed to the swift compiler.
2058 
2059   A list of strings.
2060 
2061   "swiftflags" are passed to any invocation of a tool that takes an .swift
2062   file as input.
2063 )" COMMON_ORDERING_HELP;
2064 
2065 const char kXcodeTestApplicationName[] = "xcode_test_application_name";
2066 const char kXcodeTestApplicationName_HelpShort[] =
2067     "xcode_test_application_name: [string] Name for Xcode test target.";
2068 const char kXcodeTestApplicationName_Help[] =
2069     R"(xcode_test_application_name: Name for Xcode test target.
2070 
2071   Each unit and ui test target must have a test application target, and this
2072   value is used to specify the relationship. Only meaningful to Xcode (used as
2073   part of the Xcode project generation).
2074 
2075   See "gn help create_bundle" for more information.
2076 
2077 Example
2078 
2079   create_bundle("chrome_xctest") {
2080     test_application_name = "chrome"
2081     ...
2082   }
2083 )";
2084 
2085 const char kTestonly[] = "testonly";
2086 const char kTestonly_HelpShort[] =
2087     "testonly: [boolean] Declares a target must only be used for testing.";
2088 const char kTestonly_Help[] =
2089     R"(testonly: Declares a target must only be used for testing.
2090 
2091   Boolean. Defaults to false.
2092 
2093   When a target is marked "testonly = true", it must only be depended on by
2094   other test-only targets. Otherwise, GN will issue an error that the
2095   depenedency is not allowed.
2096 
2097   This feature is intended to prevent accidentally shipping test code in a
2098   final product.
2099 
2100 Example
2101 
2102   source_set("test_support") {
2103     testonly = true
2104     ...
2105   }
2106 )";
2107 
2108 const char kVisibility[] = "visibility";
2109 const char kVisibility_HelpShort[] =
2110     "visibility: [label list] A list of labels that can depend on a target.";
2111 const char kVisibility_Help[] =
2112     R"(visibility: A list of labels that can depend on a target.
2113 
2114   A list of labels and label patterns that define which targets can depend on
2115   the current one. These permissions are checked via the "check" command (see
2116   "gn help check").
2117 
2118   If visibility is not defined, it defaults to public ("*").
2119 
2120   If visibility is defined, only the targets with labels that match it can
2121   depend on the current target. The empty list means no targets can depend on
2122   the current target.
2123 
2124   Tip: Often you will want the same visibility for all targets in a BUILD file.
2125   In this case you can just put the definition at the top, outside of any
2126   target, and the targets will inherit that scope and see the definition.
2127 
2128 Patterns
2129 
2130   See "gn help label_pattern" for more details on what types of patterns are
2131   supported. If a toolchain is specified, only targets in that toolchain will
2132   be matched. If a toolchain is not specified on a pattern, targets in all
2133   toolchains will be matched.
2134 
2135 Examples
2136 
2137   Only targets in the current buildfile ("private"):
2138     visibility = [ ":*" ]
2139 
2140   No targets (used for targets that should be leaf nodes):
2141     visibility = []
2142 
2143   Any target ("public", the default):
2144     visibility = [ "*" ]
2145 
2146   All targets in the current directory and any subdirectory:
2147     visibility = [ "./*" ]
2148 
2149   Any target in "//bar/BUILD.gn":
2150     visibility = [ "//bar:*" ]
2151 
2152   Any target in "//bar/" or any subdirectory thereof:
2153     visibility = [ "//bar/*" ]
2154 
2155   Just these specific targets:
2156     visibility = [ ":mything", "//foo:something_else" ]
2157 
2158   Any target in the current directory and any subdirectory thereof, plus
2159   any targets in "//bar/" and any subdirectory thereof.
2160     visibility = [ "./*", "//bar/*" ]
2161 )";
2162 
2163 const char kWalkKeys[] = "walk_keys";
2164 const char kWalkKeys_HelpShort[] =
2165     "walk_keys: [string list] Key(s) for managing the metadata collection "
2166     "walk.";
2167 const char kWalkKeys_Help[] =
2168     R"(walk_keys: Key(s) for managing the metadata collection walk.
2169 
2170   Defaults to [""].
2171 
2172   These keys are used to control the next step in a collection walk, acting as
2173   barriers. If a specified key is defined in a target's metadata, the walk will
2174   use the targets listed in that value to determine which targets are walked.
2175 
2176   If no walk_keys are specified for a generated_file target (i.e. "[""]"), the
2177   walk will touch all deps and data_deps of the specified target recursively.
2178 
2179   See "gn help generated_file".
2180 )";
2181 
2182 const char kWeakFrameworks[] = "weak_frameworks";
2183 const char kWeakFrameworks_HelpShort[] =
2184     "weak_frameworks: [name list] Name of frameworks that must be weak linked.";
2185 const char kWeakFrameworks_Help[] =
2186     R"(weak_frameworks: [name list] Name of frameworks that must be weak linked.
2187 
2188   A list of framework names.
2189 
2190   The frameworks named in that list will be weak linked with any dynamic link
2191   type target. Weak linking instructs the dynamic loader to attempt to load
2192   the framework, but if it is not able to do so, it leaves any imported symbols
2193   unresolved. This is typically used when a framework is present in a new
2194   version of an SDK but not on older versions of the OS that the software runs
2195   on.
2196 )" COMMON_ORDERING_HELP
2197     R"(
2198 Example
2199 
2200   weak_frameworks = [ "OnlyOnNewerOSes.framework" ]
2201 )";
2202 
2203 const char kWriteValueContents[] = "contents";
2204 const char kWriteValueContents_HelpShort[] =
2205     "contents: Contents to write to file.";
2206 const char kWriteValueContents_Help[] =
2207     R"(contents: Contents to write to file.
2208 
2209   The contents of the file for a generated_file target.
2210   See "gn help generated_file".
2211 )";
2212 
2213 const char kWriteOutputConversion[] = "output_conversion";
2214 const char kWriteOutputConversion_HelpShort[] =
2215     "output_conversion: Data format for generated_file targets.";
2216 const char kWriteOutputConversion_Help[] =
2217     R"(output_conversion: Data format for generated_file targets.
2218 
2219   Controls how the "contents" of a generated_file target is formatted.
2220   See `gn help io_conversion`.
2221 )";
2222 
2223 const char kWriteRuntimeDeps[] = "write_runtime_deps";
2224 const char kWriteRuntimeDeps_HelpShort[] =
2225     "write_runtime_deps: Writes the target's runtime_deps to the given path.";
2226 const char kWriteRuntimeDeps_Help[] =
2227     R"(write_runtime_deps: Writes the target's runtime_deps to the given path.
2228 
2229   Does not synchronously write the file, but rather schedules it to be written
2230   at the end of generation.
2231 
2232   If the file exists and the contents are identical to that being written, the
2233   file will not be updated. This will prevent unnecessary rebuilds of targets
2234   that depend on this file.
2235 
2236   Path must be within the output directory.
2237 
2238   See "gn help runtime_deps" for how the runtime dependencies are computed.
2239 
2240   The format of this file will list one file per line with no escaping. The
2241   files will be relative to the root_build_dir. The first line of the file will
2242   be the main output file of the target itself. The file contents will be the
2243   same as requesting the runtime deps be written on the command line (see "gn
2244   help --runtime-deps-list-file").
2245 )";
2246 
2247 const char kXcodeExtraAttributes[] = "xcode_extra_attributes";
2248 const char kXcodeExtraAttributes_HelpShort[] =
2249     "xcode_extra_attributes: [scope] Extra attributes for Xcode projects.";
2250 const char kXcodeExtraAttributes_Help[] =
2251     R"(xcode_extra_attributes: [scope] Extra attributes for Xcode projects.
2252 
2253   The value defined in this scope will be copied to the EXTRA_ATTRIBUTES
2254   property of the generated Xcode project. They are only meaningful when
2255   generating with --ide=xcode.
2256 
2257   See "gn help create_bundle" for more information.
2258 )";
2259 
2260 // -----------------------------------------------------------------------------
2261 
VariableInfo()2262 VariableInfo::VariableInfo() : help_short(""), help("") {}
2263 
2264 VariableInfo::VariableInfo(const char* in_help_short, const char* in_help)
2265     : help_short(in_help_short), help(in_help) {}
2266 
2267 #define INSERT_VARIABLE(var) \
2268   info_map[k##var] = VariableInfo(k##var##_HelpShort, k##var##_Help);
2269 
2270 const VariableInfoMap& GetBuiltinVariables() {
2271   static VariableInfoMap info_map;
2272   if (info_map.empty()) {
2273     INSERT_VARIABLE(CurrentCpu)
2274     INSERT_VARIABLE(CurrentOs)
2275     INSERT_VARIABLE(CurrentToolchain)
2276     INSERT_VARIABLE(DefaultToolchain)
2277     INSERT_VARIABLE(GnVersion)
2278     INSERT_VARIABLE(HostCpu)
2279     INSERT_VARIABLE(HostOs)
2280     INSERT_VARIABLE(Invoker)
2281     INSERT_VARIABLE(PythonPath)
2282     INSERT_VARIABLE(RootBuildDir)
2283     INSERT_VARIABLE(RootGenDir)
2284     INSERT_VARIABLE(RootOutDir)
2285     INSERT_VARIABLE(TargetCpu)
2286     INSERT_VARIABLE(TargetGenDir)
2287     INSERT_VARIABLE(TargetName)
2288     INSERT_VARIABLE(TargetOs)
2289     INSERT_VARIABLE(TargetOutDir)
2290   }
2291   return info_map;
2292 }
2293 
2294 const VariableInfoMap& GetTargetVariables() {
2295   static VariableInfoMap info_map;
2296   if (info_map.empty()) {
2297     INSERT_VARIABLE(AllDependentConfigs)
2298     INSERT_VARIABLE(AllowCircularIncludesFrom)
2299     INSERT_VARIABLE(GenDeps)
2300     INSERT_VARIABLE(Arflags)
2301     INSERT_VARIABLE(Args)
2302     INSERT_VARIABLE(Asmflags)
2303     INSERT_VARIABLE(AssertNoDeps)
2304     INSERT_VARIABLE(BundleRootDir)
2305     INSERT_VARIABLE(BundleContentsDir)
2306     INSERT_VARIABLE(BundleResourcesDir)
2307     INSERT_VARIABLE(BundleDepsFilter)
2308     INSERT_VARIABLE(BundleExecutableDir)
2309     INSERT_VARIABLE(XcassetCompilerFlags)
2310     INSERT_VARIABLE(Cflags)
2311     INSERT_VARIABLE(CflagsC)
2312     INSERT_VARIABLE(CflagsCC)
2313     INSERT_VARIABLE(CflagsObjC)
2314     INSERT_VARIABLE(CflagsObjCC)
2315     INSERT_VARIABLE(CheckIncludes)
2316     INSERT_VARIABLE(CodeSigningArgs)
2317     INSERT_VARIABLE(CodeSigningScript)
2318     INSERT_VARIABLE(CodeSigningSources)
2319     INSERT_VARIABLE(CodeSigningOutputs)
2320     INSERT_VARIABLE(CompleteStaticLib)
2321     INSERT_VARIABLE(Configs)
2322     INSERT_VARIABLE(Data)
2323     INSERT_VARIABLE(DataDeps)
2324     INSERT_VARIABLE(DataKeys)
2325     INSERT_VARIABLE(Defines)
2326     INSERT_VARIABLE(Depfile)
2327     INSERT_VARIABLE(Deps)
2328     INSERT_VARIABLE(Externs)
2329     INSERT_VARIABLE(Friend)
2330     INSERT_VARIABLE(FrameworkDirs)
2331     INSERT_VARIABLE(Frameworks)
2332     INSERT_VARIABLE(IncludeDirs)
2333     INSERT_VARIABLE(Inputs)
2334     INSERT_VARIABLE(Ldflags)
2335     INSERT_VARIABLE(Libs)
2336     INSERT_VARIABLE(LibDirs)
2337     INSERT_VARIABLE(Metadata)
2338     INSERT_VARIABLE(OutputDir)
2339     INSERT_VARIABLE(OutputExtension)
2340     INSERT_VARIABLE(OutputName)
2341     INSERT_VARIABLE(OutputPrefixOverride)
2342     INSERT_VARIABLE(Outputs)
2343     INSERT_VARIABLE(PartialInfoPlist)
2344     INSERT_VARIABLE(Pool)
2345     INSERT_VARIABLE(PrecompiledHeader)
2346     INSERT_VARIABLE(PrecompiledHeaderType)
2347     INSERT_VARIABLE(PrecompiledSource)
2348     INSERT_VARIABLE(ProductType)
2349     INSERT_VARIABLE(Public)
2350     INSERT_VARIABLE(PublicConfigs)
2351     INSERT_VARIABLE(PublicDeps)
2352     INSERT_VARIABLE(Rebase)
2353     INSERT_VARIABLE(ResponseFileContents)
2354     INSERT_VARIABLE(Script)
2355     INSERT_VARIABLE(Sources)
2356     INSERT_VARIABLE(Swiftflags)
2357     INSERT_VARIABLE(XcodeTestApplicationName)
2358     INSERT_VARIABLE(Testonly)
2359     INSERT_VARIABLE(Visibility)
2360     INSERT_VARIABLE(WalkKeys)
2361     INSERT_VARIABLE(WeakFrameworks)
2362     INSERT_VARIABLE(WriteOutputConversion)
2363     INSERT_VARIABLE(WriteValueContents)
2364     INSERT_VARIABLE(WriteRuntimeDeps)
2365     INSERT_VARIABLE(XcodeExtraAttributes)
2366     InsertRustVariables(&info_map);
2367     InsertSwiftVariables(&info_map);
2368   }
2369   return info_map;
2370 }
2371 
2372 #undef INSERT_VARIABLE
2373 
2374 }  // namespace variables
2375