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 criteria.
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 kMnemonic[] = "mnemonic";
576 const char kMnemonic_HelpShort[] =
577     "mnemonic: [string] Prefix displayed when ninja runs this action.";
578 const char kMnemonic_Help[] =
579     R"(mnemonic: [string] Prefix displayed when ninja runs this action.
580 
581   Tools in GN can set their ninja "description" which is displayed when
582   building a target. These are commonly set with the format "CXX $output"
583   or "LINK $label". By default, all GN actions will have the description
584   "ACTION $label". Setting a mnemonic will override the "ACTION" prefix
585   with another string, but the label will still be unconditionally displayed.
586 
587   Whitespace is not allowed within a mnemonic.
588 )";
589 
590 const char kAssertNoDeps[] = "assert_no_deps";
591 const char kAssertNoDeps_HelpShort[] =
592     "assert_no_deps: [label pattern list] Ensure no deps on these targets.";
593 const char kAssertNoDeps_Help[] =
594     R"(assert_no_deps: Ensure no deps on these targets.
595 
596   A list of label patterns.
597 
598   This list is a list of patterns that must not match any of the transitive
599   dependencies of the target. These include all public, private, and data
600   dependencies, and cross shared library boundaries. This allows you to express
601   that undesirable code isn't accidentally added to downstream dependencies in
602   a way that might otherwise be difficult to notice.
603 
604   Checking does not cross executable boundaries. If a target depends on an
605   executable, it's assumed that the executable is a tool that is producing part
606   of the build rather than something that is linked and distributed. This
607   allows assert_no_deps to express what is distributed in the final target
608   rather than depend on the internal build steps (which may include
609   non-distributable code).
610 
611   See "gn help label_pattern" for the format of the entries in the list. These
612   patterns allow blacklisting individual targets or whole directory
613   hierarchies.
614 
615   Sometimes it is desirable to enforce that many targets have no dependencies
616   on a target or set of targets. One efficient way to express this is to create
617   a group with the assert_no_deps rule on it, and make that group depend on all
618   targets you want to apply that assertion to.
619 
620 Example
621 
622   executable("doom_melon") {
623     deps = [ "//foo:bar" ]
624     ...
625     assert_no_deps = [
626       "//evil/*",  # Don't link any code from the evil directory.
627       "//foo:test_support",  # This target is also disallowed.
628     ]
629   }
630 )";
631 
632 const char kBundleRootDir[] = "bundle_root_dir";
633 const char kBundleRootDir_HelpShort[] =
634     "bundle_root_dir: Expansion of {{bundle_root_dir}} in create_bundle.";
635 const char kBundleRootDir_Help[] =
636     R"(bundle_root_dir: Expansion of {{bundle_root_dir}} in create_bundle.
637 
638   A string corresponding to a path in root_build_dir.
639 
640   This string is used by the "create_bundle" target to expand the
641   {{bundle_root_dir}} of the "bundle_data" target it depends on. This must
642   correspond to a path under root_build_dir.
643 
644 Example
645 
646   bundle_data("info_plist") {
647     sources = [ "Info.plist" ]
648     outputs = [ "{{bundle_contents_dir}}/Info.plist" ]
649   }
650 
651   create_bundle("doom_melon.app") {
652     deps = [ ":info_plist" ]
653     bundle_root_dir = "${root_build_dir}/doom_melon.app"
654     bundle_contents_dir = "${bundle_root_dir}/Contents"
655     bundle_resources_dir = "${bundle_contents_dir}/Resources"
656     bundle_executable_dir = "${bundle_contents_dir}/MacOS"
657   }
658 )";
659 
660 const char kBundleContentsDir[] = "bundle_contents_dir";
661 const char kBundleContentsDir_HelpShort[] =
662     "bundle_contents_dir: "
663     "Expansion of {{bundle_contents_dir}} in create_bundle.";
664 const char kBundleContentsDir_Help[] =
665     R"(bundle_contents_dir: Expansion of {{bundle_contents_dir}} in
666                              create_bundle.
667 
668   A string corresponding to a path in $root_build_dir.
669 
670   This string is used by the "create_bundle" target to expand the
671   {{bundle_contents_dir}} of the "bundle_data" target it depends on. This must
672   correspond to a path under "bundle_root_dir".
673 
674   See "gn help bundle_root_dir" for examples.
675 )";
676 
677 const char kBundleResourcesDir[] = "bundle_resources_dir";
678 const char kBundleResourcesDir_HelpShort[] =
679     "bundle_resources_dir: "
680     "Expansion of {{bundle_resources_dir}} in create_bundle.";
681 const char kBundleResourcesDir_Help[] =
682     R"(bundle_resources_dir
683 
684   bundle_resources_dir: Expansion of {{bundle_resources_dir}} in
685                         create_bundle.
686 
687   A string corresponding to a path in $root_build_dir.
688 
689   This string is used by the "create_bundle" target to expand the
690   {{bundle_resources_dir}} of the "bundle_data" target it depends on. This must
691   correspond to a path under "bundle_root_dir".
692 
693   See "gn help bundle_root_dir" for examples.
694 )";
695 
696 const char kBundleDepsFilter[] = "bundle_deps_filter";
697 const char kBundleDepsFilter_HelpShort[] =
698     "bundle_deps_filter: [label list] A list of labels that are filtered out.";
699 const char kBundleDepsFilter_Help[] =
700     R"(bundle_deps_filter: [label list] A list of labels that are filtered out.
701 
702   A list of target labels.
703 
704   This list contains target label patterns that should be filtered out when
705   creating the bundle. Any target matching one of those label will be removed
706   from the dependencies of the create_bundle target.
707 
708   This is mostly useful when creating application extension bundle as the
709   application extension has access to runtime resources from the application
710   bundle and thus do not require a second copy.
711 
712   See "gn help create_bundle" for more information.
713 
714 Example
715 
716   create_bundle("today_extension") {
717     deps = [
718       "//base"
719     ]
720     bundle_root_dir = "$root_out_dir/today_extension.appex"
721     bundle_deps_filter = [
722       # The extension uses //base but does not use any function calling into
723       # third_party/icu and thus does not need the icudtl.dat file.
724       "//third_party/icu:icudata",
725     ]
726   }
727 )";
728 
729 const char kBundleExecutableDir[] = "bundle_executable_dir";
730 const char kBundleExecutableDir_HelpShort[] =
731     "bundle_executable_dir: "
732     "Expansion of {{bundle_executable_dir}} in create_bundle";
733 const char kBundleExecutableDir_Help[] =
734     R"(bundle_executable_dir
735 
736   bundle_executable_dir: Expansion of {{bundle_executable_dir}} in
737                          create_bundle.
738 
739   A string corresponding to a path in $root_build_dir.
740 
741   This string is used by the "create_bundle" target to expand the
742   {{bundle_executable_dir}} of the "bundle_data" target it depends on. This
743   must correspond to a path under "bundle_root_dir".
744 
745   See "gn help bundle_root_dir" for examples.
746 )";
747 
748 const char kXcassetCompilerFlags[] = "xcasset_compiler_flags";
749 const char kXcassetCompilerFlags_HelpShort[] =
750     "xcasset_compiler_flags: [string list] Flags passed to xcassets compiler";
751 const char kXcassetCompilerFlags_Help[] =
752     R"(xcasset_compiler_flags: Flags passed to xcassets compiler.
753 
754   A list of strings.
755 
756   Valid for create_bundle target. Those flags are directly passed to
757   xcassets compiler, corresponding to {{xcasset_compiler_flags}} substitution
758   in compile_xcassets tool.
759 )";
760 
761 const char kTransparent[] = "transparent";
762 const char kTransparent_HelpShort[] =
763     "transparent: [bool] True if the bundle is transparent.";
764 const char kTransparent_Help[] =
765     R"(transparent: [bool] True if the bundle is transparent.
766 
767   A boolean.
768 
769   Valid for "create_bundle" target. If true, the "create_bundle" target will
770   not package the "bundle_data" deps but will forward them to all targets that
771   depends on it (unless the "bundle_data" target sets "product_type" to the
772   same value as the "create_bundle" target).
773 )";
774 
775 const char kCflags[] = "cflags";
776 const char kCflags_HelpShort[] =
777     "cflags: [string list] Flags passed to all C compiler variants.";
778 const char kCommonCflagsHelp[] =
779     R"(cflags*: Flags passed to the C compiler.
780 
781   A list of strings.
782 
783   "cflags" are passed to all invocations of the C, C++, Objective C, and
784   Objective C++ compilers.
785 
786   To target one of these variants individually, use "cflags_c", "cflags_cc",
787   "cflags_objc", and "cflags_objcc", respectively. These variant-specific
788   versions of cflags* will be appended on the compiler command line after
789   "cflags".
790 
791   See also "asmflags" for flags for assembly-language files, "swiftflags" for
792   swift files, and "rustflags" for Rust files.
793 )" COMMON_ORDERING_HELP;
794 const char* kCflags_Help = kCommonCflagsHelp;
795 
796 const char kAsmflags[] = "asmflags";
797 const char kAsmflags_HelpShort[] =
798     "asmflags: [string list] Flags passed to the assembler.";
799 const char* kAsmflags_Help =
800     R"(asmflags: Flags passed to the assembler.
801 
802   A list of strings.
803 
804   "asmflags" are passed to any invocation of a tool that takes an .asm or .S
805   file as input.
806 )" COMMON_ORDERING_HELP;
807 
808 const char kCflagsC[] = "cflags_c";
809 const char kCflagsC_HelpShort[] =
810     "cflags_c: [string list] Flags passed to the C compiler.";
811 const char* kCflagsC_Help = kCommonCflagsHelp;
812 
813 const char kCflagsCC[] = "cflags_cc";
814 const char kCflagsCC_HelpShort[] =
815     "cflags_cc: [string list] Flags passed to the C++ compiler.";
816 const char* kCflagsCC_Help = kCommonCflagsHelp;
817 
818 const char kCflagsObjC[] = "cflags_objc";
819 const char kCflagsObjC_HelpShort[] =
820     "cflags_objc: [string list] Flags passed to the Objective C compiler.";
821 const char* kCflagsObjC_Help = kCommonCflagsHelp;
822 
823 const char kCflagsObjCC[] = "cflags_objcc";
824 const char kCflagsObjCC_HelpShort[] =
825     "cflags_objcc: [string list] Flags passed to the Objective C++ compiler.";
826 const char* kCflagsObjCC_Help = kCommonCflagsHelp;
827 
828 const char kCheckIncludes[] = "check_includes";
829 const char kCheckIncludes_HelpShort[] =
830     "check_includes: [boolean] Controls whether a target's files are checked.";
831 const char kCheckIncludes_Help[] =
832     R"(check_includes: [boolean] Controls whether a target's files are checked.
833 
834   When true (the default), the "gn check" command (as well as "gn gen" with the
835   --check flag) will check this target's sources and headers for proper
836   dependencies.
837 
838   When false, the files in this target will be skipped by default. This does
839   not affect other targets that depend on the current target, it just skips
840   checking the includes of the current target's files.
841 
842   If there are a few conditionally included headers that trip up checking, you
843   can exclude headers individually by annotating them with "nogncheck" (see "gn
844   help nogncheck").
845 
846   The topic "gn help check" has general information on how checking works and
847   advice on how to pass a check in problematic cases.
848 
849 Example
850 
851   source_set("busted_includes") {
852     # This target's includes are messed up, exclude it from checking.
853     check_includes = false
854     ...
855   }
856 )";
857 
858 const char kCodeSigningArgs[] = "code_signing_args";
859 const char kCodeSigningArgs_HelpShort[] =
860     "code_signing_args: [string list] [deprecated] Args for the "
861     "post-processing script.";
862 const char kCodeSigningArgs_Help[] =
863     R"(code_signing_args: [string list] [deprecated] Args for the post-processing script.
864 
865   For create_bundle targets, post_processing_args is the list of arguments to
866   pass to the post-processing script. Typically you would use source expansion
867   (see "gn help source_expansion") to insert the source file names.
868 
869   Deprecated: this is an old name for the "post_processing_args" property of
870   the "create_bundle" target. It is still supported to avoid breaking existing
871   build rules, but a warning will be emitted when it is used.
872 
873   See also "gn help create_bundle" and "gn help post_processing_args".
874 )";
875 
876 const char kCodeSigningOutputs[] = "code_signing_outputs";
877 const char kCodeSigningOutputs_HelpShort[] =
878     "code_signing_outputs: [file list] [deprecated] Outputs of the "
879     "post-processing step.";
880 const char kCodeSigningOutputs_Help[] =
881     R"(code_signing_outputs: [file list] [deprecated] Outputs of the post-processing step.
882 
883   Outputs from the post-processing step of a create_bundle target. Must refer to
884   files in the build directory.
885 
886   Deprecated: this is an old name for the "post_processing_outputs" property of
887   the "create_bundle" target. It is still supported to avoid breaking existing
888   build rules, but a warning will be emitted when it is used.
889 
890   See also "gn help create_bundle" and "gn help post_processing_args".
891 )";
892 
893 const char kCodeSigningScript[] = "code_signing_script";
894 const char kCodeSigningScript_HelpShort[] =
895     "code_signing_script: [file name] [deprecated] Script for the "
896     "post-processing step.";
897 const char kCodeSigningScript_Help[] =
898     R"(code_signing_script: [file name] [deprecated] Script for the post-processing step."
899 
900   An absolute or buildfile-relative file name of a Python script to run for a
901   create_bundle target to perform the post-processing step.
902 
903   Deprecated: this is an old name for the "post_processing_script" property of
904   the "create_bundle" target. It is still supported to avoid breaking existing
905   build rules, but a warning will be emitted when it is used.
906 
907   See also "gn help create_bundle" and "gn help post_processing_args".
908 )";
909 
910 const char kCodeSigningSources[] = "code_signing_sources";
911 const char kCodeSigningSources_HelpShort[] =
912     "code_signing_sources: [file list] [deprecated] Sources for the "
913     "post-processing "
914     "step.";
915 const char kCodeSigningSources_Help[] =
916     R"(code_signing_sources: [file list] [deprecated] Sources for the post-processing step.
917 
918   A list of files used as input for the post-processing step of a create_bundle
919   target. Non-absolute paths will be resolved relative to the current build
920   file.
921 
922   Deprecated: this is an old name for the "post_processing_sources" property of
923   the "create_bundle" target. It is still supported to avoid breaking existing
924   build rules, but a warning will be emitted when it is used.
925 
926   See also "gn help create_bundle" and "gn help post_processing_args".
927 )";
928 
929 const char kCompleteStaticLib[] = "complete_static_lib";
930 const char kCompleteStaticLib_HelpShort[] =
931     "complete_static_lib: [boolean] Links all deps into a static library.";
932 const char kCompleteStaticLib_Help[] =
933     R"(complete_static_lib: [boolean] Links all deps into a static library.
934 
935   A static library normally doesn't include code from dependencies, but instead
936   forwards the static libraries and source sets in its deps up the dependency
937   chain until a linkable target (an executable or shared library) is reached.
938   The final linkable target only links each static library once, even if it
939   appears more than once in its dependency graph.
940 
941   In some cases the static library might be the final desired output. For
942   example, you may be producing a static library for distribution to third
943   parties. In this case, the static library should include code for all
944   dependencies in one complete package. However, complete static libraries
945   themselves are never linked into other complete static libraries. All
946   complete static libraries are for distribution and linking them in would
947   cause code duplication in this case. If the static library is not for
948   distribution, it should not be complete.
949 
950   GN treats non-complete static libraries as source sets when they are linked
951   into complete static libraries. This is done because some tools like AR do
952   not handle dependent static libraries properly. This makes it easier to write
953   "alink" rules.
954 
955   In rare cases it makes sense to list a header in more than one target if it
956   could be considered conceptually a member of both. libraries.
957 
958 Example
959 
960   static_library("foo") {
961     complete_static_lib = true
962     deps = [ "bar" ]
963   }
964 )";
965 
966 const char kConfigs[] = "configs";
967 const char kConfigs_HelpShort[] =
968     "configs: [label list] Configs applying to this target or config.";
969 const char kConfigs_Help[] =
970     R"(configs: Configs applying to this target or config.
971 
972   A list of config labels.
973 
974 Configs on a target
975 
976   When used on a target, the include_dirs, defines, etc. in each config are
977   appended in the order they appear to the compile command for each file in the
978   target. They will appear after the include_dirs, defines, etc. that the
979   target sets directly.
980 
981   Since configs apply after the values set on a target, directly setting a
982   compiler flag will prepend it to the command line. If you want to append a
983   flag instead, you can put that flag in a one-off config and append that
984   config to the target's configs list.
985 
986   The build configuration script will generally set up the default configs
987   applying to a given target type (see "set_defaults"). When a target is being
988   defined, it can add to or remove from this list.
989 
990 Configs on a config
991 
992   It is possible to create composite configs by specifying configs on a config.
993   One might do this to forward values, or to factor out blocks of settings from
994   very large configs into more manageable named chunks.
995 
996   In this case, the composite config is expanded to be the concatenation of its
997   own values, and in order, the values from its sub-configs *before* anything
998   else happens. This has some ramifications:
999 
1000    - A target has no visibility into a config's sub-configs. Target code only
1001      sees the name of the composite config. It can't remove sub-configs or opt
1002      in to only parts of it. The composite config may not even be defined
1003      before the target is.
1004 
1005    - You can get duplication of values if a config is listed twice, say, on a
1006      target and in a sub-config that also applies. In other cases, the configs
1007      applying to a target are de-duped. It's expected that if a config is
1008      listed as a sub-config that it is only used in that context. (Note that
1009      it's possible to fix this and de-dupe, but it's not normally relevant and
1010      complicates the implementation.)
1011 )" COMMON_ORDERING_HELP
1012     R"(
1013 Example
1014 
1015   # Configs on a target.
1016   source_set("foo") {
1017     # Don't use the default RTTI config that BUILDCONFIG applied to us.
1018     configs -= [ "//build:no_rtti" ]
1019 
1020     # Add some of our own settings.
1021     configs += [ ":mysettings" ]
1022   }
1023 
1024   # Create a default_optimization config that forwards to one of a set of more
1025   # specialized configs depending on build flags. This pattern is useful
1026   # because it allows a target to opt in to either a default set, or a more
1027   # specific set, while avoid duplicating the settings in two places.
1028   config("super_optimization") {
1029     cflags = [ ... ]
1030   }
1031   config("default_optimization") {
1032     if (optimize_everything) {
1033       configs = [ ":super_optimization" ]
1034     } else {
1035       configs = [ ":no_optimization" ]
1036     }
1037   }
1038 )";
1039 
1040 const char kData[] = "data";
1041 const char kData_HelpShort[] =
1042     "data: [file list] Runtime data file dependencies.";
1043 const char kData_Help[] =
1044     R"(data: Runtime data file dependencies.
1045 
1046   Lists files or directories required to run the given target. These are
1047   typically data files or directories of data files. The paths are interpreted
1048   as being relative to the current build file. Since these are runtime
1049   dependencies, they do not affect which targets are built or when. To declare
1050   input files to a script, use "inputs".
1051 
1052   Appearing in the "data" section does not imply any special handling such as
1053   copying them to the output directory. This is just used for declaring runtime
1054   dependencies. Runtime dependencies can be queried using the "runtime_deps"
1055   category of "gn desc" or written during build generation via
1056   "--runtime-deps-list-file".
1057 
1058   GN doesn't require data files to exist at build-time. So actions that produce
1059   files that are in turn runtime dependencies can list those generated files
1060   both in the "outputs" list as well as the "data" list.
1061 
1062   By convention, directories are listed with a trailing slash:
1063     data = [ "test/data/" ]
1064   However, no verification is done on these so GN doesn't enforce this. The
1065   paths are just rebased and passed along when requested.
1066 
1067   Note: On iOS and macOS, create_bundle targets will not be recursed into when
1068   gathering data. See "gn help create_bundle" for details.
1069 
1070   See "gn help runtime_deps" for how these are used.
1071 )";
1072 
1073 const char kDataDeps[] = "data_deps";
1074 const char kDataDeps_HelpShort[] =
1075     "data_deps: [label list] Non-linked dependencies.";
1076 const char kDataDeps_Help[] =
1077     R"(data_deps: Non-linked dependencies.
1078 
1079   A list of target labels.
1080 
1081   Specifies dependencies of a target that are not actually linked into the
1082   current target. Such dependencies will be built and will be available at
1083   runtime.
1084 
1085   This is normally used for things like plugins or helper programs that a
1086   target needs at runtime.
1087 
1088   Note: On iOS and macOS, create_bundle targets will not be recursed into when
1089   gathering data_deps. See "gn help create_bundle" for details.
1090 
1091   See also "gn help deps" and "gn help data".
1092 
1093 Example
1094 
1095   executable("foo") {
1096     deps = [ "//base" ]
1097     data_deps = [ "//plugins:my_runtime_plugin" ]
1098   }
1099 )";
1100 
1101 const char kDataKeys[] = "data_keys";
1102 const char kDataKeys_HelpShort[] =
1103     "data_keys: [string list] Keys from which to collect metadata.";
1104 const char kDataKeys_Help[] =
1105     R"(data_keys: Keys from which to collect metadata.
1106 
1107   These keys are used to identify metadata to collect. If a walked target
1108   defines this key in its metadata, its value will be appended to the resulting
1109   collection.
1110 
1111   See "gn help generated_file".
1112 )";
1113 
1114 const char kDefines[] = "defines";
1115 const char kDefines_HelpShort[] =
1116     "defines: [string list] C preprocessor defines.";
1117 const char kDefines_Help[] =
1118     R"(defines: C preprocessor defines.
1119 
1120   A list of strings
1121 
1122   These strings will be passed to the C/C++ compiler as #defines. The strings
1123   may or may not include an "=" to assign a value.
1124 )" COMMON_ORDERING_HELP
1125     R"(
1126 Example
1127 
1128   defines = [ "AWESOME_FEATURE", "LOG_LEVEL=3" ]
1129 )";
1130 
1131 const char kDepfile[] = "depfile";
1132 const char kDepfile_HelpShort[] =
1133     "depfile: [string] File name for input dependencies for actions.";
1134 const char kDepfile_Help[] =
1135     R"(depfile: [string] File name for input dependencies for actions.
1136 
1137   If nonempty, this string specifies that the current action or action_foreach
1138   target will generate the given ".d" file containing the dependencies of the
1139   input. Empty or unset means that the script doesn't generate the files.
1140 
1141   A depfile should be used only when a target depends on files that are not
1142   already specified by a target's inputs and sources. Likewise, depfiles should
1143   specify only those dependencies not already included in sources or inputs.
1144 
1145   The .d file should go in the target output directory. If you have more than
1146   one source file that the script is being run over, you can use the output
1147   file expansions described in "gn help action_foreach" to name the .d file
1148   according to the input.
1149 
1150   The format is that of a Makefile and all paths must be relative to the root
1151   build directory. Only one output may be listed and it must match the first
1152   output of the action.
1153 
1154   Although depfiles are created by an action, they should not be listed in the
1155   action's "outputs" unless another target will use the file as an input.
1156 
1157 Example
1158 
1159   action_foreach("myscript_target") {
1160     script = "myscript.py"
1161     sources = [ ... ]
1162 
1163     # Locate the depfile in the output directory named like the
1164     # inputs but with a ".d" appended.
1165     depfile = "$target_gen_dir/{{source_name_part}}.d"
1166 
1167     # Say our script uses "-o <d file>" to indicate the depfile.
1168     args = [ "{{source}}", "-o", rebase_path(depfile, root_build_dir)]
1169   }
1170 )";
1171 
1172 const char kDeps[] = "deps";
1173 const char kDeps_HelpShort[] =
1174     "deps: [label list] Private linked dependencies.";
1175 const char kDeps_Help[] =
1176     R"(deps: Private linked dependencies.
1177 
1178   A list of target labels.
1179 
1180   Specifies private dependencies of a target. Private dependencies are
1181   propagated up the dependency tree and linked to dependent targets, but do not
1182   grant the ability to include headers from the dependency. Public configs are
1183   not forwarded.
1184 
1185 Details of dependency propagation
1186 
1187   Source sets, shared libraries, and non-complete static libraries will be
1188   propagated up the dependency tree across groups, non-complete static
1189   libraries and source sets.
1190 
1191   Executables, shared libraries, and complete static libraries will link all
1192   propagated targets and stop propagation. Actions and copy steps also stop
1193   propagation, allowing them to take a library as an input but not force
1194   dependents to link to it.
1195 
1196   Propagation of all_dependent_configs and public_configs happens independently
1197   of target type. all_dependent_configs are always propagated across all types
1198   of targets, and public_configs are always propagated across public deps of
1199   all types of targets.
1200 
1201   For Rust targets, deps ensures that Rust code can refer to the dependency
1202   target. If the dependency is a C/C++ target, the path to that target will
1203   be made available to Rust for `#[link]` directives.
1204 
1205   Data dependencies are propagated differently. See "gn help data_deps" and
1206   "gn help runtime_deps".
1207 
1208   See also "public_deps".
1209 )";
1210 
1211 const char kExterns[] = "externs";
1212 const char kExterns_HelpShort[] =
1213     "externs: [scope] Set of Rust crate-dependency pairs.";
1214 const char kExterns_Help[] =
1215     R"(externs: [scope] Set of Rust crate-dependency pairs.
1216 
1217   A list, each value being a scope indicating a pair of crate name and the path
1218   to the Rust library.
1219 
1220   These libraries will be passed as `--extern crate_name=path` to compiler
1221   invocation containing the current target.
1222 
1223 Examples
1224 
1225     executable("foo") {
1226       sources = [ "main.rs" ]
1227       externs = [{
1228         crate_name = "bar",
1229         path = "path/to/bar.rlib"
1230       }]
1231     }
1232 
1233   This target would compile the `foo` crate with the following `extern` flag:
1234   `--extern bar=path/to/bar.rlib`.
1235 )";
1236 
1237 const char kFriend[] = "friend";
1238 const char kFriend_HelpShort[] =
1239     "friend: [label pattern list] Allow targets to include private headers.";
1240 const char kFriend_Help[] =
1241     R"(friend: Allow targets to include private headers.
1242 
1243   A list of label patterns (see "gn help label_pattern") that allow dependent
1244   targets to include private headers. Applies to all binary targets.
1245 
1246   Normally if a target lists headers in the "public" list (see "gn help
1247   public"), other headers are implicitly marked as private. Private headers
1248   can not be included by other targets, even with a public dependency path.
1249   The "gn check" function performs this validation.
1250 
1251   A friend declaration allows one or more targets to include private headers.
1252   This is useful for things like unit tests that are closely associated with a
1253   target and require internal knowledge without opening up all headers to be
1254   included by all dependents.
1255 
1256   A friend target does not allow that target to include headers when no
1257   dependency exists. A public dependency path must still exist between two
1258   targets to include any headers from a destination target. The friend
1259   annotation merely allows the use of headers that would otherwise be
1260   prohibited because they are private.
1261 
1262   The friend annotation is matched only against the target containing the file
1263   with the include directive. Friend annotations are not propagated across
1264   public or private dependencies. Friend annotations do not affect visibility.
1265 
1266 Example
1267 
1268   static_library("lib") {
1269     # This target can include our private headers.
1270     friend = [ ":unit_tests" ]
1271 
1272     public = [
1273       "public_api.h",  # Normal public API for dependent targets.
1274     ]
1275 
1276     # Private API and sources.
1277     sources = [
1278       "a_source_file.cc",
1279 
1280       # Normal targets that depend on this one won't be able to include this
1281       # because this target defines a list of "public" headers. Without the
1282       # "public" list, all headers are implicitly public.
1283       "private_api.h",
1284     ]
1285   }
1286 
1287   executable("unit_tests") {
1288     sources = [
1289       # This can include "private_api.h" from the :lib target because it
1290       # depends on that target and because of the friend annotation.
1291       "my_test.cc",
1292     ]
1293 
1294     deps = [
1295       ":lib",  # Required for the include to be allowed.
1296     ]
1297   }
1298 )";
1299 
1300 const char kFrameworkDirs[] = "framework_dirs";
1301 const char kFrameworkDirs_HelpShort[] =
1302     "framework_dirs: [directory list] Additional framework search directories.";
1303 const char kFrameworkDirs_Help[] =
1304     R"(framework_dirs: [directory list] Additional framework search directories.
1305 
1306   A list of source directories.
1307 
1308   The directories in this list will be added to the framework search path for
1309   the files in the affected target.
1310 )" COMMON_ORDERING_HELP
1311     R"(
1312 Example
1313 
1314   framework_dirs = [ "src/include", "//third_party/foo" ]
1315 )";
1316 
1317 const char kFrameworks[] = "frameworks";
1318 const char kFrameworks_HelpShort[] =
1319     "frameworks: [name list] Name of frameworks that must be linked.";
1320 const char kFrameworks_Help[] =
1321     R"(frameworks: [name list] Name of frameworks that must be linked.
1322 
1323   A list of framework names.
1324 
1325   The frameworks named in that list will be linked with any dynamic link
1326   type target.
1327 )" COMMON_ORDERING_HELP
1328     R"(
1329 Example
1330 
1331   frameworks = [ "Foundation.framework", "Foo.framework" ]
1332 )";
1333 
1334 const char kIncludeDirs[] = "include_dirs";
1335 const char kIncludeDirs_HelpShort[] =
1336     "include_dirs: [directory list] Additional include directories.";
1337 const char kIncludeDirs_Help[] =
1338     R"(include_dirs: Additional include directories.
1339 
1340   A list of source directories.
1341 
1342   The directories in this list will be added to the include path for the files
1343   in the affected target.
1344 )" COMMON_ORDERING_HELP
1345     R"(
1346 Example
1347 
1348   include_dirs = [ "src/include", "//third_party/foo" ]
1349 )";
1350 
1351 const char kInputs[] = "inputs";
1352 const char kInputs_HelpShort[] =
1353     "inputs: [file list] Additional compile-time dependencies.";
1354 const char kInputs_Help[] =
1355     R"(inputs: Additional compile-time dependencies.
1356 
1357   Inputs are compile-time dependencies of the current target. This means that
1358   all inputs must be available before compiling any of the sources or executing
1359   any actions.
1360 
1361   Inputs are typically only used for action and action_foreach targets.
1362 
1363 Inputs for actions
1364 
1365   For action and action_foreach targets, inputs should be the inputs to script
1366   that don't vary. These should be all .py files that the script uses via
1367   imports (the main script itself will be an implicit dependency of the action
1368   so need not be listed).
1369 
1370   For action targets, inputs and sources are treated the same, but from a style
1371   perspective, it's recommended to follow the same rule as action_foreach and
1372   put helper files in the inputs, and the data used by the script (if any) in
1373   sources.
1374 
1375   Note that another way to declare input dependencies from an action is to have
1376   the action write a depfile (see "gn help depfile"). This allows the script to
1377   dynamically write input dependencies, that might not be known until actually
1378   executing the script. This is more efficient than doing processing while
1379   running GN to determine the inputs, and is easier to keep in-sync than
1380   hardcoding the list.
1381 
1382 Script input gotchas
1383 
1384   It may be tempting to write a script that enumerates all files in a directory
1385   as inputs. Don't do this! Even if you specify all the files in the inputs or
1386   sources in the GN target (or worse, enumerate the files in an exec_script
1387   call when running GN, which will be slow), the dependencies will be broken.
1388 
1389   The problem happens if a file is ever removed because the inputs are not
1390   listed on the command line to the script. Because the script hasn't changed
1391   and all inputs are up to date, the script will not re-run and you will get a
1392   stale build. Instead, either list all inputs on the command line to the
1393   script, or if there are many, create a separate list file that the script
1394   reads. As long as this file is listed in the inputs, the build will detect
1395   when it has changed in any way and the action will re-run.
1396 
1397 Inputs for binary targets
1398 
1399   Any input dependencies will be resolved before compiling any sources or
1400   linking the target. Normally, all actions that a target depends on will be run
1401   before any files in a target are compiled. So if you depend on generated
1402   headers, you do not typically need to list them in the inputs section.
1403 
1404   Inputs for binary targets will be treated as implicit dependencies, meaning
1405   that changes in any of the inputs will force all sources in the target to be
1406   recompiled. If an input only applies to a subset of source files, you may
1407   want to split those into a separate target to avoid unnecessary recompiles.
1408 
1409 Example
1410 
1411   action("myscript") {
1412     script = "domything.py"
1413     inputs = [ "input.data" ]
1414   }
1415 )";
1416 
1417 const char kLdflags[] = "ldflags";
1418 const char kLdflags_HelpShort[] =
1419     "ldflags: [string list] Flags passed to the linker.";
1420 const char kLdflags_Help[] =
1421     R"(ldflags: Flags passed to the linker.
1422 
1423   A list of strings.
1424 
1425   These flags are passed on the command-line to the linker and generally
1426   specify various linking options. Most targets will not need these and will
1427   use "libs" and "lib_dirs" instead.
1428 
1429   ldflags are NOT pushed to dependents, so applying ldflags to source sets or
1430   static libraries will be a no-op. If you want to apply ldflags to dependent
1431   targets, put them in a config and set it in the all_dependent_configs or
1432   public_configs.
1433 )" COMMON_ORDERING_HELP;
1434 
1435 #define COMMON_LIB_INHERITANCE_HELP                                          \
1436   "\n"                                                                       \
1437   "  libs and lib_dirs work differently than other flags in two respects.\n" \
1438   "  First, they are inherited across static library boundaries until a\n"   \
1439   "  shared library or executable target is reached. Second, they are\n"     \
1440   "  uniquified so each one is only passed once (the first instance of it\n" \
1441   "  will be the one used).\n"
1442 
1443 #define LIBS_AND_LIB_DIRS_ORDERING_HELP                                  \
1444   "\n"                                                                   \
1445   "  For \"libs\" and \"lib_dirs\" only, the values propagated from\n"   \
1446   "  dependencies (as described above) are applied last assuming they\n" \
1447   "  are not already in the list.\n"
1448 
1449 const char kLibDirs[] = "lib_dirs";
1450 const char kLibDirs_HelpShort[] =
1451     "lib_dirs: [directory list] Additional library directories.";
1452 const char kLibDirs_Help[] =
1453     R"(lib_dirs: Additional library directories.
1454 
1455   A list of directories.
1456 
1457   Specifies additional directories passed to the linker for searching for the
1458   required libraries. If an item is not an absolute path, it will be treated as
1459   being relative to the current build file.
1460 )" COMMON_LIB_INHERITANCE_HELP COMMON_ORDERING_HELP LIBS_AND_LIB_DIRS_ORDERING_HELP
1461     R"(
1462 Example
1463 
1464   lib_dirs = [ "/usr/lib/foo", "lib/doom_melon" ]
1465 )";
1466 
1467 const char kLibs[] = "libs";
1468 const char kLibs_HelpShort[] =
1469     "libs: [string list] Additional libraries to link.";
1470 const char kLibs_Help[] =
1471     R"(libs: Additional libraries to link.
1472 
1473   A list of library names or library paths.
1474 
1475   These libraries will be linked into the final binary (executable or shared
1476   library) containing the current target.
1477 )" COMMON_LIB_INHERITANCE_HELP
1478     R"(
1479 Types of libs
1480 
1481   There are several different things that can be expressed in libs:
1482 
1483   File paths
1484       Values containing '/' will be treated as references to files in the
1485       checkout. They will be rebased to be relative to the build directory and
1486       specified in the "libs" for linker tools. This facility should be used
1487       for libraries that are checked in to the version control. For libraries
1488       that are generated by the build, use normal GN deps to link them.
1489 
1490   System libraries
1491       Values not containing '/' will be treated as system library names. These
1492       will be passed unmodified to the linker and prefixed with the
1493       "lib_switch" attribute of the linker tool. Generally you would set the
1494       "lib_dirs" so the given library is found. Your BUILD.gn file should not
1495       specify the switch (like "-l"): this will be encoded in the "lib_switch"
1496       of the tool.
1497 )" COMMON_ORDERING_HELP LIBS_AND_LIB_DIRS_ORDERING_HELP
1498     R"(
1499 Examples
1500 
1501   On Windows:
1502     libs = [ "ctl3d.lib" ]
1503 
1504   On Linux:
1505     libs = [ "ld" ]
1506 )";
1507 
1508 const char kMetadata[] = "metadata";
1509 const char kMetadata_HelpShort[] = "metadata: [scope] Metadata of this target.";
1510 const char kMetadata_Help[] =
1511     R"(metadata: Metadata of this target.
1512 
1513   Metadata is a collection of keys and values relating to a particular target.
1514   Values must be lists, allowing for sane and predictable collection behavior.
1515   Generally, these keys will include three types of lists: lists of ordinary
1516   strings, lists of filenames intended to be rebased according to their
1517   particular source directory, and lists of target labels intended to be used
1518   as barriers to the walk. Verification of these categories occurs at walk time,
1519   not creation time (since it is not clear until the walk which values are
1520   intended for which purpose).
1521 
1522 Example
1523 
1524   group("doom_melon") {
1525     metadata = {
1526       # These keys are not built in to GN but are interpreted when consuming
1527       # metadata.
1528       my_barrier = []
1529       my_files = [ "a.txt", "b.txt" ]
1530     }
1531   }
1532 )";
1533 
1534 const char kOutputExtension[] = "output_extension";
1535 const char kOutputExtension_HelpShort[] =
1536     "output_extension: [string] Value to use for the output's file extension.";
1537 const char kOutputExtension_Help[] =
1538     R"(output_extension: Value to use for the output's file extension.
1539 
1540   Normally the file extension for a target is based on the target type and the
1541   operating system, but in rare cases you will need to override the name (for
1542   example to use "libfreetype.so.6" instead of libfreetype.so on Linux).
1543 
1544   This value should not include a leading dot. If undefined, the default
1545   specified on the tool will be used. If set to the empty string, no output
1546   extension will be used.
1547 
1548   The output_extension will be used to set the "{{output_extension}}" expansion
1549   which the linker tool will generally use to specify the output file name. See
1550   "gn help tool".
1551 
1552 Example
1553 
1554   shared_library("freetype") {
1555     if (is_linux) {
1556       # Call the output "libfreetype.so.6"
1557       output_extension = "so.6"
1558     }
1559     ...
1560   }
1561 
1562   # On Windows, generate a "mysettings.cpl" control panel applet. Control panel
1563   # applets are actually special shared libraries.
1564   if (is_win) {
1565     shared_library("mysettings") {
1566       output_extension = "cpl"
1567       ...
1568     }
1569   }
1570 )";
1571 
1572 const char kOutputDir[] = "output_dir";
1573 const char kOutputDir_HelpShort[] =
1574     "output_dir: [directory] Directory to put output file in.";
1575 const char kOutputDir_Help[] =
1576     R"(output_dir: [directory] Directory to put output file in.
1577 
1578   For library and executable targets, overrides the directory for the final
1579   output. This must be in the root_build_dir or a child thereof.
1580 
1581   This should generally be in the root_out_dir or a subdirectory thereof (the
1582   root_out_dir will be the same as the root_build_dir for the default
1583   toolchain, and will be a subdirectory for other toolchains). Not putting the
1584   output in a subdirectory of root_out_dir can result in collisions between
1585   different toolchains, so you will need to take steps to ensure that your
1586   target is only present in one toolchain.
1587 
1588   Normally the toolchain specifies the output directory for libraries and
1589   executables (see "gn help tool"). You will have to consult that for the
1590   default location. The default location will be used if output_dir is
1591   undefined or empty.
1592 
1593 Example
1594 
1595   shared_library("doom_melon") {
1596     output_dir = "$root_out_dir/plugin_libs"
1597     ...
1598   }
1599 )";
1600 
1601 const char kOutputName[] = "output_name";
1602 const char kOutputName_HelpShort[] =
1603     "output_name: [string] Name for the output file other than the default.";
1604 const char kOutputName_Help[] =
1605     R"(output_name: Define a name for the output file other than the default.
1606 
1607   Normally the output name of a target will be based on the target name, so the
1608   target "//foo/bar:bar_unittests" will generate an output file such as
1609   "bar_unittests.exe" (using Windows as an example).
1610 
1611   Sometimes you will want an alternate name to avoid collisions or if the
1612   internal name isn't appropriate for public distribution.
1613 
1614   The output name should have no extension or prefixes, these will be added
1615   using the default system rules. For example, on Linux an output name of "foo"
1616   will produce a shared library "libfoo.so". There is no way to override the
1617   output prefix of a linker tool on a per- target basis. If you need more
1618   flexibility, create a copy target to produce the file you want.
1619 
1620   This variable is valid for all binary output target types.
1621 
1622 Example
1623 
1624   static_library("doom_melon") {
1625     output_name = "fluffy_bunny"
1626   }
1627 )";
1628 
1629 const char kOutputPrefixOverride[] = "output_prefix_override";
1630 const char kOutputPrefixOverride_HelpShort[] =
1631     "output_prefix_override: [boolean] Don't use prefix for output name.";
1632 const char kOutputPrefixOverride_Help[] =
1633     R"(output_prefix_override: Don't use prefix for output name.
1634 
1635   A boolean that overrides the output prefix for a target. Defaults to false.
1636 
1637   Some systems use prefixes for the names of the final target output file. The
1638   normal example is "libfoo.so" on Linux for a target named "foo".
1639 
1640   The output prefix for a given target type is specified on the linker tool
1641   (see "gn help tool"). Sometimes this prefix is undesired.
1642 
1643   See also "gn help output_extension".
1644 
1645 Example
1646 
1647   shared_library("doom_melon") {
1648     # Normally this will produce "libdoom_melon.so" on Linux. Setting this flag
1649     # will produce "doom_melon.so".
1650     output_prefix_override = true
1651     ...
1652   }
1653 )";
1654 
1655 const char kPartialInfoPlist[] = "partial_info_plist";
1656 const char kPartialInfoPlist_HelpShort[] =
1657     "partial_info_plist: [filename] Path plist from asset catalog compiler.";
1658 const char kPartialInfoPlist_Help[] =
1659     R"(partial_info_plist: [filename] Path plist from asset catalog compiler.
1660 
1661   Valid for create_bundle target, corresponds to the path for the partial
1662   Info.plist created by the asset catalog compiler that needs to be merged
1663   with the application Info.plist (usually done by the post-processing script).
1664 
1665   The file will be generated regardless of whether the asset compiler has
1666   been invoked or not. See "gn help create_bundle".
1667 )";
1668 
1669 const char kOutputs[] = "outputs";
1670 const char kOutputs_HelpShort[] =
1671     "outputs: [file list] Output files for actions and copy targets.";
1672 const char kOutputs_Help[] =
1673     R"(outputs: Output files for actions and copy targets.
1674 
1675   Outputs is valid for "copy", "action", and "action_foreach" target types and
1676   indicates the resulting files. Outputs must always refer to files in the
1677   build directory.
1678 
1679   copy
1680     Copy targets should have exactly one entry in the outputs list. If there is
1681     exactly one source, this can be a literal file name or a source expansion.
1682     If there is more than one source, this must contain a source expansion to
1683     map a single input name to a single output name. See "gn help copy".
1684 
1685   action_foreach
1686     Action_foreach targets must always use source expansions to map input files
1687     to output files. There can be more than one output, which means that each
1688     invocation of the script will produce a set of files (presumably based on
1689     the name of the input file). See "gn help action_foreach".
1690 
1691   action
1692     Action targets (excluding action_foreach) must list literal output file(s)
1693     with no source expansions. See "gn help action".
1694 )";
1695 
1696 const char kPool[] = "pool";
1697 const char kPool_HelpShort[] =
1698     "pool: [string] Label of the pool used by binary targets and actions.";
1699 const char kPool_Help[] =
1700     R"(pool: Label of the pool used by binary targets actions.
1701 
1702   A fully-qualified label representing the pool that will be used for binary
1703   targets and actions. Pools are defined using the pool() {...} declaration.
1704 
1705 Example
1706 
1707   executable("binary") {
1708     pool = "//build:custom_pool"
1709     ...
1710   }
1711 
1712   action("action") {
1713     pool = "//build:custom_pool"
1714     ...
1715   }
1716 )";
1717 
1718 const char kPostProcessingArgs[] = "post_processing_args";
1719 const char kPostProcessingArgs_HelpShort[] =
1720     "post_processing_args: [string list] Args for the post-processing script.";
1721 const char kPostProcessingArgs_Help[] =
1722     R"(post_processing_args: [string list] Args for the post-processing script.
1723 
1724   For create_bundle targets, post_processing_args is the list of arguments to
1725   pass to the post-processing script. Typically you would use source expansion
1726   (see "gn help source_expansion") to insert the source file names.
1727 
1728   See also "gn help create_bundle".
1729 )";
1730 
1731 const char kPostProcessingOutputs[] = "post_processing_outputs";
1732 const char kPostProcessingOutputs_HelpShort[] =
1733     "post_processing_outputs: [file list] Outputs of the post-processing step.";
1734 const char kPostProcessingOutputs_Help[] =
1735     R"(post_processing_outputs: [file list] Outputs of the post-processing step.
1736 
1737   Outputs from the post-processing step of a create_bundle target. Must refer to
1738   files in the build directory.
1739 
1740   See also "gn help create_bundle".
1741 )";
1742 
1743 const char kPostProcessingScript[] = "post_processing_script";
1744 const char kPostProcessingScript_HelpShort[] =
1745     "post_processing_script: [file name] Script for the post-processing step.";
1746 const char kPostProcessingScript_Help[] =
1747     R"(post_processing_script: [file name] Script for the post-processing step."
1748 
1749   An absolute or buildfile-relative file name of a Python script to run for a
1750   create_bundle target to perform the post-processing step.
1751 
1752   See also "gn help create_bundle".
1753 )";
1754 
1755 const char kPostProcessingSources[] = "post_processing_sources";
1756 const char kPostProcessingSources_HelpShort[] =
1757     "post_processing_sources: [file list] Sources for the post-processing "
1758     "step.";
1759 const char kPostProcessingSources_Help[] =
1760     R"(post_processing_sources: [file list] Sources for the post-processing step.
1761 
1762   A list of files used as input for the post-processing step of a create_bundle
1763   target. Non-absolute paths will be resolved relative to the current build
1764   file.
1765 
1766   See also "gn help create_bundle".
1767 )";
1768 
1769 const char kPrecompiledHeader[] = "precompiled_header";
1770 const char kPrecompiledHeader_HelpShort[] =
1771     "precompiled_header: [string] Header file to precompile.";
1772 const char kPrecompiledHeader_Help[] =
1773     R"(precompiled_header: [string] Header file to precompile.
1774 
1775   Precompiled headers will be used when a target specifies this value, or a
1776   config applying to this target specifies this value. In addition, the tool
1777   corresponding to the source files must also specify precompiled headers (see
1778   "gn help tool"). The tool will also specify what type of precompiled headers
1779   to use, by setting precompiled_header_type to either "gcc" or "msvc".
1780 
1781   The precompiled header/source variables can be specified on a target or a
1782   config, but must be the same for all configs applying to a given target since
1783   a target can only have one precompiled header.
1784 
1785   If you use both C and C++ sources, the precompiled header and source file
1786   will be compiled once per language. You will want to make sure to wrap C++
1787   includes in __cplusplus #ifdefs so the file will compile in C mode.
1788 
1789 GCC precompiled headers
1790 
1791   When using GCC-style precompiled headers, "precompiled_source" contains the
1792   path of a .h file that is precompiled and then included by all source files
1793   in targets that set "precompiled_source".
1794 
1795   The value of "precompiled_header" is not used with GCC-style precompiled
1796   headers.
1797 
1798 MSVC precompiled headers
1799 
1800   When using MSVC-style precompiled headers, the "precompiled_header" value is
1801   a string corresponding to the header. This is NOT a path to a file that GN
1802   recognises, but rather the exact string that appears in quotes after
1803   an #include line in source code. The compiler will match this string against
1804   includes or forced includes (/FI).
1805 
1806   MSVC also requires a source file to compile the header with. This must be
1807   specified by the "precompiled_source" value. In contrast to the header value,
1808   this IS a GN-style file name, and tells GN which source file to compile to
1809   make the .pch file used for subsequent compiles.
1810 
1811   For example, if the toolchain specifies MSVC headers:
1812 
1813     toolchain("vc_x64") {
1814       ...
1815       tool("cxx") {
1816         precompiled_header_type = "msvc"
1817         ...
1818 
1819   You might make a config like this:
1820 
1821     config("use_precompiled_headers") {
1822       precompiled_header = "build/precompile.h"
1823       precompiled_source = "//build/precompile.cc"
1824 
1825       # Either your source files should #include "build/precompile.h"
1826       # first, or you can do this to force-include the header.
1827       cflags = [ "/FI$precompiled_header" ]
1828     }
1829 
1830   And then define a target that uses the config:
1831 
1832     executable("doom_melon") {
1833       configs += [ ":use_precompiled_headers" ]
1834       ...
1835 )";
1836 
1837 const char kPrecompiledHeaderType[] = "precompiled_header_type";
1838 const char kPrecompiledHeaderType_HelpShort[] =
1839     "precompiled_header_type: [string] \"gcc\" or \"msvc\".";
1840 const char kPrecompiledHeaderType_Help[] =
1841     R"(precompiled_header_type: [string] "gcc" or "msvc".
1842 
1843   See "gn help precompiled_header".
1844 )";
1845 
1846 const char kPrecompiledSource[] = "precompiled_source";
1847 const char kPrecompiledSource_HelpShort[] =
1848     "precompiled_source: [file name] Source file to precompile.";
1849 const char kPrecompiledSource_Help[] =
1850     R"(precompiled_source: [file name] Source file to precompile.
1851 
1852   The source file that goes along with the precompiled_header when using
1853   "msvc"-style precompiled headers. It will be implicitly added to the sources
1854   of the target. See "gn help precompiled_header".
1855 )";
1856 
1857 const char kProductType[] = "product_type";
1858 const char kProductType_HelpShort[] =
1859     "product_type: [string] Product type for the bundle.";
1860 const char kProductType_Help[] =
1861     R"(product_type: [string] Product type for the bundle.
1862 
1863   Valid for "create_bundle" and "bundle_data" targets.
1864 
1865   Correspond to the type of the bundle. Used by transparent "create_bundle"
1866   target to control whether a "bundle_data" needs to be propagated or not.
1867 
1868   When generating Xcode project, the product_type is propagated and only
1869   "create_bundle" with a non-empty product_type will have a corresponding
1870   target in the project.
1871 )";
1872 
1873 const char kPublic[] = "public";
1874 const char kPublic_HelpShort[] =
1875     "public: [file list] Declare public header files for a target.";
1876 const char kPublic_Help[] =
1877     R"(public: Declare public header files for a target.
1878 
1879   A list of files that other targets can include. These permissions are checked
1880   via the "check" command (see "gn help check").
1881 
1882   If no public files are declared, other targets (assuming they have visibility
1883   to depend on this target) can include any file in the sources list. If this
1884   variable is defined on a target, dependent targets may only include files on
1885   this whitelist unless that target is marked as a friend (see "gn help
1886   friend").
1887 
1888   Header file permissions are also subject to visibility. A target must be
1889   visible to another target to include any files from it at all and the public
1890   headers indicate which subset of those files are permitted. See "gn help
1891   visibility" for more.
1892 
1893   Public files are inherited through the dependency tree. So if there is a
1894   dependency A -> B -> C, then A can include C's public headers. However, the
1895   same is NOT true of visibility, so unless A is in C's visibility list, the
1896   include will be rejected.
1897 
1898   GN only knows about files declared in the "sources" and "public" sections of
1899   targets. If a file is included that is not known to the build, it will be
1900   allowed.
1901 
1902   It is common for test targets to need to include private headers for their
1903   associated code. In this case, list the test target in the "friend" list of
1904   the target that owns the private header to allow the inclusion. See
1905   "gn help friend" for more.
1906 
1907   When a binary target has no explicit or implicit public headers (a "public"
1908   list is defined but is empty), GN assumes that the target can not propagate
1909   any compile-time dependencies up the dependency tree. In this case, the build
1910   can be parallelized more efficiently.
1911   Say there are dependencies:
1912     A (shared library) -> B (shared library) -> C (action).
1913   Normally C must complete before any source files in A can compile (because
1914   there might be generated includes). But when B explicitly declares no public
1915   headers, C can execute in parallel with A's compile steps. C must still be
1916   complete before any dependents link.
1917 
1918 Examples
1919 
1920   These exact files are public:
1921     public = [ "foo.h", "bar.h" ]
1922 
1923   No files are public (no targets may include headers from this one):
1924     # This allows starting compilation in dependent targets earlier.
1925     public = []
1926 )";
1927 
1928 const char kPublicConfigs[] = "public_configs";
1929 const char kPublicConfigs_HelpShort[] =
1930     "public_configs: [label list] Configs applied to dependents.";
1931 const char kPublicConfigs_Help[] =
1932     R"(public_configs: Configs to be applied on dependents.
1933 
1934   A list of config labels.
1935 
1936   Targets directly depending on this one will have the configs listed in this
1937   variable added to them. These configs will also apply to the current target.
1938   Generally, public configs are used to apply defines and include directories
1939   necessary to compile this target's header files.
1940 
1941   See also "gn help all_dependent_configs".
1942 
1943 Propagation of public configs
1944 
1945   Public configs are applied to all targets that depend directly on this one.
1946   These dependent targets can further push this target's public configs
1947   higher in the dependency tree by depending on it via public_deps (see "gn
1948   help public_deps").
1949 
1950     static_library("toplevel") {
1951       # This target will get "my_config" applied to it. However, since this
1952       # target uses "deps" and not "public_deps", targets that depend on this
1953       # one won't get it.
1954       deps = [ ":intermediate" ]
1955     }
1956 
1957     static_library("intermediate") {
1958       # Depending on "lower" in any way will apply "my_config" to this target.
1959       # Additionall, since this target depends on "lower" via public_deps,
1960       # targets that depend on this one will also get "my_config".
1961       public_deps = [ ":lower" ]
1962     }
1963 
1964     static_library("lower") {
1965       # This will get applied to all targets that depend on this one.
1966       public_configs = [ ":my_config" ]
1967     }
1968 
1969   Public config propagation happens in a second phase once a target and all of
1970   its dependencies have been resolved. Therefore, a target will not see these
1971   force-added configs in their "configs" variable while the script is running,
1972   and they can not be removed. As a result, this capability should generally
1973   only be used to add defines and include directories rather than setting
1974   complicated flags that some targets may not want.
1975 
1976   Public configs may or may not be propagated across toolchain boundaries
1977   depending on the value of the propagates_configs flag (see "gn help
1978   toolchain") on the toolchain of the target declaring the public_config.
1979 
1980 Avoiding applying public configs to this target
1981 
1982   If you want the config to apply to targets that depend on this one, but NOT
1983   this one, define an extra layer of indirection using a group:
1984 
1985     # External targets depend on this group.
1986     group("my_target") {
1987       # Config to apply to all targets that depend on this one.
1988       public_configs = [ ":external_settings" ]
1989       deps = [ ":internal_target" ]
1990     }
1991 
1992     # Internal target to actually compile the sources.
1993     static_library("internal_target") {
1994       # Force all external targets to depend on the group instead of directly
1995       # on this so the "external_settings" config will get applied.
1996       visibility = [ ":my_target" ]
1997       ...
1998     }
1999 
2000 )" COMMON_ORDERING_HELP;
2001 
2002 const char kPublicDeps[] = "public_deps";
2003 const char kPublicDeps_HelpShort[] =
2004     "public_deps: [label list] Declare public dependencies.";
2005 const char kPublicDeps_Help[] =
2006     R"(public_deps: Declare public dependencies.
2007 
2008   Public dependencies are like private dependencies (see "gn help deps") but
2009   additionally express that the current target exposes the listed deps as part
2010   of its public API.
2011 
2012   This has several ramifications:
2013 
2014     - public_configs that are part of the dependency are forwarded to direct
2015       dependents.
2016 
2017     - Public headers in the dependency are usable by dependents (includes do
2018       not require a direct dependency or visibility).
2019 
2020     - If the current target is a shared library, other shared libraries that it
2021       publicly depends on (directly or indirectly) are propagated up the
2022       dependency tree to dependents for linking.
2023 
2024   See also "gn help public_configs".
2025 
2026 Discussion
2027 
2028   Say you have three targets: A -> B -> C. C's visibility may allow B to depend
2029   on it but not A. Normally, this would prevent A from including any headers
2030   from C, and C's public_configs would apply only to B.
2031 
2032   If B lists C in its public_deps instead of regular deps, A will now inherit
2033   C's public_configs and the ability to include C's public headers.
2034 
2035   Generally if you are writing a target B and you include C's headers as part
2036   of B's public headers, or targets depending on B should consider B and C to
2037   be part of a unit, you should use public_deps instead of deps.
2038 
2039 Example
2040 
2041   # This target can include files from "c" but not from
2042   # "super_secret_implementation_details".
2043   executable("a") {
2044     deps = [ ":b" ]
2045   }
2046 
2047   shared_library("b") {
2048     deps = [ ":super_secret_implementation_details" ]
2049     public_deps = [ ":c" ]
2050   }
2051 )";
2052 
2053 const char kRebase[] = "rebase";
2054 const char kRebase_HelpShort[] =
2055     "rebase: [boolean] Rebase collected metadata as files.";
2056 const char kRebase_Help[] =
2057     R"(rebase: Rebase collected metadata as files.
2058 
2059   A boolean that triggers a rebase of collected metadata strings based on their
2060   declared file. Defaults to false.
2061 
2062   Metadata generally declares files as strings relative to the local build file.
2063   However, this data is often used in other contexts, and so setting this flag
2064   will force the metadata collection to be rebased according to the local build
2065   file's location and thus allow the filename to be used anywhere.
2066 
2067   Setting this flag will raise an error if any target's specified metadata is
2068   not a string value.
2069 
2070   See also "gn help generated_file".
2071 )";
2072 
2073 const char kResponseFileContents[] = "response_file_contents";
2074 const char kResponseFileContents_HelpShort[] =
2075     "response_file_contents: [string list] Contents of .rsp file for actions.";
2076 const char kResponseFileContents_Help[] =
2077     R"*(response_file_contents: Contents of a response file for actions.
2078 
2079   Sometimes the arguments passed to a script can be too long for the system's
2080   command-line capabilities. This is especially the case on Windows where the
2081   maximum command-line length is less than 8K. A response file allows you to
2082   pass an unlimited amount of data to a script in a temporary file for an
2083   action or action_foreach target.
2084 
2085   If the response_file_contents variable is defined and non-empty, the list
2086   will be treated as script args (including possibly substitution patterns)
2087   that will be written to a temporary file at build time. The name of the
2088   temporary file will be substituted for "{{response_file_name}}" in the script
2089   args.
2090 
2091   The response file contents will always be quoted and escaped according to
2092   Unix shell rules. To parse the response file, the Python script should use
2093   "shlex.split(file_contents)".
2094 
2095 Example
2096 
2097   action("process_lots_of_files") {
2098     script = "process.py",
2099     inputs = [ ... huge list of files ... ]
2100 
2101     # Write all the inputs to a response file for the script. Also,
2102     # make the paths relative to the script working directory.
2103     response_file_contents = rebase_path(inputs, root_build_dir)
2104 
2105     # The script expects the name of the response file in --file-list.
2106     args = [
2107       "--enable-foo",
2108       "--file-list={{response_file_name}}",
2109     ]
2110   }
2111 )*";
2112 
2113 const char kScript[] = "script";
2114 const char kScript_HelpShort[] = "script: [file name] Script file for actions.";
2115 const char kScript_Help[] =
2116     R"(script: Script file for actions.
2117 
2118   An absolute or buildfile-relative file name of a Python script to run for a
2119   action and action_foreach targets (see "gn help action" and "gn help
2120   action_foreach").
2121 )";
2122 
2123 const char kSources[] = "sources";
2124 const char kSources_HelpShort[] =
2125     "sources: [file list] Source files for a target.";
2126 const char kSources_Help[] =
2127     R"(sources: Source files for a target
2128 
2129   A list of files. Non-absolute paths will be resolved relative to the current
2130   build file.
2131 
2132 Sources for binary targets
2133 
2134   For binary targets (source sets, executables, and libraries), the known file
2135   types will be compiled with the associated tools. Unknown file types and
2136   headers will be skipped. However, you should still list all C/C+ header files
2137   so GN knows about the existence of those files for the purposes of include
2138   checking.
2139 
2140   As a special case, a file ending in ".def" will be treated as a Windows
2141   module definition file. It will be appended to the link line with a
2142   preceding "/DEF:" string. There must be at most one .def file in a target
2143   and they do not cross dependency boundaries (so specifying a .def file in a
2144   static library or source set will have no effect on the executable or shared
2145   library they're linked into).
2146 
2147   For Rust targets that do not specify a crate_root, then the crate_root will
2148   look for a lib.rs file (or main.rs for executable) or a single file in
2149   sources, if sources contains only one file.
2150 
2151 Sources for non-binary targets
2152 
2153   action_foreach
2154     The sources are the set of files that the script will be executed over. The
2155     script will run once per file.
2156 
2157   action
2158     The sources will be treated the same as inputs. See "gn help inputs" for
2159     more information and usage advice.
2160 
2161   copy
2162     The source are the source files to copy.
2163 )";
2164 
2165 const char kSwiftflags[] = "swiftflags";
2166 const char kSwiftflags_HelpShort[] =
2167     "swiftflags: [string list] Flags passed to the swift compiler.";
2168 const char* kSwiftflags_Help =
2169     R"(swiftflags: Flags passed to the swift compiler.
2170 
2171   A list of strings.
2172 
2173   "swiftflags" are passed to any invocation of a tool that takes an .swift
2174   file as input.
2175 )" COMMON_ORDERING_HELP;
2176 
2177 const char kXcodeTestApplicationName[] = "xcode_test_application_name";
2178 const char kXcodeTestApplicationName_HelpShort[] =
2179     "xcode_test_application_name: [string] Name for Xcode test target.";
2180 const char kXcodeTestApplicationName_Help[] =
2181     R"(xcode_test_application_name: Name for Xcode test target.
2182 
2183   Each unit and ui test target must have a test application target, and this
2184   value is used to specify the relationship. Only meaningful to Xcode (used as
2185   part of the Xcode project generation).
2186 
2187   See "gn help create_bundle" for more information.
2188 
2189 Example
2190 
2191   create_bundle("chrome_xctest") {
2192     test_application_name = "chrome"
2193     ...
2194   }
2195 )";
2196 
2197 const char kTestonly[] = "testonly";
2198 const char kTestonly_HelpShort[] =
2199     "testonly: [boolean] Declares a target must only be used for testing.";
2200 const char kTestonly_Help[] =
2201     R"(testonly: Declares a target must only be used for testing.
2202 
2203   Boolean. Defaults to false.
2204 
2205   When a target is marked "testonly = true", it must only be depended on by
2206   other test-only targets. Otherwise, GN will issue an error that the
2207   depenedency is not allowed.
2208 
2209   This feature is intended to prevent accidentally shipping test code in a
2210   final product.
2211 
2212 Example
2213 
2214   source_set("test_support") {
2215     testonly = true
2216     ...
2217   }
2218 )";
2219 
2220 const char kVisibility[] = "visibility";
2221 const char kVisibility_HelpShort[] =
2222     "visibility: [label list] A list of labels that can depend on a target.";
2223 const char kVisibility_Help[] =
2224     R"(visibility: A list of labels that can depend on a target.
2225 
2226   A list of labels and label patterns that define which targets can depend on
2227   the current one. These permissions are checked via the "check" command (see
2228   "gn help check").
2229 
2230   If visibility is not defined, it defaults to public ("*").
2231 
2232   If visibility is defined, only the targets with labels that match it can
2233   depend on the current target. The empty list means no targets can depend on
2234   the current target.
2235 
2236   Tip: Often you will want the same visibility for all targets in a BUILD file.
2237   In this case you can just put the definition at the top, outside of any
2238   target, and the targets will inherit that scope and see the definition.
2239 
2240 Patterns
2241 
2242   See "gn help label_pattern" for more details on what types of patterns are
2243   supported. If a toolchain is specified, only targets in that toolchain will
2244   be matched. If a toolchain is not specified on a pattern, targets in all
2245   toolchains will be matched.
2246 
2247 Examples
2248 
2249   Only targets in the current buildfile ("private"):
2250     visibility = [ ":*" ]
2251 
2252   No targets (used for targets that should be leaf nodes):
2253     visibility = []
2254 
2255   Any target ("public", the default):
2256     visibility = [ "*" ]
2257 
2258   All targets in the current directory and any subdirectory:
2259     visibility = [ "./*" ]
2260 
2261   Any target in "//bar/BUILD.gn":
2262     visibility = [ "//bar:*" ]
2263 
2264   Any target in "//bar/" or any subdirectory thereof:
2265     visibility = [ "//bar/*" ]
2266 
2267   Just these specific targets:
2268     visibility = [ ":mything", "//foo:something_else" ]
2269 
2270   Any target in the current directory and any subdirectory thereof, plus
2271   any targets in "//bar/" and any subdirectory thereof.
2272     visibility = [ "./*", "//bar/*" ]
2273 )";
2274 
2275 const char kWalkKeys[] = "walk_keys";
2276 const char kWalkKeys_HelpShort[] =
2277     "walk_keys: [string list] Key(s) for managing the metadata collection "
2278     "walk.";
2279 const char kWalkKeys_Help[] =
2280     R"(walk_keys: Key(s) for managing the metadata collection walk.
2281 
2282   Defaults to [""].
2283 
2284   These keys are used to control the next step in a collection walk, acting as
2285   barriers. If a specified key is defined in a target's metadata, the walk will
2286   use the targets listed in that value to determine which targets are walked.
2287 
2288   If no walk_keys are specified for a generated_file target (i.e. "[""]"), the
2289   walk will touch all deps and data_deps of the specified target recursively.
2290 
2291   See "gn help generated_file".
2292 )";
2293 
2294 const char kWeakFrameworks[] = "weak_frameworks";
2295 const char kWeakFrameworks_HelpShort[] =
2296     "weak_frameworks: [name list] Name of frameworks that must be weak linked.";
2297 const char kWeakFrameworks_Help[] =
2298     R"(weak_frameworks: [name list] Name of frameworks that must be weak linked.
2299 
2300   A list of framework names.
2301 
2302   The frameworks named in that list will be weak linked with any dynamic link
2303   type target. Weak linking instructs the dynamic loader to attempt to load
2304   the framework, but if it is not able to do so, it leaves any imported symbols
2305   unresolved. This is typically used when a framework is present in a new
2306   version of an SDK but not on older versions of the OS that the software runs
2307   on.
2308 )" COMMON_ORDERING_HELP
2309     R"(
2310 Example
2311 
2312   weak_frameworks = [ "OnlyOnNewerOSes.framework" ]
2313 )";
2314 
2315 const char kWriteValueContents[] = "contents";
2316 const char kWriteValueContents_HelpShort[] =
2317     "contents: Contents to write to file.";
2318 const char kWriteValueContents_Help[] =
2319     R"(contents: Contents to write to file.
2320 
2321   The contents of the file for a generated_file target.
2322   See "gn help generated_file".
2323 )";
2324 
2325 const char kWriteOutputConversion[] = "output_conversion";
2326 const char kWriteOutputConversion_HelpShort[] =
2327     "output_conversion: Data format for generated_file targets.";
2328 const char kWriteOutputConversion_Help[] =
2329     R"(output_conversion: Data format for generated_file targets.
2330 
2331   Controls how the "contents" of a generated_file target is formatted.
2332   See `gn help io_conversion`.
2333 )";
2334 
2335 const char kWriteRuntimeDeps[] = "write_runtime_deps";
2336 const char kWriteRuntimeDeps_HelpShort[] =
2337     "write_runtime_deps: Writes the target's runtime_deps to the given path.";
2338 const char kWriteRuntimeDeps_Help[] =
2339     R"(write_runtime_deps: Writes the target's runtime_deps to the given path.
2340 
2341   Does not synchronously write the file, but rather schedules it to be written
2342   at the end of generation.
2343 
2344   If the file exists and the contents are identical to that being written, the
2345   file will not be updated. This will prevent unnecessary rebuilds of targets
2346   that depend on this file.
2347 
2348   Path must be within the output directory.
2349 
2350   See "gn help runtime_deps" for how the runtime dependencies are computed.
2351 
2352   The format of this file will list one file per line with no escaping. The
2353   files will be relative to the root_build_dir. The first line of the file will
2354   be the main output file of the target itself. The file contents will be the
2355   same as requesting the runtime deps be written on the command line (see "gn
2356   help --runtime-deps-list-file").
2357 )";
2358 
2359 const char kXcodeExtraAttributes[] = "xcode_extra_attributes";
2360 const char kXcodeExtraAttributes_HelpShort[] =
2361     "xcode_extra_attributes: [scope] Extra attributes for Xcode projects.";
2362 const char kXcodeExtraAttributes_Help[] =
2363     R"(xcode_extra_attributes: [scope] Extra attributes for Xcode projects.
2364 
2365   The value defined in this scope will be copied to the EXTRA_ATTRIBUTES
2366   property of the generated Xcode project. They are only meaningful when
2367   generating with --ide=xcode.
2368 
2369   See "gn help create_bundle" for more information.
2370 )";
2371 
2372 // -----------------------------------------------------------------------------
2373 
2374 VariableInfo::VariableInfo() : help_short(""), help("") {}
2375 
2376 VariableInfo::VariableInfo(const char* in_help_short, const char* in_help)
2377     : help_short(in_help_short), help(in_help) {}
2378 
2379 #define INSERT_VARIABLE(var) \
2380   info_map[k##var] = VariableInfo(k##var##_HelpShort, k##var##_Help);
2381 
2382 const VariableInfoMap& GetBuiltinVariables() {
2383   static VariableInfoMap info_map;
2384   if (info_map.empty()) {
2385     INSERT_VARIABLE(CurrentCpu)
2386     INSERT_VARIABLE(CurrentOs)
2387     INSERT_VARIABLE(CurrentToolchain)
2388     INSERT_VARIABLE(DefaultToolchain)
2389     INSERT_VARIABLE(GnVersion)
2390     INSERT_VARIABLE(HostCpu)
2391     INSERT_VARIABLE(HostOs)
2392     INSERT_VARIABLE(Invoker)
2393     INSERT_VARIABLE(PythonPath)
2394     INSERT_VARIABLE(RootBuildDir)
2395     INSERT_VARIABLE(RootGenDir)
2396     INSERT_VARIABLE(RootOutDir)
2397     INSERT_VARIABLE(TargetCpu)
2398     INSERT_VARIABLE(TargetGenDir)
2399     INSERT_VARIABLE(TargetName)
2400     INSERT_VARIABLE(TargetOs)
2401     INSERT_VARIABLE(TargetOutDir)
2402   }
2403   return info_map;
2404 }
2405 
2406 const VariableInfoMap& GetTargetVariables() {
2407   static VariableInfoMap info_map;
2408   if (info_map.empty()) {
2409     INSERT_VARIABLE(AllDependentConfigs)
2410     INSERT_VARIABLE(AllowCircularIncludesFrom)
2411     INSERT_VARIABLE(GenDeps)
2412     INSERT_VARIABLE(Arflags)
2413     INSERT_VARIABLE(Args)
2414     INSERT_VARIABLE(Asmflags)
2415     INSERT_VARIABLE(AssertNoDeps)
2416     INSERT_VARIABLE(BundleRootDir)
2417     INSERT_VARIABLE(BundleContentsDir)
2418     INSERT_VARIABLE(BundleResourcesDir)
2419     INSERT_VARIABLE(BundleDepsFilter)
2420     INSERT_VARIABLE(BundleExecutableDir)
2421     INSERT_VARIABLE(XcassetCompilerFlags)
2422     INSERT_VARIABLE(Transparent)
2423     INSERT_VARIABLE(Cflags)
2424     INSERT_VARIABLE(CflagsC)
2425     INSERT_VARIABLE(CflagsCC)
2426     INSERT_VARIABLE(CflagsObjC)
2427     INSERT_VARIABLE(CflagsObjCC)
2428     INSERT_VARIABLE(CheckIncludes)
2429     INSERT_VARIABLE(CodeSigningArgs)
2430     INSERT_VARIABLE(CodeSigningOutputs)
2431     INSERT_VARIABLE(CodeSigningScript)
2432     INSERT_VARIABLE(CodeSigningSources)
2433     INSERT_VARIABLE(CompleteStaticLib)
2434     INSERT_VARIABLE(Configs)
2435     INSERT_VARIABLE(Data)
2436     INSERT_VARIABLE(DataDeps)
2437     INSERT_VARIABLE(DataKeys)
2438     INSERT_VARIABLE(Defines)
2439     INSERT_VARIABLE(Depfile)
2440     INSERT_VARIABLE(Deps)
2441     INSERT_VARIABLE(Mnemonic)
2442     INSERT_VARIABLE(Externs)
2443     INSERT_VARIABLE(Friend)
2444     INSERT_VARIABLE(FrameworkDirs)
2445     INSERT_VARIABLE(Frameworks)
2446     INSERT_VARIABLE(IncludeDirs)
2447     INSERT_VARIABLE(Inputs)
2448     INSERT_VARIABLE(Ldflags)
2449     INSERT_VARIABLE(Libs)
2450     INSERT_VARIABLE(LibDirs)
2451     INSERT_VARIABLE(Metadata)
2452     INSERT_VARIABLE(OutputDir)
2453     INSERT_VARIABLE(OutputExtension)
2454     INSERT_VARIABLE(OutputName)
2455     INSERT_VARIABLE(OutputPrefixOverride)
2456     INSERT_VARIABLE(Outputs)
2457     INSERT_VARIABLE(PartialInfoPlist)
2458     INSERT_VARIABLE(Pool)
2459     INSERT_VARIABLE(PostProcessingArgs)
2460     INSERT_VARIABLE(PostProcessingOutputs)
2461     INSERT_VARIABLE(PostProcessingScript)
2462     INSERT_VARIABLE(PostProcessingSources)
2463     INSERT_VARIABLE(PrecompiledHeader)
2464     INSERT_VARIABLE(PrecompiledHeaderType)
2465     INSERT_VARIABLE(PrecompiledSource)
2466     INSERT_VARIABLE(ProductType)
2467     INSERT_VARIABLE(Public)
2468     INSERT_VARIABLE(PublicConfigs)
2469     INSERT_VARIABLE(PublicDeps)
2470     INSERT_VARIABLE(Rebase)
2471     INSERT_VARIABLE(ResponseFileContents)
2472     INSERT_VARIABLE(Script)
2473     INSERT_VARIABLE(Sources)
2474     INSERT_VARIABLE(Swiftflags)
2475     INSERT_VARIABLE(XcodeTestApplicationName)
2476     INSERT_VARIABLE(Testonly)
2477     INSERT_VARIABLE(Visibility)
2478     INSERT_VARIABLE(WalkKeys)
2479     INSERT_VARIABLE(WeakFrameworks)
2480     INSERT_VARIABLE(WriteOutputConversion)
2481     INSERT_VARIABLE(WriteValueContents)
2482     INSERT_VARIABLE(WriteRuntimeDeps)
2483     INSERT_VARIABLE(XcodeExtraAttributes)
2484     InsertRustVariables(&info_map);
2485     InsertSwiftVariables(&info_map);
2486   }
2487   return info_map;
2488 }
2489 
2490 #undef INSERT_VARIABLE
2491 
2492 }  // namespace variables
2493