OLD | NEW |
1 # GN Reference | 1 # GN Reference |
2 | 2 |
3 *This page is automatically generated from* `gn help --markdown all`. | 3 *This page is automatically generated from* `gn help --markdown all`. |
4 | 4 |
5 ## **--args**: Specifies build arguments overrides. | 5 ## **--args**: Specifies build arguments overrides. |
6 | 6 |
7 ``` | 7 ``` |
8 See "gn help buildargs" for an overview of how build arguments work. | 8 See "gn help buildargs" for an overview of how build arguments work. |
9 | 9 |
10 Most operations take a build directory. The build arguments are taken | 10 Most operations take a build directory. The build arguments are taken |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 ### **Examples** | 52 ### **Examples** |
53 | 53 |
54 ``` | 54 ``` |
55 gn gen out/Default --color | 55 gn gen out/Default --color |
56 | 56 |
57 gn gen out/Default --nocolor | 57 gn gen out/Default --nocolor |
58 | 58 |
59 | 59 |
60 ``` | 60 ``` |
61 ## **--dotfile**: override the name of the ".gn" file. | 61 ## **--dotfile**: Override the name of the ".gn" file. |
62 | 62 |
63 ``` | 63 ``` |
64 Normally GN loads the ".gn"file from the source root for some basic | 64 Normally GN loads the ".gn"file from the source root for some basic |
65 configuration (see "gn help dotfile"). This flag allows you to | 65 configuration (see "gn help dotfile"). This flag allows you to |
66 use a different file. | 66 use a different file. |
67 | 67 |
68 Note that this interacts with "--root" in a possibly incorrect way. | 68 Note that this interacts with "--root" in a possibly incorrect way. |
69 It would be nice to test the edge cases and document or fix. | 69 It would be nice to test the edge cases and document or fix. |
70 | 70 |
71 | 71 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 ### **Examples** | 113 ### **Examples** |
114 | 114 |
115 ``` | 115 ``` |
116 gn gen //out/Default --root=/home/baracko/src | 116 gn gen //out/Default --root=/home/baracko/src |
117 | 117 |
118 gn desc //out/Default --root="C:\Users\BObama\My Documents\foo" | 118 gn desc //out/Default --root="C:\Users\BObama\My Documents\foo" |
119 | 119 |
120 | 120 |
121 ``` | 121 ``` |
| 122 ## **--runtime-deps-list-file**: Save runtime dependencies for targets in file. |
| 123 |
| 124 ``` |
| 125 --runtime-deps-list-file=<filename> |
| 126 |
| 127 Where <filename> is a text file consisting of the labels, one per |
| 128 line, of the targets for which runtime dependencies are desired. |
| 129 |
| 130 See "gn help runtime_deps" for a description of how runtime |
| 131 dependencies are computed. |
| 132 |
| 133 ``` |
| 134 |
| 135 ### **Runtime deps output file** |
| 136 |
| 137 ``` |
| 138 For each target requested, GN will write a separate runtime dependency |
| 139 file. The runtime dependency file will be in the output directory |
| 140 alongside the output file of the target, with a ".runtime_deps" |
| 141 extension. For example, if the target "//foo:bar" is listed in the |
| 142 input file, and that target produces an output file "bar.so", GN |
| 143 will create a file "bar.so.runtime_deps" in the build directory. |
| 144 |
| 145 If a source set, action, copy, or group is listed, the runtime deps |
| 146 file will correspond to the .stamp file corresponding to that target. |
| 147 This is probably not useful; the use-case for this feature is |
| 148 generally executable targets. |
| 149 |
| 150 The runtime dependency file will list one file per line, with no |
| 151 escaping. The files will be relative to the root_build_dir. The first |
| 152 line of the file will be the main output file of the target itself |
| 153 (in the above example, "bar.so"). |
| 154 |
| 155 |
| 156 ``` |
122 ## **--time**: Outputs a summary of how long everything took. | 157 ## **--time**: Outputs a summary of how long everything took. |
123 | 158 |
124 ``` | 159 ``` |
125 Hopefully self-explanatory. | 160 Hopefully self-explanatory. |
126 | 161 |
127 ``` | 162 ``` |
128 | 163 |
129 ### **Examples** | 164 ### **Examples** |
130 | 165 |
131 ``` | 166 ``` |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 include_dirs [--blame] | 375 include_dirs [--blame] |
341 cflags [--blame] | 376 cflags [--blame] |
342 cflags_cc [--blame] | 377 cflags_cc [--blame] |
343 cflags_cxx [--blame] | 378 cflags_cxx [--blame] |
344 ldflags [--blame] | 379 ldflags [--blame] |
345 lib_dirs | 380 lib_dirs |
346 libs | 381 libs |
347 Shows the given values taken from the target and all configs | 382 Shows the given values taken from the target and all configs |
348 applying. See "--blame" below. | 383 applying. See "--blame" below. |
349 | 384 |
| 385 runtime_deps |
| 386 Compute all runtime deps for the given target. This is a |
| 387 computed list and does not correspond to any GN variable, unlike |
| 388 most other values here. |
| 389 |
| 390 The output is a list of file names relative to the build |
| 391 directory. See "gn help runtime_deps" for how this is computed. |
| 392 This also works with "--blame" to see the source of the |
| 393 dependency. |
| 394 |
| 395 ``` |
| 396 |
| 397 ### **Shared flags** |
| 398 |
| 399 ``` |
350 --blame | 400 --blame |
351 Used with any value specified by a config, this will name | 401 Used with any value specified by a config, this will name |
352 the config that specified the value. This doesn't currently work | 402 the config that specified the value. This doesn't currently work |
353 for libs and lib_dirs because those are inherited and are more | 403 for libs and lib_dirs because those are inherited and are more |
354 complicated to figure out the blame (patches welcome). | 404 complicated to figure out the blame (patches welcome). |
355 | 405 |
356 ``` | 406 ``` |
357 | 407 |
358 ### **Flags that control how deps are printed** | 408 ### **Flags that control how deps are printed** |
359 | 409 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 606 |
557 gn ls out/Debug "//base/*" --as=output | xargs ninja -C out/Debug | 607 gn ls out/Debug "//base/*" --as=output | xargs ninja -C out/Debug |
558 Builds all targets in //base and all subdirectories. | 608 Builds all targets in //base and all subdirectories. |
559 | 609 |
560 gn ls out/Debug //base --all-toolchains | 610 gn ls out/Debug //base --all-toolchains |
561 Lists all variants of the target //base:base (it may be referenced | 611 Lists all variants of the target //base:base (it may be referenced |
562 in multiple toolchains). | 612 in multiple toolchains). |
563 | 613 |
564 | 614 |
565 ``` | 615 ``` |
| 616 ## **gn path <out_dir> <target_one> <target_two>** |
| 617 |
| 618 ``` |
| 619 Finds paths of dependencies between two targets. Each unique path |
| 620 will be printed in one group, and groups will be separate by newlines. |
| 621 The two targets can appear in either order: paths will be found going |
| 622 in either direction. |
| 623 |
| 624 Each dependency will be annotated with its type. By default, only the |
| 625 first path encountered will be printed, which is not necessarily the |
| 626 shortest path. |
| 627 |
| 628 ``` |
| 629 |
| 630 ### **Options** |
| 631 |
| 632 ``` |
| 633 --all |
| 634 Prints all paths found rather than just the first one. |
| 635 |
| 636 ``` |
| 637 |
| 638 ### **Example** |
| 639 |
| 640 ``` |
| 641 gn path out/Default //base //tools/gn |
| 642 |
| 643 |
| 644 ``` |
566 ## **gn refs <out_dir> (<label_pattern>|<label>|<file>|@<response_file>)* [--all
]** | 645 ## **gn refs <out_dir> (<label_pattern>|<label>|<file>|@<response_file>)* [--all
]** |
567 ``` | 646 ``` |
568 [--all-toolchains] [--as=...] [--testonly=...] [--type=...] | 647 [--all-toolchains] [--as=...] [--testonly=...] [--type=...] |
569 | 648 |
570 Finds reverse dependencies (which targets reference something). The | 649 Finds reverse dependencies (which targets reference something). The |
571 input is a list containing: | 650 input is a list containing: |
572 | 651 |
573 - Target label: The result will be which targets depend on it. | 652 - Target label: The result will be which targets depend on it. |
574 | 653 |
575 - Config label: The result will be which targets list the given | 654 - Config label: The result will be which targets list the given |
576 config in its "configs" or "public_configs" list. | 655 config in its "configs" or "public_configs" list. |
577 | 656 |
578 - Label pattern: The result will be which targets depend on any | 657 - Label pattern: The result will be which targets depend on any |
579 target matching the given pattern. Patterns will not match | 658 target matching the given pattern. Patterns will not match |
580 configs. These are not general regular expressions, see | 659 configs. These are not general regular expressions, see |
581 "gn help label_pattern" for details. | 660 "gn help label_pattern" for details. |
582 | 661 |
583 - File name: The result will be which targets list the given file in | 662 - File name: The result will be which targets list the given file in |
584 its "inputs", "sources", "public", or "data". Any input | 663 its "inputs", "sources", "public", "data", or "outputs". |
585 that does not contain wildcards and does not match a target or a | 664 Any input that does not contain wildcards and does not match a |
586 config will be treated as a file. | 665 target or a config will be treated as a file. |
587 | 666 |
588 - Response file: If the input starts with an "@", it will be | 667 - Response file: If the input starts with an "@", it will be |
589 interpreted as a path to a file containing a list of labels or | 668 interpreted as a path to a file containing a list of labels or |
590 file names, one per line. This allows us to handle long lists | 669 file names, one per line. This allows us to handle long lists |
591 of inputs without worrying about command line limits. | 670 of inputs without worrying about command line limits. |
592 | 671 |
593 ``` | 672 ``` |
594 | 673 |
595 ### **Options** | 674 ### **Options** |
596 | 675 |
(...skipping 2648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3245 static_library("foo") { | 3324 static_library("foo") { |
3246 configs -= "//build:no_rtti" # Don't use the default RTTI config. | 3325 configs -= "//build:no_rtti" # Don't use the default RTTI config. |
3247 configs += ":mysettings" # Add some of our own settings. | 3326 configs += ":mysettings" # Add some of our own settings. |
3248 } | 3327 } |
3249 | 3328 |
3250 | 3329 |
3251 ``` | 3330 ``` |
3252 ## **data**: Runtime data file dependencies. | 3331 ## **data**: Runtime data file dependencies. |
3253 | 3332 |
3254 ``` | 3333 ``` |
3255 Lists files required to run the given target. These are typically | 3334 Lists files or directories required to run the given target. These are |
3256 data files. | 3335 typically data files or directories of data files. The paths are |
| 3336 interpreted as being relative to the current build file. Since these |
| 3337 are runtime dependencies, they do not affect which targets are built |
| 3338 or when. To declare input files to a script, use "inputs". |
3257 | 3339 |
3258 Appearing in the "data" section does not imply any special handling | 3340 Appearing in the "data" section does not imply any special handling |
3259 such as copying them to the output directory. This is just used for | 3341 such as copying them to the output directory. This is just used for |
3260 declaring runtime dependencies. There currently isn't a good use for | 3342 declaring runtime dependencies. Runtime dependencies can be queried |
3261 these but it is envisioned that test data can be listed here for use | 3343 using the "runtime_deps" category of "gn desc" or written during |
3262 running automated tests. | 3344 build generation via "--runtime-deps-list-file". |
3263 | 3345 |
3264 See also "gn help inputs" and "gn help data_deps", both of | 3346 GN doesn't require data files to exist at build-time. So actions that |
3265 which actually affect the build in concrete ways. | 3347 produce files that are in turn runtime dependencies can list those |
| 3348 generated files both in the "outputs" list as well as the "data" |
| 3349 list. |
| 3350 |
| 3351 By convention, directories are be listed with a trailing slash: |
| 3352 data = [ "test/data/" ] |
| 3353 However, no verification is done on these so GN doesn't enforce this. |
| 3354 The paths are just rebased and passed along when requested. |
| 3355 |
| 3356 See "gn help runtime_deps" for how these are used. |
3266 | 3357 |
3267 | 3358 |
3268 ``` | 3359 ``` |
3269 ## **data_deps**: Non-linked dependencies. | 3360 ## **data_deps**: Non-linked dependencies. |
3270 | 3361 |
3271 ``` | 3362 ``` |
3272 A list of target labels. | 3363 A list of target labels. |
3273 | 3364 |
3274 Specifies dependencies of a target that are not actually linked into | 3365 Specifies dependencies of a target that are not actually linked into |
3275 the current target. Such dependencies will built and will be available | 3366 the current target. Such dependencies will built and will be available |
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4284 ":*(//build/toolchain/linux:32bit)" | 4375 ":*(//build/toolchain/linux:32bit)" |
4285 All targets in the current build file using the 32-bit Linux | 4376 All targets in the current build file using the 32-bit Linux |
4286 toolchain. | 4377 toolchain. |
4287 | 4378 |
4288 "//foo/*(//build/toolchain:win)" | 4379 "//foo/*(//build/toolchain:win)" |
4289 All targets in //foo and any subdirectory using the Windows | 4380 All targets in //foo and any subdirectory using the Windows |
4290 toolchain. | 4381 toolchain. |
4291 | 4382 |
4292 | 4383 |
4293 ``` | 4384 ``` |
| 4385 ## **Runtime dependencies** |
| 4386 |
| 4387 ``` |
| 4388 Runtime dependencies of a target are exposed via the "runtime_deps" |
| 4389 category of "gn desc" (see "gn help desc") or they can be written |
| 4390 at build generation time via "--runtime-deps-list-file" |
| 4391 (see "gn help --runtime-deps-list-file"). |
| 4392 |
| 4393 To a first approximation, the runtime dependencies of a target are |
| 4394 the set of "data" files, data directories, and the shared libraries |
| 4395 from all transitive dependencies. Executables and shared libraries are |
| 4396 considered runtime dependencies of themselves. |
| 4397 |
| 4398 ``` |
| 4399 |
| 4400 ### **Details** |
| 4401 |
| 4402 ``` |
| 4403 Executable targets and those executable targets' transitive |
| 4404 dependencies are not considered unless that executable is listed in |
| 4405 "data_deps". Otherwise, GN assumes that the executable (and |
| 4406 everything it requires) is a build-time dependency only. |
| 4407 |
| 4408 Action and copy targets that are listed as "data_deps" will have all |
| 4409 of their outputs and data files considered as runtime dependencies. |
| 4410 Action and copy targets that are "deps" or "public_deps" will have |
| 4411 only their data files considered as runtime dependencies. These |
| 4412 targets can list an output file in both the "outputs" and "data" |
| 4413 lists to force an output file as a runtime dependency in all cases. |
| 4414 |
| 4415 The results of static_library or source_set targets are not considered |
| 4416 runtime dependencies since these are assumed to be intermediate |
| 4417 targets only. If you need to list a static library as a runtime |
| 4418 dependency, you can manually compute the .a/.lib file name for the |
| 4419 current platform and list it in the "data" list of a target |
| 4420 (possibly on the static library target itself). |
| 4421 |
| 4422 When a tool produces more than one output, only the first output |
| 4423 is considered. For example, a shared library target may produce a |
| 4424 .dll and a .lib file on Windows. Only the .dll file will be considered |
| 4425 a runtime dependency. |
| 4426 |
| 4427 |
| 4428 ``` |
4294 ## **How Source Expansion Works** | 4429 ## **How Source Expansion Works** |
4295 | 4430 |
4296 ``` | 4431 ``` |
4297 Source expansion is used for the action_foreach and copy target types | 4432 Source expansion is used for the action_foreach and copy target types |
4298 to map source file names to output file names or arguments. | 4433 to map source file names to output file names or arguments. |
4299 | 4434 |
4300 To perform source expansion in the outputs, GN maps every entry in the | 4435 To perform source expansion in the outputs, GN maps every entry in the |
4301 sources to every entry in the outputs list, producing the cross | 4436 sources to every entry in the outputs list, producing the cross |
4302 product of all combinations, expanding placeholders (see below). | 4437 product of all combinations, expanding placeholders (see below). |
4303 | 4438 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4409 ``` | 4544 ``` |
4410 **Available global switches | 4545 **Available global switches |
4411 ** Do "gn help --the_switch_you_want_help_on" for more. Individual | 4546 ** Do "gn help --the_switch_you_want_help_on" for more. Individual |
4412 commands may take command-specific switches not listed here. See the | 4547 commands may take command-specific switches not listed here. See the |
4413 help on your specific command for more. | 4548 help on your specific command for more. |
4414 | 4549 |
4415 ``` | 4550 ``` |
4416 | 4551 |
4417 ** --args**: Specifies build arguments overrides. | 4552 ** --args**: Specifies build arguments overrides. |
4418 ** --color**: Force colored output. | 4553 ** --color**: Force colored output. |
4419 ** --dotfile**: override the name of the ".gn" file. | 4554 ** --dotfile**: Override the name of the ".gn" file. |
4420 ** --markdown**: write the output in the Markdown format. | 4555 ** --markdown**: write the output in the Markdown format. |
4421 ** --nocolor**: Force non-colored output. | 4556 ** --nocolor**: Force non-colored output. |
4422 ** -q**: Quiet mode. Don't print output on success. | 4557 ** -q**: Quiet mode. Don't print output on success. |
4423 ** --root**: Explicitly specify source root. | 4558 ** --root**: Explicitly specify source root. |
| 4559 ** --runtime-deps-list-file**: Save runtime dependencies for targets in file. |
4424 ** --time**: Outputs a summary of how long everything took. | 4560 ** --time**: Outputs a summary of how long everything took. |
4425 ** --tracelog**: Writes a Chrome-compatible trace log to the given file. | 4561 ** --tracelog**: Writes a Chrome-compatible trace log to the given file. |
4426 ** -v**: Verbose logging. | 4562 ** -v**: Verbose logging. |
4427 ** --version**: Prints the GN version number and exits. | 4563 ** --version**: Prints the GN version number and exits. |
4428 | 4564 |
4429 ``` | 4565 ``` |
OLD | NEW |