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

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

Issue 2936923002: Add not_needed function (Closed)
Patch Set: Support current scope 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 24 matching lines...) Expand all
35 * [declare_args: Declare build arguments.](#declare_args) 35 * [declare_args: Declare build arguments.](#declare_args)
36 * [defined: Returns whether an identifier is defined.](#defined) 36 * [defined: Returns whether an identifier is defined.](#defined)
37 * [exec_script: Synchronously run a script and return the output.](#exec_s cript) 37 * [exec_script: Synchronously run a script and return the output.](#exec_s cript)
38 * [foreach: Iterate over a list.](#foreach) 38 * [foreach: Iterate over a list.](#foreach)
39 * [forward_variables_from: Copies variables from a different scope.](#forw ard_variables_from) 39 * [forward_variables_from: Copies variables from a different scope.](#forw ard_variables_from)
40 * [get_label_info: Get an attribute from a target's label.](#get_label_inf o) 40 * [get_label_info: Get an attribute from a target's label.](#get_label_inf o)
41 * [get_path_info: Extract parts of a file or directory name.](#get_path_in fo) 41 * [get_path_info: Extract parts of a file or directory name.](#get_path_in fo)
42 * [get_target_outputs: [file list] Get the list of outputs from a target.] (#get_target_outputs) 42 * [get_target_outputs: [file list] Get the list of outputs from a target.] (#get_target_outputs)
43 * [getenv: Get an environment variable.](#getenv) 43 * [getenv: Get an environment variable.](#getenv)
44 * [import: Import a file into the current scope.](#import) 44 * [import: Import a file into the current scope.](#import)
45 * [not_needed: Mark variables from scope as not needed.](#not_needed)
45 * [pool: Defines a pool object.](#pool) 46 * [pool: Defines a pool object.](#pool)
46 * [print: Prints to the console.](#print) 47 * [print: Prints to the console.](#print)
47 * [process_file_template: Do template expansion over a list of files.](#pr ocess_file_template) 48 * [process_file_template: Do template expansion over a list of files.](#pr ocess_file_template)
48 * [read_file: Read a file into a variable.](#read_file) 49 * [read_file: Read a file into a variable.](#read_file)
49 * [rebase_path: Rebase a file or directory to another location.](#rebase_p ath) 50 * [rebase_path: Rebase a file or directory to another location.](#rebase_p ath)
50 * [set_default_toolchain: Sets the default toolchain name.](#set_default_t oolchain) 51 * [set_default_toolchain: Sets the default toolchain name.](#set_default_t oolchain)
51 * [set_defaults: Set default values for a target type.](#set_defaults) 52 * [set_defaults: Set default values for a target type.](#set_defaults)
52 * [set_sources_assignment_filter: Set a pattern to filter source files.](# set_sources_assignment_filter) 53 * [set_sources_assignment_filter: Set a pattern to filter source files.](# set_sources_assignment_filter)
53 * [split_list: Splits a list into N different sub-lists.](#split_list) 54 * [split_list: Splits a list into N different sub-lists.](#split_list)
54 * [template: Define a template rule.](#template) 55 * [template: Define a template rule.](#template)
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 #### **Examples** 592 #### **Examples**
592 ``` 593 ```
593 gn format //some/BUILD.gn 594 gn format //some/BUILD.gn
594 gn format some\\BUILD.gn 595 gn format some\\BUILD.gn
595 gn format /abspath/some/BUILD.gn 596 gn format /abspath/some/BUILD.gn
596 gn format --stdin 597 gn format --stdin
597 ``` 598 ```
598 ### <a name="gen:"></a>**gn gen**: Generate ninja files. 599 ### <a name="gen:"></a>**gn gen**: Generate ninja files.
599 600
600 ``` 601 ```
601 gn gen [<ide options>] <out_dir> 602 gn gen [--check] [<ide options>] <out_dir>
602 603
603 Generates ninja files from the current tree and puts them in the given output 604 Generates ninja files from the current tree and puts them in the given output
604 directory. 605 directory.
605 606
606 The output directory can be a source-repo-absolute path name such as: 607 The output directory can be a source-repo-absolute path name such as:
607 //out/foo 608 //out/foo
608 Or it can be a directory relative to the current directory such as: 609 Or it can be a directory relative to the current directory such as:
609 out/foo 610 out/foo
610 611
612 "gn gen --check" is the same as running "gn check". See "gn help check"
613 for documentation on that mode.
614
611 See "gn help switches" for the common command-line switches. 615 See "gn help switches" for the common command-line switches.
612 ``` 616 ```
613 617
614 #### **IDE options** 618 #### **IDE options**
615 619
616 ``` 620 ```
617 GN optionally generates files for IDE. Possibilities for <ide options> 621 GN optionally generates files for IDE. Possibilities for <ide options>
618 622
619 --ide=<ide_name> 623 --ide=<ide_name>
620 Generate files for an IDE. Currently supported values: 624 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 685 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 686 .cproject definition, it is not possible to properly define includes/defines
683 for each file individually. Instead, one set of includes/defines is generated 687 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 688 for the entire project. This works fairly well but may still result in a few
685 indexer issues here and there. 689 indexer issues here and there.
686 ``` 690 ```
687 691
688 #### **Generic JSON Output** 692 #### **Generic JSON Output**
689 693
690 ``` 694 ```
691 Dumps target information to JSON file and optionally invokes python script on 695 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 696 python script on the generated file. See the comments at the beginning
693 desc_builder.cc for overview of JSON file format. 697 of json_project_writer.cc and desc_builder.cc for an overview of the JSON
698 file format.
694 699
695 --json-file-name=<json_file_name> 700 --json-file-name=<json_file_name>
696 Overrides default file name (project.json) of generated JSON file. 701 Overrides default file name (project.json) of generated JSON file.
697 702
698 --json-ide-script=<path_to_python_script> 703 --json-ide-script=<path_to_python_script>
699 Executes python script after the JSON file is generated. Path can be 704 Executes python script after the JSON file is generated. Path can be
700 project absolute (//), system absolute (/) or relative, in which case the 705 project absolute (//), system absolute (/) or relative, in which case the
701 output directory will be base. Path to generated JSON file will be first 706 output directory will be base. Path to generated JSON file will be first
702 argument when invoking script. 707 argument when invoking script.
703 708
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 ``` 2125 ```
2121 2126
2122 #### **Examples** 2127 #### **Examples**
2123 2128
2124 ``` 2129 ```
2125 import("//build/rules/idl_compilation_rule.gni") 2130 import("//build/rules/idl_compilation_rule.gni")
2126 2131
2127 # Looks in the current directory. 2132 # Looks in the current directory.
2128 import("my_vars.gni") 2133 import("my_vars.gni")
2129 ``` 2134 ```
2135 ### <a name="not_needed"></a>**not_needed**: Mark variables from scope as not ne eded.
2136
2137 ```
2138 not_needed(variable_list_or_star, variable_to_ignore_list = [])
2139 not_needed(from_scope, variable_list_or_star,
2140 variable_to_ignore_list = [])
2141
2142 Mark the variables in the current or given scope as not needed, which means
2143 you will not get an error about unused variables for these.
2144 ```
2145
2146 #### **Example**
2147
2148 ```
2149 not_needed("*", [ "config" ])
2150 not_needed([ "data_deps", "deps" ])
2151 not_needed(invoker, "*", [ "config" ])
2152 not_needed(invoker, [ "data_deps", "deps" ])
2153 ```
2130 ### <a name="pool"></a>**pool**: Defines a pool object. 2154 ### <a name="pool"></a>**pool**: Defines a pool object.
2131 2155
2132 ``` 2156 ```
2133 Pool objects can be applied to a tool to limit the parallelism of the 2157 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 2158 build. This object has a single property "depth" corresponding to
2135 the number of tasks that may run simultaneously. 2159 the number of tasks that may run simultaneously.
2136 2160
2137 As the file containing the pool definition may be executed in the 2161 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 2162 context of more than one toolchain it is recommended to specify an
2139 explicit toolchain when defining and referencing a pool. 2163 explicit toolchain when defining and referencing a pool.
(...skipping 4007 matching lines...) Expand 10 before | Expand all | Expand 10 after
6147 * [--root: Explicitly specify source root.](#--root) 6171 * [--root: Explicitly specify source root.](#--root)
6148 * [--runtime-deps-list-file: Save runtime dependencies for targets in file .](#--runtime-deps-list-file) 6172 * [--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) 6173 * [--script-executable: Set the executable used to execute scripts.](#--sc ript-executable)
6150 * [--threads: Specify number of worker threads.](#--threads) 6174 * [--threads: Specify number of worker threads.](#--threads)
6151 * [--time: Outputs a summary of how long everything took.](#--time) 6175 * [--time: Outputs a summary of how long everything took.](#--time)
6152 * [--tracelog: Writes a Chrome-compatible trace log to the given file.](#- -tracelog) 6176 * [--tracelog: Writes a Chrome-compatible trace log to the given file.](#- -tracelog)
6153 * [-v: Verbose logging.](#-v) 6177 * [-v: Verbose logging.](#-v)
6154 * [--version: Prints the GN version number and exits.](#--version) 6178 * [--version: Prints the GN version number and exits.](#--version)
6155 ``` 6179 ```
6156 6180
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698