Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: tools/gn/docs/reference.md

Issue 2926013002: Support explicit pools in actions (Closed)
Patch Set: Update reference Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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: [boolean] Use console pool for the 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)
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 a list of include paths and defines. Because GN does not generate a full 684 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 685 .cproject definition, it is not possible to properly define includes/defines
683 for each file individually. Instead, one set of includes/defines is generated 686 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 687 for the entire project. This works fairly well but may still result in a few
685 indexer issues here and there. 688 indexer issues here and there.
686 ``` 689 ```
687 690
688 #### **Generic JSON Output** 691 #### **Generic JSON Output**
689 692
690 ``` 693 ```
691 Dumps target information to JSON file and optionally invokes python script on 694 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 695 python script on the generated file. See the comments at the beginning
693 desc_builder.cc for overview of JSON file format. 696 of json_project_writer.cc and desc_builder.cc for an overview of the JSON
697 file format.
694 698
695 --json-file-name=<json_file_name> 699 --json-file-name=<json_file_name>
696 Overrides default file name (project.json) of generated JSON file. 700 Overrides default file name (project.json) of generated JSON file.
697 701
698 --json-ide-script=<path_to_python_script> 702 --json-ide-script=<path_to_python_script>
699 Executes python script after the JSON file is generated. Path can be 703 Executes python script after the JSON file is generated. Path can be
700 project absolute (//), system absolute (/) or relative, in which case the 704 project absolute (//), system absolute (/) or relative, in which case the
701 output directory will be base. Path to generated JSON file will be first 705 output directory will be base. Path to generated JSON file will be first
702 argument when invoking script. 706 argument when invoking script.
703 707
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 2135
2132 ``` 2136 ```
2133 Pool objects can be applied to a tool to limit the parallelism of the 2137 Pool objects can be applied to a tool to limit the parallelism of the
2134 build. This object has a single property "depth" corresponding to 2138 build. This object has a single property "depth" corresponding to
2135 the number of tasks that may run simultaneously. 2139 the number of tasks that may run simultaneously.
2136 2140
2137 As the file containing the pool definition may be executed in the 2141 As the file containing the pool definition may be executed in the
2138 context of more than one toolchain it is recommended to specify an 2142 context of more than one toolchain it is recommended to specify an
2139 explicit toolchain when defining and referencing a pool. 2143 explicit toolchain when defining and referencing a pool.
2140 2144
2145 A pool marked "console = true" will use the built-in ninja "console"
2146 pool and cannot specify "depth" which is always 1.
2147
2141 A pool is referenced by its label just like a target. 2148 A pool is referenced by its label just like a target.
2142 ``` 2149 ```
2143 2150
2144 #### **Variables** 2151 #### **Variables**
2145 2152
2146 ``` 2153 ```
2147 depth* 2154 console, depth*
2148 * = required 2155 * = required
2149 ``` 2156 ```
2150 2157
2151 #### **Example** 2158 #### **Example**
2152 2159
2153 ``` 2160 ```
2154 if (current_toolchain == default_toolchain) { 2161 if (current_toolchain == default_toolchain) {
2155 pool("link_pool") { 2162 pool("link_pool") {
2156 depth = 1 2163 depth = 1
2157 } 2164 }
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 "asm": Assembler 2686 "asm": Assembler
2680 2687
2681 Linker tools: 2688 Linker tools:
2682 "alink": Linker for static libraries (archives) 2689 "alink": Linker for static libraries (archives)
2683 "solink": Linker for shared libraries 2690 "solink": Linker for shared libraries
2684 "link": Linker for executables 2691 "link": Linker for executables
2685 2692
2686 Other tools: 2693 Other tools:
2687 "stamp": Tool for creating stamp files 2694 "stamp": Tool for creating stamp files
2688 "copy": Tool to copy files. 2695 "copy": Tool to copy files.
2696 "action": Defaults for actions
2689 2697
2690 Platform specific tools: 2698 Platform specific tools:
2691 "copy_bundle_data": [iOS, OS X] Tool to copy files in a bundle. 2699 "copy_bundle_data": [iOS, OS X] Tool to copy files in a bundle.
2692 "compile_xcassets": [iOS, OS X] Tool to compile asset catalogs. 2700 "compile_xcassets": [iOS, OS X] Tool to compile asset catalogs.
2693 ``` 2701 ```
2694 2702
2695 #### **Tool variables** 2703 #### **Tool variables**
2696 2704
2697 ``` 2705 ```
2698 command [string with substitutions] 2706 command [string with substitutions]
2699 Valid for: all tools (required) 2707 Valid for: all tools except "action" (required)
2700 2708
2701 The command to run. 2709 The command to run.
2702 2710
2703 default_output_dir [string with substitutions] 2711 default_output_dir [string with substitutions]
2704 Valid for: linker tools 2712 Valid for: linker tools
2705 2713
2706 Default directory name for the output file relative to the 2714 Default directory name for the output file relative to the
2707 root_build_dir. It can contain other substitution patterns. This will 2715 root_build_dir. It can contain other substitution patterns. This will
2708 be the default value for the {{output_dir}} expansion (discussed below) 2716 be the default value for the {{output_dir}} expansion (discussed below)
2709 but will be overridden by the "output_dir" variable in a target, if one 2717 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
2789 Example for a linker tool that produces a .dll and a .lib. The use of 2797 Example for a linker tool that produces a .dll and a .lib. The use of
2790 {{target_output_name}}, {{output_extension}} and {{output_dir}} allows 2798 {{target_output_name}}, {{output_extension}} and {{output_dir}} allows
2791 the target to override these values. 2799 the target to override these values.
2792 outputs = [ 2800 outputs = [
2793 "{{output_dir}}/{{target_output_name}}" 2801 "{{output_dir}}/{{target_output_name}}"
2794 "{{output_extension}}", 2802 "{{output_extension}}",
2795 "{{output_dir}}/{{target_output_name}}.lib", 2803 "{{output_dir}}/{{target_output_name}}.lib",
2796 ] 2804 ]
2797 2805
2798 pool [label, optional] 2806 pool [label, optional]
2807 Valid for: all tools (optional)
2799 2808
2800 Label of the pool to use for the tool. Pools are used to limit the 2809 Label of the pool to use for the tool. Pools are used to limit the
2801 number of tasks that can execute concurrently during the build. 2810 number of tasks that can execute concurrently during the build.
2802 2811
2803 See also "gn help pool". 2812 See also "gn help pool".
2804 2813
2805 link_output [string with substitutions] 2814 link_output [string with substitutions]
2806 depend_output [string with substitutions] 2815 depend_output [string with substitutions]
2807 Valid for: "solink" only (optional) 2816 Valid for: "solink" only (optional)
2808 2817
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 2868
2860 Normally, Ninja will assume that when a tool runs the output be new and 2869 Normally, Ninja will assume that when a tool runs the output be new and
2861 downstream dependents must be rebuild. When this is set to trye, Ninja 2870 downstream dependents must be rebuild. When this is set to trye, Ninja
2862 can skip rebuilding downstream dependents for input changes that don't 2871 can skip rebuilding downstream dependents for input changes that don't
2863 actually affect the output. 2872 actually affect the output.
2864 2873
2865 Example: 2874 Example:
2866 restat = true 2875 restat = true
2867 2876
2868 rspfile [string with substitutions] 2877 rspfile [string with substitutions]
2869 Valid for: all tools (optional) 2878 Valid for: all tools except "action" (optional)
2870 2879
2871 Name of the response file. If empty, no response file will be 2880 Name of the response file. If empty, no response file will be
2872 used. See "rspfile_content". 2881 used. See "rspfile_content".
2873 2882
2874 rspfile_content [string with substitutions] 2883 rspfile_content [string with substitutions]
2875 Valid for: all tools (required when "rspfile" is specified) 2884 Valid for: all tools except "action" (required when "rspfile" is used)
2876 2885
2877 The contents to be written to the response file. This may include all 2886 The contents to be written to the response file. This may include all
2878 or part of the command to send to the tool which allows you to get 2887 or part of the command to send to the tool which allows you to get
2879 around OS command-line length limits. 2888 around OS command-line length limits.
2880 2889
2881 This example adds the inputs and libraries to a response file, but 2890 This example adds the inputs and libraries to a response file, but
2882 passes the linker flags directly on the command line: 2891 passes the linker flags directly on the command line:
2883 tool("link") { 2892 tool("link") {
2884 command = "link -o {{output}} {{ldflags}} @{{output}}.rsp" 2893 command = "link -o {{output}} {{ldflags}} @{{output}}.rsp"
2885 rspfile = "{{output}}.rsp" 2894 rspfile = "{{output}}.rsp"
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after
4272 cflags = [ ... ] 4281 cflags = [ ... ]
4273 } 4282 }
4274 config("default_optimization") { 4283 config("default_optimization") {
4275 if (optimize_everything) { 4284 if (optimize_everything) {
4276 configs = [ ":super_optimization" ] 4285 configs = [ ":super_optimization" ]
4277 } else { 4286 } else {
4278 configs = [ ":no_optimization" ] 4287 configs = [ ":no_optimization" ]
4279 } 4288 }
4280 } 4289 }
4281 ``` 4290 ```
4282 ### <a name="console"></a>**console**: Run this action in the console pool. 4291 ### <a name="console"></a>**console**: Use console pool for the pool object.
4283 4292
4284 ``` 4293 ```
4285 Boolean. Defaults to false. 4294 Boolean. Defaults to false.
4286 4295
4287 Actions marked "console = true" will be run in the built-in ninja "console" 4296 Pool objects marked "console = true" will use the built-in ninja "console"
4288 pool. They will have access to real stdin and stdout, and output will not be 4297 pool. They will have access to real stdin and stdout, and output will not be
4289 buffered by ninja. This can be useful for long-running actions with progress 4298 buffered by ninja. This can be useful for long-running actions with progress
4290 logs, or actions that require user input. 4299 logs, or actions that require user input.
4291 4300
4292 Only one console pool target can run at any one time in Ninja. Refer to the 4301 Only one console pool target can run at any one time in Ninja. Refer to the
4293 Ninja documentation on the console pool for more info. 4302 Ninja documentation on the console pool for more info.
4294 ``` 4303 ```
4295 4304
4296 #### **Example** 4305 #### **Example**
4297 4306
4298 ``` 4307 ```
4299 action("long_action_with_progress_logs") { 4308 pool("action_pool") {
4300 console = true 4309 console = true
4301 } 4310 }
4302 ``` 4311 ```
4303 ### <a name="data"></a>**data**: Runtime data file dependencies. 4312 ### <a name="data"></a>**data**: Runtime data file dependencies.
4304 4313
4305 ``` 4314 ```
4306 Lists files or directories required to run the given target. These are 4315 Lists files or directories required to run the given target. These are
4307 typically data files or directories of data files. The paths are interpreted 4316 typically data files or directories of data files. The paths are interpreted
4308 as being relative to the current build file. Since these are runtime 4317 as being relative to the current build file. Since these are runtime
4309 dependencies, they do not affect which targets are built or when. To declare 4318 dependencies, they do not affect which targets are built or when. To declare
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after
6147 * [--root: Explicitly specify source root.](#--root) 6156 * [--root: Explicitly specify source root.](#--root)
6148 * [--runtime-deps-list-file: Save runtime dependencies for targets in file .](#--runtime-deps-list-file) 6157 * [--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) 6158 * [--script-executable: Set the executable used to execute scripts.](#--sc ript-executable)
6150 * [--threads: Specify number of worker threads.](#--threads) 6159 * [--threads: Specify number of worker threads.](#--threads)
6151 * [--time: Outputs a summary of how long everything took.](#--time) 6160 * [--time: Outputs a summary of how long everything took.](#--time)
6152 * [--tracelog: Writes a Chrome-compatible trace log to the given file.](#- -tracelog) 6161 * [--tracelog: Writes a Chrome-compatible trace log to the given file.](#- -tracelog)
6153 * [-v: Verbose logging.](#-v) 6162 * [-v: Verbose logging.](#-v)
6154 * [--version: Prints the GN version number and exits.](#--version) 6163 * [--version: Prints the GN version number and exits.](#--version)
6155 ``` 6164 ```
6156 6165
OLDNEW
« no previous file with comments | « tools/gn/builder.cc ('k') | tools/gn/function_toolchain.cc » ('j') | tools/gn/toolchain.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698