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 ## Contents | 5 ## Contents |
6 | 6 |
7 * [Commands](#commands) | 7 * [Commands](#commands) |
8 * [analyze: Analyze which targets are affected by a list of files.](#analy
ze) | 8 * [analyze: Analyze which targets are affected by a list of files.](#analy
ze) |
9 * [args: Display or configure arguments declared by the build.](#args) | 9 * [args: Display or configure arguments declared by the build.](#args) |
10 * [check: Check header dependencies.](#check) | 10 * [check: Check header dependencies.](#check) |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 * [cflags_cc: [string list] Flags passed to the C++ compiler.](#cflags_cc) | 89 * [cflags_cc: [string list] Flags passed to the C++ compiler.](#cflags_cc) |
90 * [cflags_objc: [string list] Flags passed to the Objective C compiler.](#
cflags_objc) | 90 * [cflags_objc: [string list] Flags passed to the Objective C compiler.](#
cflags_objc) |
91 * [cflags_objcc: [string list] Flags passed to the Objective C++ compiler.
](#cflags_objcc) | 91 * [cflags_objcc: [string list] Flags passed to the Objective C++ compiler.
](#cflags_objcc) |
92 * [check_includes: [boolean] Controls whether a target's files are checked
.](#check_includes) | 92 * [check_includes: [boolean] Controls whether a target's files are checked
.](#check_includes) |
93 * [code_signing_args: [string list] Arguments passed to code signing scrip
t.](#code_signing_args) | 93 * [code_signing_args: [string list] Arguments passed to code signing scrip
t.](#code_signing_args) |
94 * [code_signing_outputs: [file list] Output files for code signing step.](
#code_signing_outputs) | 94 * [code_signing_outputs: [file list] Output files for code signing step.](
#code_signing_outputs) |
95 * [code_signing_script: [file name] Script for code signing.](#code_signin
g_script) | 95 * [code_signing_script: [file name] Script for code signing.](#code_signin
g_script) |
96 * [code_signing_sources: [file list] Sources for code signing step.](#code
_signing_sources) | 96 * [code_signing_sources: [file list] Sources for code signing step.](#code
_signing_sources) |
97 * [complete_static_lib: [boolean] Links all deps into a static library.](#
complete_static_lib) | 97 * [complete_static_lib: [boolean] Links all deps into a static library.](#
complete_static_lib) |
98 * [configs: [label list] Configs applying to this target or config.](#conf
igs) | 98 * [configs: [label list] Configs applying to this target or config.](#conf
igs) |
99 * [console: [boolean] Run this action in the console pool.](#console) | 99 * [console: [label] Console pool object.](#console) |
100 * [data: [file list] Runtime data file dependencies.](#data) | 100 * [data: [file list] Runtime data file dependencies.](#data) |
101 * [data_deps: [label list] Non-linked dependencies.](#data_deps) | 101 * [data_deps: [label list] Non-linked dependencies.](#data_deps) |
102 * [defines: [string list] C preprocessor defines.](#defines) | 102 * [defines: [string list] C preprocessor defines.](#defines) |
103 * [depfile: [string] File name for input dependencies for actions.](#depfi
le) | 103 * [depfile: [string] File name for input dependencies for actions.](#depfi
le) |
104 * [deps: [label list] Private linked dependencies.](#deps) | 104 * [deps: [label list] Private linked dependencies.](#deps) |
105 * [include_dirs: [directory list] Additional include directories.](#includ
e_dirs) | 105 * [include_dirs: [directory list] Additional include directories.](#includ
e_dirs) |
106 * [inputs: [file list] Additional compile-time dependencies.](#inputs) | 106 * [inputs: [file list] Additional compile-time dependencies.](#inputs) |
107 * [ldflags: [string list] Flags passed to the linker.](#ldflags) | 107 * [ldflags: [string list] Flags passed to the linker.](#ldflags) |
108 * [lib_dirs: [directory list] Additional library directories.](#lib_dirs) | 108 * [lib_dirs: [directory list] Additional library directories.](#lib_dirs) |
109 * [libs: [string list] Additional libraries to link.](#libs) | 109 * [libs: [string list] Additional libraries to link.](#libs) |
110 * [output_dir: [directory] Directory to put output file in.](#output_dir) | 110 * [output_dir: [directory] Directory to put output file in.](#output_dir) |
111 * [output_extension: [string] Value to use for the output's file extension
.](#output_extension) | 111 * [output_extension: [string] Value to use for the output's file extension
.](#output_extension) |
112 * [output_name: [string] Name for the output file other than the default.]
(#output_name) | 112 * [output_name: [string] Name for the output file other than the default.]
(#output_name) |
113 * [output_prefix_override: [boolean] Don't use prefix for output name.](#o
utput_prefix_override) | 113 * [output_prefix_override: [boolean] Don't use prefix for output name.](#o
utput_prefix_override) |
114 * [outputs: [file list] Output files for actions and copy targets.](#outpu
ts) | 114 * [outputs: [file list] Output files for actions and copy targets.](#outpu
ts) |
| 115 * [pool: [string] Label of the pool used by the action.](#pool) |
115 * [precompiled_header: [string] Header file to precompile.](#precompiled_h
eader) | 116 * [precompiled_header: [string] Header file to precompile.](#precompiled_h
eader) |
116 * [precompiled_header_type: [string] "gcc" or "msvc".](#precompiled_header
_type) | 117 * [precompiled_header_type: [string] "gcc" or "msvc".](#precompiled_header
_type) |
117 * [precompiled_source: [file name] Source file to precompile.](#precompile
d_source) | 118 * [precompiled_source: [file name] Source file to precompile.](#precompile
d_source) |
118 * [product_type: [string] Product type for Xcode projects.](#product_type) | 119 * [product_type: [string] Product type for Xcode projects.](#product_type) |
119 * [public: [file list] Declare public header files for a target.](#public) | 120 * [public: [file list] Declare public header files for a target.](#public) |
120 * [public_configs: [label list] Configs applied to dependents.](#public_co
nfigs) | 121 * [public_configs: [label list] Configs applied to dependents.](#public_co
nfigs) |
121 * [public_deps: [label list] Declare public dependencies.](#public_deps) | 122 * [public_deps: [label list] Declare public dependencies.](#public_deps) |
122 * [response_file_contents: [string list] Contents of .rsp file for actions
.](#response_file_contents) | 123 * [response_file_contents: [string list] Contents of .rsp file for actions
.](#response_file_contents) |
123 * [script: [file name] Script file for actions.](#script) | 124 * [script: [file name] Script file for actions.](#script) |
124 * [sources: [file list] Source files for a target.](#sources) | 125 * [sources: [file list] Source files for a target.](#sources) |
(...skipping 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2704 "asm": Assembler | 2705 "asm": Assembler |
2705 | 2706 |
2706 Linker tools: | 2707 Linker tools: |
2707 "alink": Linker for static libraries (archives) | 2708 "alink": Linker for static libraries (archives) |
2708 "solink": Linker for shared libraries | 2709 "solink": Linker for shared libraries |
2709 "link": Linker for executables | 2710 "link": Linker for executables |
2710 | 2711 |
2711 Other tools: | 2712 Other tools: |
2712 "stamp": Tool for creating stamp files | 2713 "stamp": Tool for creating stamp files |
2713 "copy": Tool to copy files. | 2714 "copy": Tool to copy files. |
| 2715 "action": Defaults for actions |
2714 | 2716 |
2715 Platform specific tools: | 2717 Platform specific tools: |
2716 "copy_bundle_data": [iOS, OS X] Tool to copy files in a bundle. | 2718 "copy_bundle_data": [iOS, OS X] Tool to copy files in a bundle. |
2717 "compile_xcassets": [iOS, OS X] Tool to compile asset catalogs. | 2719 "compile_xcassets": [iOS, OS X] Tool to compile asset catalogs. |
2718 ``` | 2720 ``` |
2719 | 2721 |
2720 #### **Tool variables** | 2722 #### **Tool variables** |
2721 | 2723 |
2722 ``` | 2724 ``` |
2723 command [string with substitutions] | 2725 command [string with substitutions] |
2724 Valid for: all tools (required) | 2726 Valid for: all tools except "action" (required) |
2725 | 2727 |
2726 The command to run. | 2728 The command to run. |
2727 | 2729 |
2728 default_output_dir [string with substitutions] | 2730 default_output_dir [string with substitutions] |
2729 Valid for: linker tools | 2731 Valid for: linker tools |
2730 | 2732 |
2731 Default directory name for the output file relative to the | 2733 Default directory name for the output file relative to the |
2732 root_build_dir. It can contain other substitution patterns. This will | 2734 root_build_dir. It can contain other substitution patterns. This will |
2733 be the default value for the {{output_dir}} expansion (discussed below) | 2735 be the default value for the {{output_dir}} expansion (discussed below) |
2734 but will be overridden by the "output_dir" variable in a target, if one | 2736 but will be overridden by the "output_dir" variable in a target, if one |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2814 Example for a linker tool that produces a .dll and a .lib. The use of | 2816 Example for a linker tool that produces a .dll and a .lib. The use of |
2815 {{target_output_name}}, {{output_extension}} and {{output_dir}} allows | 2817 {{target_output_name}}, {{output_extension}} and {{output_dir}} allows |
2816 the target to override these values. | 2818 the target to override these values. |
2817 outputs = [ | 2819 outputs = [ |
2818 "{{output_dir}}/{{target_output_name}}" | 2820 "{{output_dir}}/{{target_output_name}}" |
2819 "{{output_extension}}", | 2821 "{{output_extension}}", |
2820 "{{output_dir}}/{{target_output_name}}.lib", | 2822 "{{output_dir}}/{{target_output_name}}.lib", |
2821 ] | 2823 ] |
2822 | 2824 |
2823 pool [label, optional] | 2825 pool [label, optional] |
| 2826 Valid for: all tools (optional) |
2824 | 2827 |
2825 Label of the pool to use for the tool. Pools are used to limit the | 2828 Label of the pool to use for the tool. Pools are used to limit the |
2826 number of tasks that can execute concurrently during the build. | 2829 number of tasks that can execute concurrently during the build. |
2827 | 2830 |
2828 See also "gn help pool". | 2831 See also "gn help pool". |
2829 | 2832 |
2830 link_output [string with substitutions] | 2833 link_output [string with substitutions] |
2831 depend_output [string with substitutions] | 2834 depend_output [string with substitutions] |
2832 Valid for: "solink" only (optional) | 2835 Valid for: "solink" only (optional) |
2833 | 2836 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2884 | 2887 |
2885 Normally, Ninja will assume that when a tool runs the output be new and | 2888 Normally, Ninja will assume that when a tool runs the output be new and |
2886 downstream dependents must be rebuild. When this is set to trye, Ninja | 2889 downstream dependents must be rebuild. When this is set to trye, Ninja |
2887 can skip rebuilding downstream dependents for input changes that don't | 2890 can skip rebuilding downstream dependents for input changes that don't |
2888 actually affect the output. | 2891 actually affect the output. |
2889 | 2892 |
2890 Example: | 2893 Example: |
2891 restat = true | 2894 restat = true |
2892 | 2895 |
2893 rspfile [string with substitutions] | 2896 rspfile [string with substitutions] |
2894 Valid for: all tools (optional) | 2897 Valid for: all tools except "action" (optional) |
2895 | 2898 |
2896 Name of the response file. If empty, no response file will be | 2899 Name of the response file. If empty, no response file will be |
2897 used. See "rspfile_content". | 2900 used. See "rspfile_content". |
2898 | 2901 |
2899 rspfile_content [string with substitutions] | 2902 rspfile_content [string with substitutions] |
2900 Valid for: all tools (required when "rspfile" is specified) | 2903 Valid for: all tools except "action" (required when "rspfile" is used) |
2901 | 2904 |
2902 The contents to be written to the response file. This may include all | 2905 The contents to be written to the response file. This may include all |
2903 or part of the command to send to the tool which allows you to get | 2906 or part of the command to send to the tool which allows you to get |
2904 around OS command-line length limits. | 2907 around OS command-line length limits. |
2905 | 2908 |
2906 This example adds the inputs and libraries to a response file, but | 2909 This example adds the inputs and libraries to a response file, but |
2907 passes the linker flags directly on the command line: | 2910 passes the linker flags directly on the command line: |
2908 tool("link") { | 2911 tool("link") { |
2909 command = "link -o {{output}} {{ldflags}} @{{output}}.rsp" | 2912 command = "link -o {{output}} {{ldflags}} @{{output}}.rsp" |
2910 rspfile = "{{output}}.rsp" | 2913 rspfile = "{{output}}.rsp" |
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4297 cflags = [ ... ] | 4300 cflags = [ ... ] |
4298 } | 4301 } |
4299 config("default_optimization") { | 4302 config("default_optimization") { |
4300 if (optimize_everything) { | 4303 if (optimize_everything) { |
4301 configs = [ ":super_optimization" ] | 4304 configs = [ ":super_optimization" ] |
4302 } else { | 4305 } else { |
4303 configs = [ ":no_optimization" ] | 4306 configs = [ ":no_optimization" ] |
4304 } | 4307 } |
4305 } | 4308 } |
4306 ``` | 4309 ``` |
4307 ### <a name="console"></a>**console**: Run this action in the console pool. | 4310 ### <a name="console"></a>**console**: Console pool objects. |
4308 | 4311 |
4309 ``` | 4312 ``` |
4310 Boolean. Defaults to false. | 4313 Console pool is a special pool object that uses the built-in ninja "console" |
4311 | 4314 pool. Target using this pool will have access to real stdin and stdout, and |
4312 Actions marked "console = true" will be run in the built-in ninja "console" | 4315 output will not be buffered by ninja. This can be useful for long-running |
4313 pool. They will have access to real stdin and stdout, and output will not be | 4316 actions with progress logs, or actions that require user input. |
4314 buffered by ninja. This can be useful for long-running actions with progress | |
4315 logs, or actions that require user input. | |
4316 | 4317 |
4317 Only one console pool target can run at any one time in Ninja. Refer to the | 4318 Only one console pool target can run at any one time in Ninja. Refer to the |
4318 Ninja documentation on the console pool for more info. | 4319 Ninja documentation on the console pool for more info. |
4319 ``` | 4320 ``` |
4320 | 4321 |
4321 #### **Example** | 4322 #### **Example** |
4322 | 4323 |
4323 ``` | 4324 ``` |
4324 action("long_action_with_progress_logs") { | 4325 action("my_action") { |
4325 console = true | 4326 ... |
| 4327 pool = console |
| 4328 ... |
4326 } | 4329 } |
4327 ``` | 4330 ``` |
4328 ### <a name="data"></a>**data**: Runtime data file dependencies. | 4331 ### <a name="data"></a>**data**: Runtime data file dependencies. |
4329 | 4332 |
4330 ``` | 4333 ``` |
4331 Lists files or directories required to run the given target. These are | 4334 Lists files or directories required to run the given target. These are |
4332 typically data files or directories of data files. The paths are interpreted | 4335 typically data files or directories of data files. The paths are interpreted |
4333 as being relative to the current build file. Since these are runtime | 4336 as being relative to the current build file. Since these are runtime |
4334 dependencies, they do not affect which targets are built or when. To declare | 4337 dependencies, they do not affect which targets are built or when. To declare |
4335 input files to a script, use "inputs". | 4338 input files to a script, use "inputs". |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4863 action_foreach | 4866 action_foreach |
4864 Action_foreach targets must always use source expansions to map input files | 4867 Action_foreach targets must always use source expansions to map input files |
4865 to output files. There can be more than one output, which means that each | 4868 to output files. There can be more than one output, which means that each |
4866 invocation of the script will produce a set of files (presumably based on | 4869 invocation of the script will produce a set of files (presumably based on |
4867 the name of the input file). See "gn help action_foreach". | 4870 the name of the input file). See "gn help action_foreach". |
4868 | 4871 |
4869 action | 4872 action |
4870 Action targets (excluding action_foreach) must list literal output file(s) | 4873 Action targets (excluding action_foreach) must list literal output file(s) |
4871 with no source expansions. See "gn help action". | 4874 with no source expansions. See "gn help action". |
4872 ``` | 4875 ``` |
| 4876 ### <a name="pool"></a>**pool**: Label of the pool used by the action. |
| 4877 |
| 4878 ``` |
| 4879 A fully-qualified label representing the pool that will be used for the |
| 4880 action. Pools are defined using the pool() {...} declaration. |
| 4881 ``` |
| 4882 |
| 4883 #### **Example** |
| 4884 |
| 4885 ``` |
| 4886 action("action") { |
| 4887 pool = "//build:custom_pool" |
| 4888 ... |
| 4889 } |
| 4890 ``` |
4873 ### <a name="precompiled_header"></a>**precompiled_header**: [string] Header fil
e to precompile. | 4891 ### <a name="precompiled_header"></a>**precompiled_header**: [string] Header fil
e to precompile. |
4874 | 4892 |
4875 ``` | 4893 ``` |
4876 Precompiled headers will be used when a target specifies this value, or a | 4894 Precompiled headers will be used when a target specifies this value, or a |
4877 config applying to this target specifies this value. In addition, the tool | 4895 config applying to this target specifies this value. In addition, the tool |
4878 corresponding to the source files must also specify precompiled headers (see | 4896 corresponding to the source files must also specify precompiled headers (see |
4879 "gn help tool"). The tool will also specify what type of precompiled headers | 4897 "gn help tool"). The tool will also specify what type of precompiled headers |
4880 to use, by setting precompiled_header_type to either "gcc" or "msvc". | 4898 to use, by setting precompiled_header_type to either "gcc" or "msvc". |
4881 | 4899 |
4882 The precompiled header/source variables can be specified on a target or a | 4900 The precompiled header/source variables can be specified on a target or a |
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6177 * [--root: Explicitly specify source root.](#--root) | 6195 * [--root: Explicitly specify source root.](#--root) |
6178 * [--runtime-deps-list-file: Save runtime dependencies for targets in file
.](#--runtime-deps-list-file) | 6196 * [--runtime-deps-list-file: Save runtime dependencies for targets in file
.](#--runtime-deps-list-file) |
6179 * [--script-executable: Set the executable used to execute scripts.](#--sc
ript-executable) | 6197 * [--script-executable: Set the executable used to execute scripts.](#--sc
ript-executable) |
6180 * [--threads: Specify number of worker threads.](#--threads) | 6198 * [--threads: Specify number of worker threads.](#--threads) |
6181 * [--time: Outputs a summary of how long everything took.](#--time) | 6199 * [--time: Outputs a summary of how long everything took.](#--time) |
6182 * [--tracelog: Writes a Chrome-compatible trace log to the given file.](#-
-tracelog) | 6200 * [--tracelog: Writes a Chrome-compatible trace log to the given file.](#-
-tracelog) |
6183 * [-v: Verbose logging.](#-v) | 6201 * [-v: Verbose logging.](#-v) |
6184 * [--version: Prints the GN version number and exits.](#--version) | 6202 * [--version: Prints the GN version number and exits.](#--version) |
6185 ``` | 6203 ``` |
6186 | 6204 |
OLD | NEW |