| 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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 #### **Examples** | 591 #### **Examples** |
| 592 ``` | 592 ``` |
| 593 gn format //some/BUILD.gn | 593 gn format //some/BUILD.gn |
| 594 gn format some\\BUILD.gn | 594 gn format some\\BUILD.gn |
| 595 gn format /abspath/some/BUILD.gn | 595 gn format /abspath/some/BUILD.gn |
| 596 gn format --stdin | 596 gn format --stdin |
| 597 ``` | 597 ``` |
| 598 ### <a name="gen:"></a>**gn gen**: Generate ninja files. | 598 ### <a name="gen:"></a>**gn gen**: Generate ninja files. |
| 599 | 599 |
| 600 ``` | 600 ``` |
| 601 gn gen [<ide options>] <out_dir> | 601 gn gen [--check] [<ide options>] <out_dir> |
| 602 | 602 |
| 603 Generates ninja files from the current tree and puts them in the given output | 603 Generates ninja files from the current tree and puts them in the given output |
| 604 directory. | 604 directory. |
| 605 | 605 |
| 606 The output directory can be a source-repo-absolute path name such as: | 606 The output directory can be a source-repo-absolute path name such as: |
| 607 //out/foo | 607 //out/foo |
| 608 Or it can be a directory relative to the current directory such as: | 608 Or it can be a directory relative to the current directory such as: |
| 609 out/foo | 609 out/foo |
| 610 | 610 |
| 611 "gn gen --check" is the same as running "gn check". See "gn help check" |
| 612 for documentation on that mode. |
| 613 |
| 611 See "gn help switches" for the common command-line switches. | 614 See "gn help switches" for the common command-line switches. |
| 612 ``` | 615 ``` |
| 613 | 616 |
| 614 #### **IDE options** | 617 #### **IDE options** |
| 615 | 618 |
| 616 ``` | 619 ``` |
| 617 GN optionally generates files for IDE. Possibilities for <ide options> | 620 GN optionally generates files for IDE. Possibilities for <ide options> |
| 618 | 621 |
| 619 --ide=<ide_name> | 622 --ide=<ide_name> |
| 620 Generate files for an IDE. Currently supported values: | 623 Generate files for an IDE. Currently supported values: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 638 #### **Visual Studio Flags** | 641 #### **Visual Studio Flags** |
| 639 | 642 |
| 640 ``` | 643 ``` |
| 641 --sln=<file_name> | 644 --sln=<file_name> |
| 642 Override default sln file name ("all"). Solution file is written to the | 645 Override default sln file name ("all"). Solution file is written to the |
| 643 root build directory. | 646 root build directory. |
| 644 | 647 |
| 645 --no-deps | 648 --no-deps |
| 646 Don't include targets dependencies to the solution. Changes the way how | 649 Don't include targets dependencies to the solution. Changes the way how |
| 647 --filters option works. Only directly matching targets are included. | 650 --filters option works. Only directly matching targets are included. |
| 651 |
| 652 --winsdk=<sdk_version> |
| 653 Use the specified Windows 10 SDK version to generate project files. |
| 654 As an example, "10.0.15063.0" can be specified to use Creators Update SDK |
| 655 instead of the default one. |
| 648 ``` | 656 ``` |
| 649 | 657 |
| 650 #### **Xcode Flags** | 658 #### **Xcode Flags** |
| 651 | 659 |
| 652 ``` | 660 ``` |
| 653 --workspace=<file_name> | 661 --workspace=<file_name> |
| 654 Override defaut workspace file name ("all"). The workspace file is | 662 Override defaut workspace file name ("all"). The workspace file is |
| 655 written to the root build directory. | 663 written to the root build directory. |
| 656 | 664 |
| 657 --ninja-extra-args=<string> | 665 --ninja-extra-args=<string> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 681 a list of include paths and defines. Because GN does not generate a full | 689 a list of include paths and defines. Because GN does not generate a full |
| 682 .cproject definition, it is not possible to properly define includes/defines | 690 .cproject definition, it is not possible to properly define includes/defines |
| 683 for each file individually. Instead, one set of includes/defines is generated | 691 for each file individually. Instead, one set of includes/defines is generated |
| 684 for the entire project. This works fairly well but may still result in a few | 692 for the entire project. This works fairly well but may still result in a few |
| 685 indexer issues here and there. | 693 indexer issues here and there. |
| 686 ``` | 694 ``` |
| 687 | 695 |
| 688 #### **Generic JSON Output** | 696 #### **Generic JSON Output** |
| 689 | 697 |
| 690 ``` | 698 ``` |
| 691 Dumps target information to JSON file and optionally invokes python script on | 699 Dumps target information to a JSON file and optionally invokes a |
| 692 generated file. See comments at the beginning of json_project_writer.cc and | 700 python script on the generated file. See the comments at the beginning |
| 693 desc_builder.cc for overview of JSON file format. | 701 of json_project_writer.cc and desc_builder.cc for an overview of the JSON |
| 702 file format. |
| 694 | 703 |
| 695 --json-file-name=<json_file_name> | 704 --json-file-name=<json_file_name> |
| 696 Overrides default file name (project.json) of generated JSON file. | 705 Overrides default file name (project.json) of generated JSON file. |
| 697 | 706 |
| 698 --json-ide-script=<path_to_python_script> | 707 --json-ide-script=<path_to_python_script> |
| 699 Executes python script after the JSON file is generated. Path can be | 708 Executes python script after the JSON file is generated. Path can be |
| 700 project absolute (//), system absolute (/) or relative, in which case the | 709 project absolute (//), system absolute (/) or relative, in which case the |
| 701 output directory will be base. Path to generated JSON file will be first | 710 output directory will be base. Path to generated JSON file will be first |
| 702 argument when invoking script. | 711 argument when invoking script. |
| 703 | 712 |
| (...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 The label of the toolchain. This will match the value of the | 1934 The label of the toolchain. This will match the value of the |
| 1926 "current_toolchain" variable when inside that target's declaration. | 1935 "current_toolchain" variable when inside that target's declaration. |
| 1927 ``` | 1936 ``` |
| 1928 | 1937 |
| 1929 #### **Examples** | 1938 #### **Examples** |
| 1930 | 1939 |
| 1931 ``` | 1940 ``` |
| 1932 get_label_info(":foo", "name") | 1941 get_label_info(":foo", "name") |
| 1933 # Returns string "foo". | 1942 # Returns string "foo". |
| 1934 | 1943 |
| 1935 get_label_info("//foo/bar:baz", "gen_dir") | 1944 get_label_info("//foo/bar:baz", "target_gen_dir") |
| 1936 # Returns string "//out/Debug/gen/foo/bar". | 1945 # Returns string "//out/Debug/gen/foo/bar". |
| 1937 ``` | 1946 ``` |
| 1938 ### <a name="get_path_info"></a>**get_path_info**: Extract parts of a file or di
rectory name. | 1947 ### <a name="get_path_info"></a>**get_path_info**: Extract parts of a file or di
rectory name. |
| 1939 | 1948 |
| 1940 ``` | 1949 ``` |
| 1941 get_path_info(input, what) | 1950 get_path_info(input, what) |
| 1942 | 1951 |
| 1943 The first argument is either a string representing a file or directory name, | 1952 The first argument is either a string representing a file or directory name, |
| 1944 or a list of such strings. If the input is a list the return value will be a | 1953 or a list of such strings. If the input is a list the return value will be a |
| 1945 list containing the result of applying the rule to each item in the input. | 1954 list containing the result of applying the rule to each item in the input. |
| (...skipping 3405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5351 exec_script_whitelist = [ | 5360 exec_script_whitelist = [ |
| 5352 "//base/BUILD.gn", | 5361 "//base/BUILD.gn", |
| 5353 "//build/my_config.gni", | 5362 "//build/my_config.gni", |
| 5354 ] | 5363 ] |
| 5355 | 5364 |
| 5356 root [optional] | 5365 root [optional] |
| 5357 Label of the root build target. The GN build will start by loading the | 5366 Label of the root build target. The GN build will start by loading the |
| 5358 build file containing this target name. This defaults to "//:" which will | 5367 build file containing this target name. This defaults to "//:" which will |
| 5359 cause the file //BUILD.gn to be loaded. | 5368 cause the file //BUILD.gn to be loaded. |
| 5360 | 5369 |
| 5370 script_executable [optional] |
| 5371 Path to specific Python executable or potentially a different language |
| 5372 interpreter that is used to execute scripts in action targets and |
| 5373 exec_script calls. |
| 5374 |
| 5361 secondary_source [optional] | 5375 secondary_source [optional] |
| 5362 Label of an alternate directory tree to find input files. When searching | 5376 Label of an alternate directory tree to find input files. When searching |
| 5363 for a BUILD.gn file (or the build config file discussed above), the file | 5377 for a BUILD.gn file (or the build config file discussed above), the file |
| 5364 will first be looked for in the source root. If it's not found, the | 5378 will first be looked for in the source root. If it's not found, the |
| 5365 secondary source root will be checked (which would contain a parallel | 5379 secondary source root will be checked (which would contain a parallel |
| 5366 directory hierarchy). | 5380 directory hierarchy). |
| 5367 | 5381 |
| 5368 This behavior is intended to be used when BUILD.gn files can't be checked | 5382 This behavior is intended to be used when BUILD.gn files can't be checked |
| 5369 in to certain source directories for whatever reason. | 5383 in to certain source directories for whatever reason. |
| 5370 | 5384 |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6147 * [--root: Explicitly specify source root.](#--root) | 6161 * [--root: Explicitly specify source root.](#--root) |
| 6148 * [--runtime-deps-list-file: Save runtime dependencies for targets in file
.](#--runtime-deps-list-file) | 6162 * [--runtime-deps-list-file: Save runtime dependencies for targets in file
.](#--runtime-deps-list-file) |
| 6149 * [--script-executable: Set the executable used to execute scripts.](#--sc
ript-executable) | 6163 * [--script-executable: Set the executable used to execute scripts.](#--sc
ript-executable) |
| 6150 * [--threads: Specify number of worker threads.](#--threads) | 6164 * [--threads: Specify number of worker threads.](#--threads) |
| 6151 * [--time: Outputs a summary of how long everything took.](#--time) | 6165 * [--time: Outputs a summary of how long everything took.](#--time) |
| 6152 * [--tracelog: Writes a Chrome-compatible trace log to the given file.](#-
-tracelog) | 6166 * [--tracelog: Writes a Chrome-compatible trace log to the given file.](#-
-tracelog) |
| 6153 * [-v: Verbose logging.](#-v) | 6167 * [-v: Verbose logging.](#-v) |
| 6154 * [--version: Prints the GN version number and exits.](#--version) | 6168 * [--version: Prints the GN version number and exits.](#--version) |
| 6155 ``` | 6169 ``` |
| 6156 | 6170 |
| OLD | NEW |