| 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 439 |
| 440 ``` | 440 ``` |
| 441 ## **gn clean <out_dir>** | 441 ## **gn clean <out_dir>** |
| 442 | 442 |
| 443 ``` | 443 ``` |
| 444 Deletes the contents of the output directory except for args.gn and | 444 Deletes the contents of the output directory except for args.gn and |
| 445 creates a Ninja build environment sufficient to regenerate the build. | 445 creates a Ninja build environment sufficient to regenerate the build. |
| 446 | 446 |
| 447 | 447 |
| 448 ``` | 448 ``` |
| 449 ## **gn desc <out_dir> <label or pattern> [<what to show>] [\--blame]** | 449 ## **gn desc <out_dir> <label or pattern> [<what to show>] [\--blame] [\--format
=json]** |
| 450 | 450 |
| 451 ``` | 451 ``` |
| 452 Displays information about a given target or config. The build | 452 Displays information about a given target or config. The build |
| 453 build parameters will be taken for the build in the given <out_dir>. | 453 build parameters will be taken for the build in the given <out_dir>. |
| 454 | 454 |
| 455 The <label or pattern> can be a target label, a config label, or a | 455 The <label or pattern> can be a target label, a config label, or a |
| 456 label pattern (see "gn help label_pattern"). A label pattern will | 456 label pattern (see "gn help label_pattern"). A label pattern will |
| 457 only match targets. | 457 only match targets. |
| 458 | 458 |
| 459 ``` | 459 ``` |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 ``` | 505 ``` |
| 506 --all-toolchains | 506 --all-toolchains |
| 507 Normally only inputs in the default toolchain will be included. | 507 Normally only inputs in the default toolchain will be included. |
| 508 This switch will turn on matching all toolchains. | 508 This switch will turn on matching all toolchains. |
| 509 | 509 |
| 510 For example, a file is in a target might be compiled twice: | 510 For example, a file is in a target might be compiled twice: |
| 511 once in the default toolchain and once in a secondary one. Without | 511 once in the default toolchain and once in a secondary one. Without |
| 512 this flag, only the default toolchain one will be matched by | 512 this flag, only the default toolchain one will be matched by |
| 513 wildcards. With this flag, both will be matched. | 513 wildcards. With this flag, both will be matched. |
| 514 | 514 |
| 515 --format=json |
| 516 Format the output as JSON instead of text. |
| 517 |
| 515 ``` | 518 ``` |
| 516 | 519 |
| 517 ### **Target flags** | 520 ### **Target flags** |
| 518 | 521 |
| 519 ``` | 522 ``` |
| 520 --blame | 523 --blame |
| 521 Used with any value specified on a config, this will name | 524 Used with any value specified on a config, this will name |
| 522 the config that cause that target to get the flag. This doesn't | 525 the config that cause that target to get the flag. This doesn't |
| 523 currently work for libs and lib_dirs because those are inherited | 526 currently work for libs and lib_dirs because those are inherited |
| 524 and are more complicated to figure out the blame (patches | 527 and are more complicated to figure out the blame (patches |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 | 698 |
| 696 --ide=<ide_name> | 699 --ide=<ide_name> |
| 697 Generate files for an IDE. Currently supported values: | 700 Generate files for an IDE. Currently supported values: |
| 698 "eclipse" - Eclipse CDT settings file. | 701 "eclipse" - Eclipse CDT settings file. |
| 699 "vs" - Visual Studio project/solution files. | 702 "vs" - Visual Studio project/solution files. |
| 700 (default Visual Studio version: 2015) | 703 (default Visual Studio version: 2015) |
| 701 "vs2013" - Visual Studio 2013 project/solution files. | 704 "vs2013" - Visual Studio 2013 project/solution files. |
| 702 "vs2015" - Visual Studio 2015 project/solution files. | 705 "vs2015" - Visual Studio 2015 project/solution files. |
| 703 "xcode" - Xcode workspace/solution files. | 706 "xcode" - Xcode workspace/solution files. |
| 704 "qtcreator" - QtCreator project files. | 707 "qtcreator" - QtCreator project files. |
| 708 "json" - JSON file containing target information |
| 705 | 709 |
| 706 --filters=<path_prefixes> | 710 --filters=<path_prefixes> |
| 707 Semicolon-separated list of label patterns used to limit the set | 711 Semicolon-separated list of label patterns used to limit the set |
| 708 of generated projects (see "gn help label_pattern"). Only | 712 of generated projects (see "gn help label_pattern"). Only |
| 709 matching targets and their dependencies will be included in the | 713 matching targets and their dependencies will be included in the |
| 710 solution. Only used for Visual Studio and Xcode. | 714 solution. Only used for Visual Studio, Xcode and JSON. |
| 711 | 715 |
| 712 ``` | 716 ``` |
| 713 | 717 |
| 714 ### **Visual Studio Flags** | 718 ### **Visual Studio Flags** |
| 715 | 719 |
| 716 ``` | 720 ``` |
| 717 --sln=<file_name> | 721 --sln=<file_name> |
| 718 Override default sln file name ("all"). Solution file is written | 722 Override default sln file name ("all"). Solution file is written |
| 719 to the root build directory. | 723 to the root build directory. |
| 720 | 724 |
| 725 --no-deps |
| 726 Don't include targets dependencies to the solution. Changes the |
| 727 way how --filters option works. Only directly matching targets are |
| 728 included. |
| 729 |
| 721 ``` | 730 ``` |
| 722 | 731 |
| 723 ### **Xcode Flags** | 732 ### **Xcode Flags** |
| 724 | 733 |
| 725 ``` | 734 ``` |
| 726 --workspace=<file_name> | 735 --workspace=<file_name> |
| 727 Override defaut workspace file name ("all"). The workspace file | 736 Override defaut workspace file name ("all"). The workspace file |
| 728 is written to the root build directory. | 737 is written to the root build directory. |
| 729 | 738 |
| 730 --ninja-extra-args=<string> | 739 --ninja-extra-args=<string> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 755 ``` | 764 ``` |
| 756 GN DOES NOT generate Eclipse CDT projects. Instead, it generates a | 765 GN DOES NOT generate Eclipse CDT projects. Instead, it generates a |
| 757 settings file which can be imported into an Eclipse CDT project. The | 766 settings file which can be imported into an Eclipse CDT project. The |
| 758 XML file contains a list of include paths and defines. Because GN does | 767 XML file contains a list of include paths and defines. Because GN does |
| 759 not generate a full .cproject definition, it is not possible to | 768 not generate a full .cproject definition, it is not possible to |
| 760 properly define includes/defines for each file individually. | 769 properly define includes/defines for each file individually. |
| 761 Instead, one set of includes/defines is generated for the entire | 770 Instead, one set of includes/defines is generated for the entire |
| 762 project. This works fairly well but may still result in a few indexer | 771 project. This works fairly well but may still result in a few indexer |
| 763 issues here and there. | 772 issues here and there. |
| 764 | 773 |
| 774 ``` |
| 775 |
| 776 ### **Generic JSON Output** |
| 777 |
| 778 ``` |
| 779 Dumps target information to JSON file and optionally invokes python |
| 780 script on generated file. |
| 781 See comments at the beginning of json_project_writer.cc and |
| 782 desc_builder.cc for overview of JSON file format. |
| 783 |
| 784 --json-file-name=<json_file_name> |
| 785 Overrides default file name (project.json) of generated JSON file. |
| 786 |
| 787 --json-ide-script=<path_to_python_script> |
| 788 Executes python script after the JSON file is generated. |
| 789 Path can be project absolute (//), system absolute (/) or |
| 790 relative, in which case the output directory will be base. |
| 791 Path to generated JSON file will be first argument when invoking |
| 792 script. |
| 793 |
| 794 --json-ide-script-args=<argument> |
| 795 Optional second argument that will passed to executed script. |
| 796 |
| 765 | 797 |
| 766 ``` | 798 ``` |
| 767 ## **gn help <anything>** | 799 ## **gn help <anything>** |
| 768 | 800 |
| 769 ``` | 801 ``` |
| 770 Yo dawg, I heard you like help on your help so I put help on the help | 802 Yo dawg, I heard you like help on your help so I put help on the help |
| 771 in the help. | 803 in the help. |
| 772 | 804 |
| 773 You can also use "all" as the parameter to get all help at once. | 805 You can also use "all" as the parameter to get all help at once. |
| 774 | 806 |
| (...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3024 at least one output file. There can be more than one output (a | 3056 at least one output file. There can be more than one output (a |
| 3025 linker might produce a library and an import library, for | 3057 linker might produce a library and an import library, for |
| 3026 example). | 3058 example). |
| 3027 | 3059 |
| 3028 This array just declares to GN what files the tool will | 3060 This array just declares to GN what files the tool will |
| 3029 produce. It is your responsibility to specify the tool command | 3061 produce. It is your responsibility to specify the tool command |
| 3030 that actually produces these files. | 3062 that actually produces these files. |
| 3031 | 3063 |
| 3032 If you specify more than one output for shared library links, | 3064 If you specify more than one output for shared library links, |
| 3033 you should consider setting link_output, depend_output, and | 3065 you should consider setting link_output, depend_output, and |
| 3034 runtime_link_output. Otherwise, the first entry in the | 3066 runtime_outputs. |
| 3035 outputs list should always be the main output which will be | |
| 3036 linked to. | |
| 3037 | 3067 |
| 3038 Example for a compiler tool that produces .obj files: | 3068 Example for a compiler tool that produces .obj files: |
| 3039 outputs = [ | 3069 outputs = [ |
| 3040 "{{source_out_dir}}/{{source_name_part}}.obj" | 3070 "{{source_out_dir}}/{{source_name_part}}.obj" |
| 3041 ] | 3071 ] |
| 3042 | 3072 |
| 3043 Example for a linker tool that produces a .dll and a .lib. The | 3073 Example for a linker tool that produces a .dll and a .lib. The |
| 3044 use of {{target_output_name}}, {{output_extension}} and | 3074 use of {{target_output_name}}, {{output_extension}} and |
| 3045 {{output_dir}} allows the target to override these values. | 3075 {{output_dir}} allows the target to override these values. |
| 3046 outputs = [ | 3076 outputs = [ |
| 3047 "{{output_dir}}/{{target_output_name}}{{output_extension}}", | 3077 "{{output_dir}}/{{target_output_name}}{{output_extension}}", |
| 3048 "{{output_dir}}/{{target_output_name}}.lib", | 3078 "{{output_dir}}/{{target_output_name}}.lib", |
| 3049 ] | 3079 ] |
| 3050 | 3080 |
| 3051 pool [label, optional] | 3081 pool [label, optional] |
| 3052 | 3082 |
| 3053 Label of the pool to use for the tool. Pools are used to limit | 3083 Label of the pool to use for the tool. Pools are used to limit |
| 3054 the number of tasks that can execute concurrently during the | 3084 the number of tasks that can execute concurrently during the |
| 3055 build. | 3085 build. |
| 3056 | 3086 |
| 3057 See also "gn help pool". | 3087 See also "gn help pool". |
| 3058 | 3088 |
| 3059 link_output [string with substitutions] | 3089 link_output [string with substitutions] |
| 3060 depend_output [string with substitutions] | 3090 depend_output [string with substitutions] |
| 3061 runtime_link_output [string with substitutions] | |
| 3062 Valid for: "solink" only (optional) | 3091 Valid for: "solink" only (optional) |
| 3063 | 3092 |
| 3064 These three files specify which of the outputs from the solink | 3093 These two files specify which of the outputs from the solink |
| 3065 tool should be used for linking and dependency tracking. These | 3094 tool should be used for linking and dependency tracking. These |
| 3066 should match entries in the "outputs". If unspecified, the | 3095 should match entries in the "outputs". If unspecified, the |
| 3067 first item in the "outputs" array will be used for all. See | 3096 first item in the "outputs" array will be used for all. See |
| 3068 "Separate linking and dependencies for shared libraries" | 3097 "Separate linking and dependencies for shared libraries" |
| 3069 below for more. If link_output is set but runtime_link_output | 3098 below for more. |
| 3070 is not set, runtime_link_output defaults to link_output. | |
| 3071 | 3099 |
| 3072 On Windows, where the tools produce a .dll shared library and | 3100 On Windows, where the tools produce a .dll shared library and |
| 3073 a .lib import library, you will want the first two to be the | 3101 a .lib import library, you will want the first two to be the |
| 3074 import library and the third one to be the .dll file. | 3102 import library and the third one to be the .dll file. |
| 3075 On Linux, if you're not doing the separate linking/dependency | 3103 On Linux, if you're not doing the separate linking/dependency |
| 3076 optimization, all of these should be the .so output. | 3104 optimization, all of these should be the .so output. |
| 3077 | 3105 |
| 3078 output_prefix [string] | 3106 output_prefix [string] |
| 3079 Valid for: Linker tools (optional) | 3107 Valid for: Linker tools (optional) |
| 3080 | 3108 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3137 allows you to get around OS command-line length limits. | 3165 allows you to get around OS command-line length limits. |
| 3138 | 3166 |
| 3139 This example adds the inputs and libraries to a response file, | 3167 This example adds the inputs and libraries to a response file, |
| 3140 but passes the linker flags directly on the command line: | 3168 but passes the linker flags directly on the command line: |
| 3141 tool("link") { | 3169 tool("link") { |
| 3142 command = "link -o {{output}} {{ldflags}} @{{output}}.rsp" | 3170 command = "link -o {{output}} {{ldflags}} @{{output}}.rsp" |
| 3143 rspfile = "{{output}}.rsp" | 3171 rspfile = "{{output}}.rsp" |
| 3144 rspfile_content = "{{inputs}} {{solibs}} {{libs}}" | 3172 rspfile_content = "{{inputs}} {{solibs}} {{libs}}" |
| 3145 } | 3173 } |
| 3146 | 3174 |
| 3175 runtime_outputs [string list with substitutions] |
| 3176 Valid for: linker tools |
| 3177 |
| 3178 If specified, this list is the subset of the outputs that should |
| 3179 be added to runtime deps (see "gn help runtime_deps"). By |
| 3180 default (if runtime_outputs is empty or unspecified), it will be |
| 3181 the link_output. |
| 3182 |
| 3147 ``` | 3183 ``` |
| 3148 | 3184 |
| 3149 ### **Expansions for tool variables** | 3185 ### **Expansions for tool variables** |
| 3150 | 3186 |
| 3151 ``` | 3187 ``` |
| 3152 All paths are relative to the root build directory, which is the | 3188 All paths are relative to the root build directory, which is the |
| 3153 current directory for running all tools. These expansions are | 3189 current directory for running all tools. These expansions are |
| 3154 available to all tools: | 3190 available to all tools: |
| 3155 | 3191 |
| 3156 {{label}} | 3192 {{label}} |
| (...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6150 targets only. If you need to list a static library as a runtime | 6186 targets only. If you need to list a static library as a runtime |
| 6151 dependency, you can manually compute the .a/.lib file name for the | 6187 dependency, you can manually compute the .a/.lib file name for the |
| 6152 current platform and list it in the "data" list of a target | 6188 current platform and list it in the "data" list of a target |
| 6153 (possibly on the static library target itself). | 6189 (possibly on the static library target itself). |
| 6154 | 6190 |
| 6155 ``` | 6191 ``` |
| 6156 | 6192 |
| 6157 ### **Multiple outputs** | 6193 ### **Multiple outputs** |
| 6158 | 6194 |
| 6159 ``` | 6195 ``` |
| 6160 When a tool produces more than one output, only the first output | 6196 Linker tools can specify which of their outputs should be considered |
| 6161 is considered. For example, a shared library target may produce a | 6197 when computing the runtime deps by setting runtime_outputs. If this |
| 6162 .dll and a .lib file on Windows. Only the .dll file will be considered | 6198 is unset on the tool, the default will be the first output only. |
| 6163 a runtime dependency. This applies only to linker tools. Scripts and | |
| 6164 copy steps with multiple outputs will get all outputs listed. | |
| 6165 | 6199 |
| 6166 | 6200 |
| 6167 ``` | 6201 ``` |
| 6168 ## **How Source Expansion Works** | 6202 ## **How Source Expansion Works** |
| 6169 | 6203 |
| 6170 ``` | 6204 ``` |
| 6171 Source expansion is used for the action_foreach and copy target types | 6205 Source expansion is used for the action_foreach and copy target types |
| 6172 to map source file names to output file names or arguments. | 6206 to map source file names to output file names or arguments. |
| 6173 | 6207 |
| 6174 To perform source expansion in the outputs, GN maps every entry in the | 6208 To perform source expansion in the outputs, GN maps every entry in the |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6302 ** \--root**: Explicitly specify source root. | 6336 ** \--root**: Explicitly specify source root. |
| 6303 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. | 6337 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. |
| 6304 ** \--script-executable**: Set the executable used to execute scripts. | 6338 ** \--script-executable**: Set the executable used to execute scripts. |
| 6305 ** \--threads**: Specify number of worker threads. | 6339 ** \--threads**: Specify number of worker threads. |
| 6306 ** \--time**: Outputs a summary of how long everything took. | 6340 ** \--time**: Outputs a summary of how long everything took. |
| 6307 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. | 6341 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. |
| 6308 ** -v**: Verbose logging. | 6342 ** -v**: Verbose logging. |
| 6309 ** \--version**: Prints the GN version number and exits. | 6343 ** \--version**: Prints the GN version number and exits. |
| 6310 | 6344 |
| 6311 ``` | 6345 ``` |
| OLD | NEW |