| 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 ``` | 318 ``` |
| 319 ## **gn args <out_dir> [\--list] [\--short] [\--args]** | 319 ## **gn args <out_dir> [\--list] [\--short] [\--args]** |
| 320 | 320 |
| 321 ``` | 321 ``` |
| 322 See also "gn help buildargs" for a more high-level overview of how | 322 See also "gn help buildargs" for a more high-level overview of how |
| 323 build arguments work. | 323 build arguments work. |
| 324 | 324 |
| 325 ``` | 325 ``` |
| 326 | 326 |
| 327 ### **Usage** | 327 ### **Usage** |
| 328 |
| 328 ``` | 329 ``` |
| 329 gn args <out_dir> | 330 gn args <out_dir> |
| 330 Open the arguments for the given build directory in an editor (as | 331 Open the arguments for the given build directory in an editor. If the |
| 331 specified by the EDITOR environment variable). If the given build | 332 given build directory doesn't exist, it will be created and an empty args |
| 332 directory doesn't exist, it will be created and an empty args file will | 333 file will be opened in the editor. You would type something like this |
| 333 be opened in the editor. You would type something like this into that | 334 into that file: |
| 334 file: | |
| 335 enable_doom_melon=false | 335 enable_doom_melon=false |
| 336 os="android" | 336 os="android" |
| 337 | 337 |
| 338 To find your editor on Posix, GN will search the environment variables in |
| 339 order: GN_EDITOR, VISUAL, and EDITOR. On Windows GN will open the command |
| 340 associated with .txt files. |
| 341 |
| 338 Note: you can edit the build args manually by editing the file "args.gn" | 342 Note: you can edit the build args manually by editing the file "args.gn" |
| 339 in the build directory and then running "gn gen <out_dir>". | 343 in the build directory and then running "gn gen <out_dir>". |
| 340 | 344 |
| 341 gn args <out_dir> --list[=<exact_arg>] [--short] | 345 gn args <out_dir> --list[=<exact_arg>] [--short] |
| 342 Lists all build arguments available in the current configuration, or, if | 346 Lists all build arguments available in the current configuration, or, if |
| 343 an exact_arg is specified for the list flag, just that one build | 347 an exact_arg is specified for the list flag, just that one build |
| 344 argument. | 348 argument. |
| 345 | 349 |
| 346 The output will list the declaration location, default value, and comment | 350 The output will list the declaration location, current value for the |
| 347 preceeding the declaration. If --short is specified, only the names and | 351 build, default value (if different than the current value), and comment |
| 348 values will be printed. | 352 preceeding the declaration. |
| 349 | 353 |
| 350 If the out_dir is specified, the build configuration will be taken from | 354 If --short is specified, only the names and current values will be |
| 351 that build directory. The reason this is needed is that the definition of | 355 printed. |
| 352 some arguments is dependent on the build configuration, so setting some | |
| 353 values might add, remove, or change the default values for other | |
| 354 arguments. Specifying your exact configuration allows the proper | |
| 355 arguments to be displayed. | |
| 356 | |
| 357 Instead of specifying the out_dir, you can also use the command-line flag | |
| 358 to specify the build configuration: | |
| 359 --args=<exact list of args to use> | |
| 360 | 356 |
| 361 ``` | 357 ``` |
| 362 | 358 |
| 363 ### **Examples** | 359 ### **Examples** |
| 364 | 360 |
| 365 ``` | 361 ``` |
| 366 gn args out/Debug | 362 gn args out/Debug |
| 367 Opens an editor with the args for out/Debug. | 363 Opens an editor with the args for out/Debug. |
| 368 | 364 |
| 369 gn args out/Debug --list --short | 365 gn args out/Debug --list --short |
| (...skipping 5353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5723 ``` | 5719 ``` |
| 5724 First, system default arguments are set based on the current system. The | 5720 First, system default arguments are set based on the current system. The |
| 5725 built-in arguments are: | 5721 built-in arguments are: |
| 5726 - host_cpu | 5722 - host_cpu |
| 5727 - host_os | 5723 - host_os |
| 5728 - current_cpu | 5724 - current_cpu |
| 5729 - current_os | 5725 - current_os |
| 5730 - target_cpu | 5726 - target_cpu |
| 5731 - target_os | 5727 - target_os |
| 5732 | 5728 |
| 5729 Next, project-specific overrides are applied. These are specified inside |
| 5730 the default_args variable of //.gn. See "gn help dotfile" for more. |
| 5731 |
| 5733 If specified, arguments from the --args command line flag are used. If that | 5732 If specified, arguments from the --args command line flag are used. If that |
| 5734 flag is not specified, args from previous builds in the build directory will | 5733 flag is not specified, args from previous builds in the build directory will |
| 5735 be used (this is in the file args.gn in the build directory). | 5734 be used (this is in the file args.gn in the build directory). |
| 5736 | 5735 |
| 5737 Last, for targets being compiled with a non-default toolchain, the toolchain | 5736 Last, for targets being compiled with a non-default toolchain, the toolchain |
| 5738 overrides are applied. These are specified in the toolchain_args section of a | 5737 overrides are applied. These are specified in the toolchain_args section of a |
| 5739 toolchain definition. The use-case for this is that a toolchain may be | 5738 toolchain definition. The use-case for this is that a toolchain may be |
| 5740 building code for a different platform, and that it may want to always | 5739 building code for a different platform, and that it may want to always |
| 5741 specify Posix, for example. See "gn help toolchain" for more. | 5740 specify Posix, for example. See "gn help toolchain" for more. |
| 5742 | 5741 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5838 for a BUILD.gn file (or the build config file discussed above), the file | 5837 for a BUILD.gn file (or the build config file discussed above), the file |
| 5839 will first be looked for in the source root. If it's not found, the | 5838 will first be looked for in the source root. If it's not found, the |
| 5840 secondary source root will be checked (which would contain a parallel | 5839 secondary source root will be checked (which would contain a parallel |
| 5841 directory hierarchy). | 5840 directory hierarchy). |
| 5842 | 5841 |
| 5843 This behavior is intended to be used when BUILD.gn files can't be checked | 5842 This behavior is intended to be used when BUILD.gn files can't be checked |
| 5844 in to certain source directories for whatever reason. | 5843 in to certain source directories for whatever reason. |
| 5845 | 5844 |
| 5846 The secondary source root must be inside the main source tree. | 5845 The secondary source root must be inside the main source tree. |
| 5847 | 5846 |
| 5847 default_args [optional] |
| 5848 Scope containing the default overrides for declared arguments. These |
| 5849 overrides take precedence over the default values specified in the |
| 5850 declare_args() block, but can be overriden using --args or the |
| 5851 args.gn file. |
| 5852 |
| 5853 This is intended to be used when subprojects declare arguments with |
| 5854 default values that need to be changed for whatever reason. |
| 5855 |
| 5848 ``` | 5856 ``` |
| 5849 | 5857 |
| 5850 ### **Example .gn file contents** | 5858 ### **Example .gn file contents** |
| 5851 | 5859 |
| 5852 ``` | 5860 ``` |
| 5853 buildconfig = "//build/config/BUILDCONFIG.gn" | 5861 buildconfig = "//build/config/BUILDCONFIG.gn" |
| 5854 | 5862 |
| 5855 check_targets = [ | 5863 check_targets = [ |
| 5856 "//doom_melon/*", # Check everything in this subtree. | 5864 "//doom_melon/*", # Check everything in this subtree. |
| 5857 "//tools:mind_controlling_ant", # Check this specific target. | 5865 "//tools:mind_controlling_ant", # Check this specific target. |
| 5858 ] | 5866 ] |
| 5859 | 5867 |
| 5860 root = "//:root" | 5868 root = "//:root" |
| 5861 | 5869 |
| 5862 secondary_source = "//build/config/temporary_buildfiles/" | 5870 secondary_source = "//build/config/temporary_buildfiles/" |
| 5863 | 5871 |
| 5872 default_args = { |
| 5873 # Default to release builds for this project. |
| 5874 is_debug = false |
| 5875 is_component_build = false |
| 5876 } |
| 5877 |
| 5864 | 5878 |
| 5865 ``` | 5879 ``` |
| 5866 ## **Build graph and execution overview** | 5880 ## **Build graph and execution overview** |
| 5867 | 5881 |
| 5868 ### **Overall build flow** | 5882 ### **Overall build flow** |
| 5869 | 5883 |
| 5870 ``` | 5884 ``` |
| 5871 1. Look for ".gn" file (see "gn help dotfile") in the current directory and | 5885 1. Look for ".gn" file (see "gn help dotfile") in the current directory and |
| 5872 walk up the directory tree until one is found. Set this directory to be | 5886 walk up the directory tree until one is found. Set this directory to be |
| 5873 the "source root" and interpret this file to find the name of the build | 5887 the "source root" and interpret this file to find the name of the build |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6651 ** \--root**: Explicitly specify source root. | 6665 ** \--root**: Explicitly specify source root. |
| 6652 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. | 6666 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. |
| 6653 ** \--script-executable**: Set the executable used to execute scripts. | 6667 ** \--script-executable**: Set the executable used to execute scripts. |
| 6654 ** \--threads**: Specify number of worker threads. | 6668 ** \--threads**: Specify number of worker threads. |
| 6655 ** \--time**: Outputs a summary of how long everything took. | 6669 ** \--time**: Outputs a summary of how long everything took. |
| 6656 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. | 6670 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. |
| 6657 ** -v**: Verbose logging. | 6671 ** -v**: Verbose logging. |
| 6658 ** \--version**: Prints the GN version number and exits. | 6672 ** \--version**: Prints the GN version number and exits. |
| 6659 | 6673 |
| 6660 ``` | 6674 ``` |
| OLD | NEW |