| 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 from | 10 Most operations take a build directory. The build arguments are taken from |
| (...skipping 3875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3886 primary object(s) of the build. It will match the OS of the default | 3886 primary object(s) of the build. It will match the OS of the default |
| 3887 toolchain. | 3887 toolchain. |
| 3888 | 3888 |
| 3889 In many cases, this is the same as "host_os", but in the case of | 3889 In many cases, this is the same as "host_os", but in the case of |
| 3890 cross-compiles, it may be different. This variable differs from "current_os" | 3890 cross-compiles, it may be different. This variable differs from "current_os" |
| 3891 in that it can be referenced from inside any toolchain and will always return | 3891 in that it can be referenced from inside any toolchain and will always return |
| 3892 the initial value. | 3892 the initial value. |
| 3893 | 3893 |
| 3894 This should be set to the most specific value possible. So, "android" or | 3894 This should be set to the most specific value possible. So, "android" or |
| 3895 "chromeos" should be used instead of "linux" where applicable, even though | 3895 "chromeos" should be used instead of "linux" where applicable, even though |
| 3896 Android and Chrome OS are both Linux variants. This can mean that one needs to | 3896 Android and ChromeOS are both Linux variants. This can mean that one needs to |
| 3897 write | 3897 write |
| 3898 | 3898 |
| 3899 if (target_os == "android" || target_os == "linux") { | 3899 if (target_os == "android" || target_os == "linux") { |
| 3900 # ... | 3900 # ... |
| 3901 } | 3901 } |
| 3902 | 3902 |
| 3903 and so forth. | 3903 and so forth. |
| 3904 | 3904 |
| 3905 This value is not used internally by GN for any purpose, so it may be set to | 3905 This value is not used internally by GN for any purpose, so it may be set to |
| 3906 whatever value is needed for the build. GN defaults this value to the empty | 3906 whatever value is needed for the build. GN defaults this value to the empty |
| (...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5300 | 5300 |
| 5301 | 5301 |
| 5302 ``` | 5302 ``` |
| 5303 ## **precompiled_header**: [string] Header file to precompile. | 5303 ## **precompiled_header**: [string] Header file to precompile. |
| 5304 | 5304 |
| 5305 ``` | 5305 ``` |
| 5306 Precompiled headers will be used when a target specifies this value, or a | 5306 Precompiled headers will be used when a target specifies this value, or a |
| 5307 config applying to this target specifies this value. In addition, the tool | 5307 config applying to this target specifies this value. In addition, the tool |
| 5308 corresponding to the source files must also specify precompiled headers (see | 5308 corresponding to the source files must also specify precompiled headers (see |
| 5309 "gn help tool"). The tool will also specify what type of precompiled headers | 5309 "gn help tool"). The tool will also specify what type of precompiled headers |
| 5310 to use. | 5310 to use, by setting precompiled_header_type to either "gcc" or "msvc". |
| 5311 | 5311 |
| 5312 The precompiled header/source variables can be specified on a target or a | 5312 The precompiled header/source variables can be specified on a target or a |
| 5313 config, but must be the same for all configs applying to a given target since | 5313 config, but must be the same for all configs applying to a given target since |
| 5314 a target can only have one precompiled header. | 5314 a target can only have one precompiled header. |
| 5315 | 5315 |
| 5316 If you use both C and C++ sources, the precompiled header and source file |
| 5317 will be compiled once per language. You will want to make sure to wrap C++ |
| 5318 includes in __cplusplus #ifdefs so the file will compile in C mode. |
| 5319 |
| 5320 ``` |
| 5321 |
| 5322 ### **GCC precompiled headers** |
| 5323 |
| 5324 ``` |
| 5325 When using GCC-style precompiled headers, "precompiled_source" contains the |
| 5326 path of a .h file that is precompiled and then included by all source files |
| 5327 in targets that set "precompiled_source". |
| 5328 |
| 5329 The value of "precompiled_header" is not used with GCC-style precompiled |
| 5330 headers. |
| 5331 |
| 5316 ``` | 5332 ``` |
| 5317 | 5333 |
| 5318 ### **MSVC precompiled headers** | 5334 ### **MSVC precompiled headers** |
| 5319 | 5335 |
| 5320 ``` | 5336 ``` |
| 5321 When using MSVC-style precompiled headers, the "precompiled_header" value is | 5337 When using MSVC-style precompiled headers, the "precompiled_header" value is |
| 5322 a string corresponding to the header. This is NOT a path to a file that GN | 5338 a string corresponding to the header. This is NOT a path to a file that GN |
| 5323 recognises, but rather the exact string that appears in quotes after an | 5339 recognises, but rather the exact string that appears in quotes after |
| 5324 #include line in source code. The compiler will match this string against | 5340 an #include line in source code. The compiler will match this string against |
| 5325 includes or forced includes (/FI). | 5341 includes or forced includes (/FI). |
| 5326 | 5342 |
| 5327 MSVC also requires a source file to compile the header with. This must be | 5343 MSVC also requires a source file to compile the header with. This must be |
| 5328 specified by the "precompiled_source" value. In contrast to the header value, | 5344 specified by the "precompiled_source" value. In contrast to the header value, |
| 5329 this IS a GN-style file name, and tells GN which source file to compile to | 5345 this IS a GN-style file name, and tells GN which source file to compile to |
| 5330 make the .pch file used for subsequent compiles. | 5346 make the .pch file used for subsequent compiles. |
| 5331 | 5347 |
| 5332 If you use both C and C++ sources, the precompiled header and source file | |
| 5333 will be compiled using both tools. You will want to make sure to wrap C++ | |
| 5334 includes in __cplusplus #ifdefs so the file will compile in C mode. | |
| 5335 | |
| 5336 For example, if the toolchain specifies MSVC headers: | 5348 For example, if the toolchain specifies MSVC headers: |
| 5337 | 5349 |
| 5338 toolchain("vc_x64") { | 5350 toolchain("vc_x64") { |
| 5339 ... | 5351 ... |
| 5340 tool("cxx") { | 5352 tool("cxx") { |
| 5341 precompiled_header_type = "msvc" | 5353 precompiled_header_type = "msvc" |
| 5342 ... | 5354 ... |
| 5343 | 5355 |
| 5344 You might make a config like this: | 5356 You might make a config like this: |
| 5345 | 5357 |
| 5346 config("use_precompiled_headers") { | 5358 config("use_precompiled_headers") { |
| 5347 precompiled_header = "build/precompile.h" | 5359 precompiled_header = "build/precompile.h" |
| 5348 precompiled_source = "//build/precompile.cc" | 5360 precompiled_source = "//build/precompile.cc" |
| 5349 | 5361 |
| 5350 # Either your source files should #include "build/precompile.h" | 5362 # Either your source files should #include "build/precompile.h" |
| 5351 # first, or you can do this to force-include the header. | 5363 # first, or you can do this to force-include the header. |
| 5352 cflags = [ "/FI$precompiled_header" ] | 5364 cflags = [ "/FI$precompiled_header" ] |
| 5353 } | 5365 } |
| 5354 | 5366 |
| 5355 And then define a target that uses the config: | 5367 And then define a target that uses the config: |
| 5356 | 5368 |
| 5357 executable("doom_melon") { | 5369 executable("doom_melon") { |
| 5358 configs += [ ":use_precompiled_headers" ] | 5370 configs += [ ":use_precompiled_headers" ] |
| 5359 ... | 5371 ... |
| 5360 | 5372 |
| 5361 | 5373 |
| 5362 ``` | 5374 ``` |
| 5375 ## **precompiled_header_type**: [string] "gcc" or "msvc". |
| 5376 |
| 5377 ``` |
| 5378 See "gn help precompiled_header". |
| 5379 |
| 5380 |
| 5381 ``` |
| 5363 ## **precompiled_source**: [file name] Source file to precompile. | 5382 ## **precompiled_source**: [file name] Source file to precompile. |
| 5364 | 5383 |
| 5365 ``` | 5384 ``` |
| 5366 The source file that goes along with the precompiled_header when using | 5385 The source file that goes along with the precompiled_header when using |
| 5367 "msvc"-style precompiled headers. It will be implicitly added to the sources | 5386 "msvc"-style precompiled headers. It will be implicitly added to the sources |
| 5368 of the target. See "gn help precompiled_header". | 5387 of the target. See "gn help precompiled_header". |
| 5369 | 5388 |
| 5370 | 5389 |
| 5371 ``` | 5390 ``` |
| 5372 ## **product_type**: Product type for Xcode projects. | 5391 ## **product_type**: Product type for Xcode projects. |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5789 directory. If you want to specify a different file, you can additionally pass | 5808 directory. If you want to specify a different file, you can additionally pass |
| 5790 --dotfile: | 5809 --dotfile: |
| 5791 | 5810 |
| 5792 gn gen out/Debug --root=/home/build --dotfile=/home/my_gn_file.gn | 5811 gn gen out/Debug --root=/home/build --dotfile=/home/my_gn_file.gn |
| 5793 | 5812 |
| 5794 ``` | 5813 ``` |
| 5795 | 5814 |
| 5796 ### **Variables** | 5815 ### **Variables** |
| 5797 | 5816 |
| 5798 ``` | 5817 ``` |
| 5818 arg_file_template [optional] |
| 5819 Path to a file containing the text that should be used as the default |
| 5820 args.gn content when you run `gn args`. |
| 5821 |
| 5799 buildconfig [required] | 5822 buildconfig [required] |
| 5800 Label of the build config file. This file will be used to set up the | 5823 Path to the build config file. This file will be used to set up the |
| 5801 build file execution environment for each toolchain. | 5824 build file execution environment for each toolchain. |
| 5802 | 5825 |
| 5803 check_targets [optional] | 5826 check_targets [optional] |
| 5804 A list of labels and label patterns that should be checked when running | 5827 A list of labels and label patterns that should be checked when running |
| 5805 "gn check" or "gn gen --check". If unspecified, all targets will be | 5828 "gn check" or "gn gen --check". If unspecified, all targets will be |
| 5806 checked. If it is the empty list, no targets will be checked. | 5829 checked. If it is the empty list, no targets will be checked. |
| 5807 | 5830 |
| 5808 The format of this list is identical to that of "visibility" so see "gn | 5831 The format of this list is identical to that of "visibility" so see "gn |
| 5809 help visibility" for examples. | 5832 help visibility" for examples. |
| 5810 | 5833 |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6665 ** \--root**: Explicitly specify source root. | 6688 ** \--root**: Explicitly specify source root. |
| 6666 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. | 6689 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. |
| 6667 ** \--script-executable**: Set the executable used to execute scripts. | 6690 ** \--script-executable**: Set the executable used to execute scripts. |
| 6668 ** \--threads**: Specify number of worker threads. | 6691 ** \--threads**: Specify number of worker threads. |
| 6669 ** \--time**: Outputs a summary of how long everything took. | 6692 ** \--time**: Outputs a summary of how long everything took. |
| 6670 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. | 6693 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. |
| 6671 ** -v**: Verbose logging. | 6694 ** -v**: Verbose logging. |
| 6672 ** \--version**: Prints the GN version number and exits. | 6695 ** \--version**: Prints the GN version number and exits. |
| 6673 | 6696 |
| 6674 ``` | 6697 ``` |
| OLD | NEW |