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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 Print a dependency tree. By default, duplicates will be elided | 448 Print a dependency tree. By default, duplicates will be elided |
449 with "..." but when --all and -tree are used together, no | 449 with "..." but when --all and -tree are used together, no |
450 eliding will be performed. | 450 eliding will be performed. |
451 | 451 |
452 The "deps", "public_deps", and "data_deps" will all be | 452 The "deps", "public_deps", and "data_deps" will all be |
453 included in the tree. | 453 included in the tree. |
454 | 454 |
455 Tree output can not be used with the filtering or output flags: | 455 Tree output can not be used with the filtering or output flags: |
456 --as, --type, --testonly. | 456 --as, --type, --testonly. |
457 | 457 |
458 --type=(action|copy|executable|group|shared_library|source_set| | 458 --type=(action|copy|executable|group|loadable_module|shared_library| |
459 static_library) | 459 source_set|static_library) |
460 Restrict outputs to targets matching the given type. If | 460 Restrict outputs to targets matching the given type. If |
461 unspecified, no filtering will be performed. | 461 unspecified, no filtering will be performed. |
462 | 462 |
463 ``` | 463 ``` |
464 | 464 |
465 ### **Note** | 465 ### **Note** |
466 | 466 |
467 ``` | 467 ``` |
468 This command will show the full name of directories and source files, | 468 This command will show the full name of directories and source files, |
469 but when directories and source paths are written to the build file, | 469 but when directories and source paths are written to the build file, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 Matches all toolchains. When set, if the label pattern does not | 587 Matches all toolchains. When set, if the label pattern does not |
588 specify an explicit toolchain, labels from all toolchains will be | 588 specify an explicit toolchain, labels from all toolchains will be |
589 matched. When unset, only targets in the default toolchain will | 589 matched. When unset, only targets in the default toolchain will |
590 be matched unless an explicit toolchain in the label is set. | 590 be matched unless an explicit toolchain in the label is set. |
591 | 591 |
592 --testonly=(true|false) | 592 --testonly=(true|false) |
593 Restrict outputs to targets with the testonly flag set | 593 Restrict outputs to targets with the testonly flag set |
594 accordingly. When unspecified, the target's testonly flags are | 594 accordingly. When unspecified, the target's testonly flags are |
595 ignored. | 595 ignored. |
596 | 596 |
597 --type=(action|copy|executable|group|shared_library|source_set| | 597 --type=(action|copy|executable|group|loadable_module|shared_library| |
598 static_library) | 598 source_set|static_library) |
599 Restrict outputs to targets matching the given type. If | 599 Restrict outputs to targets matching the given type. If |
600 unspecified, no filtering will be performed. | 600 unspecified, no filtering will be performed. |
601 | 601 |
602 ``` | 602 ``` |
603 | 603 |
604 ### **Examples** | 604 ### **Examples** |
605 | 605 |
606 ``` | 606 ``` |
607 gn ls out/Debug | 607 gn ls out/Debug |
608 Lists all targets in the default toolchain. | 608 Lists all targets in the default toolchain. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 ignored. | 733 ignored. |
734 | 734 |
735 --tree | 735 --tree |
736 Outputs a reverse dependency tree from the given target. | 736 Outputs a reverse dependency tree from the given target. |
737 Duplicates will be elided. Combine with --all to see a full | 737 Duplicates will be elided. Combine with --all to see a full |
738 dependency tree. | 738 dependency tree. |
739 | 739 |
740 Tree output can not be used with the filtering or output flags: | 740 Tree output can not be used with the filtering or output flags: |
741 --as, --type, --testonly. | 741 --as, --type, --testonly. |
742 | 742 |
743 --type=(action|copy|executable|group|shared_library|source_set| | 743 --type=(action|copy|executable|group|loadable_module|shared_library| |
744 static_library) | 744 source_set|static_library) |
745 Restrict outputs to targets matching the given type. If | 745 Restrict outputs to targets matching the given type. If |
746 unspecified, no filtering will be performed. | 746 unspecified, no filtering will be performed. |
747 | 747 |
748 ``` | 748 ``` |
749 | 749 |
750 ### **Examples (target input)** | 750 ### **Examples (target input)** |
751 | 751 |
752 ``` | 752 ``` |
753 gn refs out/Debug //tools/gn:gn | 753 gn refs out/Debug //tools/gn:gn |
754 Find all targets depending on the given exact target name. | 754 Find all targets depending on the given exact target name. |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 3. Public_configs from a breadth-first traversal of the dependency | 1018 3. Public_configs from a breadth-first traversal of the dependency |
1019 tree in the order that the targets appear in "deps". | 1019 tree in the order that the targets appear in "deps". |
1020 4. All dependent configs from a breadth-first traversal of the | 1020 4. All dependent configs from a breadth-first traversal of the |
1021 dependency tree in the order that the targets appear in "deps". | 1021 dependency tree in the order that the targets appear in "deps". |
1022 | 1022 |
1023 ``` | 1023 ``` |
1024 | 1024 |
1025 ### **Variables valid in a config definition**: | 1025 ### **Variables valid in a config definition**: |
1026 ``` | 1026 ``` |
1027 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, | 1027 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, |
1028 defines, include_dirs, ldflags, lib_dirs, libs, | 1028 asmflags, defines, include_dirs, ldflags, lib_dirs, libs, |
1029 precompiled_header, precompiled_source | 1029 precompiled_header, precompiled_source |
1030 | 1030 |
1031 ``` | 1031 ``` |
1032 | 1032 |
1033 ### **Variables on a target used to apply configs**: | 1033 ### **Variables on a target used to apply configs**: |
1034 ``` | 1034 ``` |
1035 all_dependent_configs, configs, public_configs | 1035 all_dependent_configs, configs, public_configs |
1036 | 1036 |
1037 ``` | 1037 ``` |
1038 | 1038 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 ## **declare_args**: Declare build arguments. | 1096 ## **declare_args**: Declare build arguments. |
1097 | 1097 |
1098 ``` | 1098 ``` |
1099 Introduces the given arguments into the current scope. If they are | 1099 Introduces the given arguments into the current scope. If they are |
1100 not specified on the command line or in a toolchain's arguments, | 1100 not specified on the command line or in a toolchain's arguments, |
1101 the default values given in the declare_args block will be used. | 1101 the default values given in the declare_args block will be used. |
1102 However, these defaults will not override command-line values. | 1102 However, these defaults will not override command-line values. |
1103 | 1103 |
1104 See also "gn help buildargs" for an overview. | 1104 See also "gn help buildargs" for an overview. |
1105 | 1105 |
| 1106 The precise behavior of declare args is: |
| 1107 |
| 1108 1. The declare_arg block executes. Any variables in the enclosing |
| 1109 scope are available for reading. |
| 1110 |
| 1111 2. At the end of executing the block, any variables set within that |
| 1112 scope are saved globally as build arguments, with their current |
| 1113 values being saved as the "default value" for that argument. |
| 1114 |
| 1115 3. User-defined overrides are applied. Anything set in "gn args" |
| 1116 now overrides any default values. The resulting set of variables |
| 1117 is promoted to be readable from the following code in the file. |
| 1118 |
| 1119 This has some ramifications that may not be obvious: |
| 1120 |
| 1121 - You should not perform difficult work inside a declare_args block |
| 1122 since this only sets a default value that may be discarded. In |
| 1123 particular, don't use the result of exec_script() to set the |
| 1124 default value. If you want to have a script-defined default, set |
| 1125 some default "undefined" value like [], "", or -1, and after |
| 1126 the declare_args block, call exec_script if the value is unset by |
| 1127 the user. |
| 1128 |
| 1129 - Any code inside of the declare_args block will see the default |
| 1130 values of previous variables defined in the block rather than |
| 1131 the user-overridden value. This can be surprising because you will |
| 1132 be used to seeing the overridden value. If you need to make the |
| 1133 default value of one arg dependent on the possibly-overridden |
| 1134 value of another, write two separate declare_args blocks: |
| 1135 |
| 1136 declare_args() { |
| 1137 enable_foo = true |
| 1138 } |
| 1139 declare_args() { |
| 1140 # Bar defaults to same user-overridden state as foo. |
| 1141 enable_bar = enable_foo |
| 1142 } |
| 1143 |
1106 ``` | 1144 ``` |
1107 | 1145 |
1108 ### **Example**: | 1146 ### **Example** |
| 1147 |
1109 ``` | 1148 ``` |
1110 declare_args() { | 1149 declare_args() { |
1111 enable_teleporter = true | 1150 enable_teleporter = true |
1112 enable_doom_melon = false | 1151 enable_doom_melon = false |
1113 } | 1152 } |
1114 | 1153 |
1115 If you want to override the (default disabled) Doom Melon: | 1154 If you want to override the (default disabled) Doom Melon: |
1116 gn --args="enable_doom_melon=true enable_teleporter=false" | 1155 gn --args="enable_doom_melon=true enable_teleporter=false" |
1117 This also sets the teleporter, but it's already defaulted to on so | 1156 This also sets the teleporter, but it's already defaulted to on so |
1118 it will have no effect. | 1157 it will have no effect. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 exec_script("//foo/bar/myscript.py") | 1255 exec_script("//foo/bar/myscript.py") |
1217 | 1256 |
1218 | 1257 |
1219 ``` | 1258 ``` |
1220 ## **executable**: Declare an executable target. | 1259 ## **executable**: Declare an executable target. |
1221 | 1260 |
1222 ### **Variables** | 1261 ### **Variables** |
1223 | 1262 |
1224 ``` | 1263 ``` |
1225 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, | 1264 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, |
1226 defines, include_dirs, ldflags, lib_dirs, libs, | 1265 asmflags, defines, include_dirs, ldflags, lib_dirs, libs, |
1227 precompiled_header, precompiled_source | 1266 precompiled_header, precompiled_source |
1228 Deps: data_deps, deps, public_deps | 1267 Deps: data_deps, deps, public_deps |
1229 Dependent configs: all_dependent_configs, public_configs | 1268 Dependent configs: all_dependent_configs, public_configs |
1230 General: check_includes, configs, data, inputs, output_name, | 1269 General: check_includes, configs, data, inputs, output_name, |
1231 output_extension, public, sources, testonly, visibility | 1270 output_extension, public, sources, testonly, visibility, |
| 1271 darwin_bundle |
1232 | 1272 |
1233 | 1273 |
1234 ``` | 1274 ``` |
1235 ## **foreach**: Iterate over a list. | 1275 ## **foreach**: Iterate over a list. |
1236 | 1276 |
1237 ``` | 1277 ``` |
1238 foreach(<loop_var>, <list>) { | 1278 foreach(<loop_var>, <list>) { |
1239 <loop contents> | 1279 <loop contents> |
1240 } | 1280 } |
1241 | 1281 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 | 1615 |
1576 ``` | 1616 ``` |
1577 ## **group**: Declare a named group of targets. | 1617 ## **group**: Declare a named group of targets. |
1578 | 1618 |
1579 ``` | 1619 ``` |
1580 This target type allows you to create meta-targets that just collect a | 1620 This target type allows you to create meta-targets that just collect a |
1581 set of dependencies into one named target. Groups can additionally | 1621 set of dependencies into one named target. Groups can additionally |
1582 specify configs that apply to their dependents. | 1622 specify configs that apply to their dependents. |
1583 | 1623 |
1584 Depending on a group is exactly like depending directly on that | 1624 Depending on a group is exactly like depending directly on that |
1585 group's deps. | 1625 group's deps. |
1586 | 1626 |
1587 ``` | 1627 ``` |
1588 | 1628 |
1589 ### **Variables** | 1629 ### **Variables** |
1590 | 1630 |
1591 ``` | 1631 ``` |
1592 Deps: data_deps, deps, public_deps | 1632 Deps: data_deps, deps, public_deps |
1593 Dependent configs: all_dependent_configs, public_configs | 1633 Dependent configs: all_dependent_configs, public_configs |
1594 | 1634 |
1595 ``` | 1635 ``` |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 ### **Examples**: | 1678 ### **Examples**: |
1639 | 1679 |
1640 ``` | 1680 ``` |
1641 import("//build/rules/idl_compilation_rule.gni") | 1681 import("//build/rules/idl_compilation_rule.gni") |
1642 | 1682 |
1643 # Looks in the current directory. | 1683 # Looks in the current directory. |
1644 import("my_vars.gni") | 1684 import("my_vars.gni") |
1645 | 1685 |
1646 | 1686 |
1647 ``` | 1687 ``` |
| 1688 ## **loadable_module**: Declare a loadable module target. |
| 1689 |
| 1690 ``` |
| 1691 A loadable module will be specified on the linker line for targets |
| 1692 listing the loadable module in its "deps". If you don't want this |
| 1693 (if you don't need to dynamically load the library at runtime), then |
| 1694 you should use a "shared_library" target type instead. |
| 1695 |
| 1696 ``` |
| 1697 |
| 1698 ### **Variables** |
| 1699 |
| 1700 ``` |
| 1701 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, |
| 1702 asmflags, defines, include_dirs, ldflags, lib_dirs, libs, |
| 1703 precompiled_header, precompiled_source |
| 1704 Deps: data_deps, deps, public_deps |
| 1705 Dependent configs: all_dependent_configs, public_configs |
| 1706 General: check_includes, configs, data, inputs, output_name, |
| 1707 output_extension, public, sources, testonly, visibility, |
| 1708 darwin_bundle |
| 1709 |
| 1710 |
| 1711 ``` |
1648 ## **print**: Prints to the console. | 1712 ## **print**: Prints to the console. |
1649 | 1713 |
1650 ``` | 1714 ``` |
1651 Prints all arguments to the console separated by spaces. A newline is | 1715 Prints all arguments to the console separated by spaces. A newline is |
1652 automatically appended to the end. | 1716 automatically appended to the end. |
1653 | 1717 |
1654 This function is intended for debugging. Note that build files are run | 1718 This function is intended for debugging. Note that build files are run |
1655 in parallel so you may get interleaved prints. A buildfile may also | 1719 in parallel so you may get interleaved prints. A buildfile may also |
1656 be executed more than once in parallel in the context of different | 1720 be executed more than once in parallel in the context of different |
1657 toolchains so the prints from one file may be duplicated or | 1721 toolchains so the prints from one file may be duplicated or |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 # Will print [ "a.cc" ]. b_win one was filtered out. | 2045 # Will print [ "a.cc" ]. b_win one was filtered out. |
1982 | 2046 |
1983 | 2047 |
1984 ``` | 2048 ``` |
1985 ## **shared_library**: Declare a shared library target. | 2049 ## **shared_library**: Declare a shared library target. |
1986 | 2050 |
1987 ``` | 2051 ``` |
1988 A shared library will be specified on the linker line for targets | 2052 A shared library will be specified on the linker line for targets |
1989 listing the shared library in its "deps". If you don't want this | 2053 listing the shared library in its "deps". If you don't want this |
1990 (say you dynamically load the library at runtime), then you should | 2054 (say you dynamically load the library at runtime), then you should |
1991 depend on the shared library via "data_deps" instead. | 2055 depend on the shared library via "data_deps" or, on Darwin |
| 2056 platforms, use a "loadable_module" target type instead. |
1992 | 2057 |
1993 ``` | 2058 ``` |
1994 | 2059 |
1995 ### **Variables** | 2060 ### **Variables** |
1996 | 2061 |
1997 ``` | 2062 ``` |
1998 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, | 2063 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, |
1999 defines, include_dirs, ldflags, lib_dirs, libs, | 2064 asmflags, defines, include_dirs, ldflags, lib_dirs, libs, |
2000 precompiled_header, precompiled_source | 2065 precompiled_header, precompiled_source |
2001 Deps: data_deps, deps, public_deps | 2066 Deps: data_deps, deps, public_deps |
2002 Dependent configs: all_dependent_configs, public_configs | 2067 Dependent configs: all_dependent_configs, public_configs |
2003 General: check_includes, configs, data, inputs, output_name, | 2068 General: check_includes, configs, data, inputs, output_name, |
2004 output_extension, public, sources, testonly, visibility | 2069 output_extension, public, sources, testonly, visibility, |
| 2070 darwin_bundle |
2005 | 2071 |
2006 | 2072 |
2007 ``` | 2073 ``` |
2008 ## **source_set**: Declare a source set target. | 2074 ## **source_set**: Declare a source set target. |
2009 | 2075 |
2010 ``` | 2076 ``` |
2011 A source set is a collection of sources that get compiled, but are not | 2077 A source set is a collection of sources that get compiled, but are not |
2012 linked to produce any kind of library. Instead, the resulting object | 2078 linked to produce any kind of library. Instead, the resulting object |
2013 files are implicitly added to the linker line of all targets that | 2079 files are implicitly added to the linker line of all targets that |
2014 depend on the source set. | 2080 depend on the source set. |
(...skipping 15 matching lines...) Expand all Loading... |
2030 final shared library and not from the intermediate targets." There is | 2096 final shared library and not from the intermediate targets." There is |
2031 no way to express this concept when linking multiple static libraries | 2097 no way to express this concept when linking multiple static libraries |
2032 into a shared library. | 2098 into a shared library. |
2033 | 2099 |
2034 ``` | 2100 ``` |
2035 | 2101 |
2036 ### **Variables** | 2102 ### **Variables** |
2037 | 2103 |
2038 ``` | 2104 ``` |
2039 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, | 2105 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, |
2040 defines, include_dirs, ldflags, lib_dirs, libs, | 2106 asmflags, defines, include_dirs, ldflags, lib_dirs, libs, |
2041 precompiled_header, precompiled_source | 2107 precompiled_header, precompiled_source |
2042 Deps: data_deps, deps, public_deps | 2108 Deps: data_deps, deps, public_deps |
2043 Dependent configs: all_dependent_configs, public_configs | 2109 Dependent configs: all_dependent_configs, public_configs |
2044 General: check_includes, configs, data, inputs, output_name, | 2110 General: check_includes, configs, data, inputs, output_name, |
2045 output_extension, public, sources, testonly, visibility | 2111 output_extension, public, sources, testonly, visibility, |
| 2112 darwin_bundle |
2046 | 2113 |
2047 | 2114 |
2048 ``` | 2115 ``` |
2049 ## **static_library**: Declare a static library target. | 2116 ## **static_library**: Declare a static library target. |
2050 | 2117 |
2051 ``` | 2118 ``` |
2052 Make a ".a" / ".lib" file. | 2119 Make a ".a" / ".lib" file. |
2053 | 2120 |
2054 If you only need the static library for intermediate results in the | 2121 If you only need the static library for intermediate results in the |
2055 build, you should consider a source_set instead since it will skip | 2122 build, you should consider a source_set instead since it will skip |
2056 the (potentially slow) step of creating the intermediate library file. | 2123 the (potentially slow) step of creating the intermediate library file. |
2057 | 2124 |
2058 ``` | 2125 ``` |
2059 | 2126 |
2060 ### **Variables** | 2127 ### **Variables** |
2061 | 2128 |
2062 ``` | 2129 ``` |
2063 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, | 2130 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, |
2064 defines, include_dirs, ldflags, lib_dirs, libs, | 2131 asmflags, defines, include_dirs, ldflags, lib_dirs, libs, |
2065 precompiled_header, precompiled_source | 2132 precompiled_header, precompiled_source |
2066 Deps: data_deps, deps, public_deps | 2133 Deps: data_deps, deps, public_deps |
2067 Dependent configs: all_dependent_configs, public_configs | 2134 Dependent configs: all_dependent_configs, public_configs |
2068 General: check_includes, configs, data, inputs, output_name, | 2135 General: check_includes, configs, data, inputs, output_name, |
2069 output_extension, public, sources, testonly, visibility | 2136 output_extension, public, sources, testonly, visibility, |
| 2137 darwin_bundle |
2070 | 2138 |
2071 | 2139 |
2072 ``` | 2140 ``` |
2073 ## **target**: Declare an target with the given programmatic type. | 2141 ## **target**: Declare an target with the given programmatic type. |
2074 | 2142 |
2075 ``` | 2143 ``` |
2076 target(target_type_string, target_name_string) { ... } | 2144 target(target_type_string, target_name_string) { ... } |
2077 | 2145 |
2078 The target() function is a way to invoke a built-in target or template | 2146 The target() function is a way to invoke a built-in target or template |
2079 with a type determined at runtime. This is useful for cases where the | 2147 with a type determined at runtime. This is useful for cases where the |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 produces a ".lib" import library: | 2455 produces a ".lib" import library: |
2388 outputs = [ | 2456 outputs = [ |
2389 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", | 2457 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", |
2390 "{{root_out_dir}}/{{target_output_name}}.lib", | 2458 "{{root_out_dir}}/{{target_output_name}}.lib", |
2391 ] | 2459 ] |
2392 | 2460 |
2393 link_output [string with substitutions] | 2461 link_output [string with substitutions] |
2394 depend_output [string with substitutions] | 2462 depend_output [string with substitutions] |
2395 Valid for: "solink" only (optional) | 2463 Valid for: "solink" only (optional) |
2396 | 2464 |
2397 These two files specify whch of the outputs from the solink | 2465 These two files specify which of the outputs from the solink |
2398 tool should be used for linking and dependency tracking. These | 2466 tool should be used for linking and dependency tracking. These |
2399 should match entries in the "outputs". If unspecified, the | 2467 should match entries in the "outputs". If unspecified, the |
2400 first item in the "outputs" array will be used for both. See | 2468 first item in the "outputs" array will be used for both. See |
2401 "Separate linking and dependencies for shared libraries" | 2469 "Separate linking and dependencies for shared libraries" |
2402 below for more. | 2470 below for more. |
2403 | 2471 |
2404 On Windows, where the tools produce a .dll shared library and | 2472 On Windows, where the tools produce a .dll shared library and |
2405 a .lib import library, you will want both of these to be the | 2473 a .lib import library, you will want both of these to be the |
2406 import library. On Linux, if you're not doing the separate | 2474 import library. On Linux, if you're not doing the separate |
2407 linking/dependency optimization, both of these should be the | 2475 linking/dependency optimization, both of these should be the |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 The short name of the current target with no path information, | 2572 The short name of the current target with no path information, |
2505 or the value of the "output_name" variable if one is specified | 2573 or the value of the "output_name" variable if one is specified |
2506 in the target. This will include the "output_prefix" if any. | 2574 in the target. This will include the "output_prefix" if any. |
2507 Example: "libfoo" for the target named "foo" and an | 2575 Example: "libfoo" for the target named "foo" and an |
2508 output prefix for the linker tool of "lib". | 2576 output prefix for the linker tool of "lib". |
2509 | 2577 |
2510 Compiler tools have the notion of a single input and a single output, | 2578 Compiler tools have the notion of a single input and a single output, |
2511 along with a set of compiler-specific flags. The following expansions | 2579 along with a set of compiler-specific flags. The following expansions |
2512 are available: | 2580 are available: |
2513 | 2581 |
| 2582 {{asmflags}} |
2514 {{cflags}} | 2583 {{cflags}} |
2515 {{cflags_c}} | 2584 {{cflags_c}} |
2516 {{cflags_cc}} | 2585 {{cflags_cc}} |
2517 {{cflags_objc}} | 2586 {{cflags_objc}} |
2518 {{cflags_objcc}} | 2587 {{cflags_objcc}} |
2519 {{defines}} | 2588 {{defines}} |
2520 {{include_dirs}} | 2589 {{include_dirs}} |
2521 Strings correspond that to the processed flags/defines/include | 2590 Strings correspond that to the processed flags/defines/include |
2522 directories specified for the target. | 2591 directories specified for the target. |
2523 Example: "--enable-foo --enable-bar" | 2592 Example: "--enable-foo --enable-bar" |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3210 ``` | 3279 ``` |
3211 ## **cflags***: Flags passed to the C compiler. | 3280 ## **cflags***: Flags passed to the C compiler. |
3212 | 3281 |
3213 ``` | 3282 ``` |
3214 A list of strings. | 3283 A list of strings. |
3215 | 3284 |
3216 "cflags" are passed to all invocations of the C, C++, Objective C, | 3285 "cflags" are passed to all invocations of the C, C++, Objective C, |
3217 and Objective C++ compilers. | 3286 and Objective C++ compilers. |
3218 | 3287 |
3219 To target one of these variants individually, use "cflags_c", | 3288 To target one of these variants individually, use "cflags_c", |
3220 "cflags_cc", "cflags_objc", and "cflags_objcc", respectively. | 3289 "cflags_cc", "cflags_objc", and "cflags_objcc", |
3221 These variant-specific versions will be appended to the "cflags". | 3290 respectively. |
| 3291 |
| 3292 These variant-specific versions of cflags* will be appended to the |
| 3293 "cflags". |
3222 | 3294 |
3223 ``` | 3295 ``` |
3224 | 3296 |
3225 ### **Ordering of flags and values** | 3297 ### **Ordering of flags and values** |
3226 | 3298 |
3227 ``` | 3299 ``` |
3228 1. Those set on the current target (not in a config). | 3300 1. Those set on the current target (not in a config). |
3229 2. Those set on the "configs" on the target in order that the | 3301 2. Those set on the "configs" on the target in order that the |
3230 configs appear in the list. | 3302 configs appear in the list. |
3231 3. Those set on the "all_dependent_configs" on the target in order | 3303 3. Those set on the "all_dependent_configs" on the target in order |
(...skipping 11 matching lines...) Expand all Loading... |
3243 ``` | 3315 ``` |
3244 ## **cflags***: Flags passed to the C compiler. | 3316 ## **cflags***: Flags passed to the C compiler. |
3245 | 3317 |
3246 ``` | 3318 ``` |
3247 A list of strings. | 3319 A list of strings. |
3248 | 3320 |
3249 "cflags" are passed to all invocations of the C, C++, Objective C, | 3321 "cflags" are passed to all invocations of the C, C++, Objective C, |
3250 and Objective C++ compilers. | 3322 and Objective C++ compilers. |
3251 | 3323 |
3252 To target one of these variants individually, use "cflags_c", | 3324 To target one of these variants individually, use "cflags_c", |
3253 "cflags_cc", "cflags_objc", and "cflags_objcc", respectively. | 3325 "cflags_cc", "cflags_objc", and "cflags_objcc", |
3254 These variant-specific versions will be appended to the "cflags". | 3326 respectively. |
| 3327 |
| 3328 These variant-specific versions of cflags* will be appended to the |
| 3329 "cflags". |
3255 | 3330 |
3256 ``` | 3331 ``` |
3257 | 3332 |
3258 ### **Ordering of flags and values** | 3333 ### **Ordering of flags and values** |
3259 | 3334 |
3260 ``` | 3335 ``` |
3261 1. Those set on the current target (not in a config). | 3336 1. Those set on the current target (not in a config). |
3262 2. Those set on the "configs" on the target in order that the | 3337 2. Those set on the "configs" on the target in order that the |
3263 configs appear in the list. | 3338 configs appear in the list. |
3264 3. Those set on the "all_dependent_configs" on the target in order | 3339 3. Those set on the "all_dependent_configs" on the target in order |
(...skipping 11 matching lines...) Expand all Loading... |
3276 ``` | 3351 ``` |
3277 ## **cflags***: Flags passed to the C compiler. | 3352 ## **cflags***: Flags passed to the C compiler. |
3278 | 3353 |
3279 ``` | 3354 ``` |
3280 A list of strings. | 3355 A list of strings. |
3281 | 3356 |
3282 "cflags" are passed to all invocations of the C, C++, Objective C, | 3357 "cflags" are passed to all invocations of the C, C++, Objective C, |
3283 and Objective C++ compilers. | 3358 and Objective C++ compilers. |
3284 | 3359 |
3285 To target one of these variants individually, use "cflags_c", | 3360 To target one of these variants individually, use "cflags_c", |
3286 "cflags_cc", "cflags_objc", and "cflags_objcc", respectively. | 3361 "cflags_cc", "cflags_objc", and "cflags_objcc", |
3287 These variant-specific versions will be appended to the "cflags". | 3362 respectively. |
| 3363 |
| 3364 These variant-specific versions of cflags* will be appended to the |
| 3365 "cflags". |
3288 | 3366 |
3289 ``` | 3367 ``` |
3290 | 3368 |
3291 ### **Ordering of flags and values** | 3369 ### **Ordering of flags and values** |
3292 | 3370 |
3293 ``` | 3371 ``` |
3294 1. Those set on the current target (not in a config). | 3372 1. Those set on the current target (not in a config). |
3295 2. Those set on the "configs" on the target in order that the | 3373 2. Those set on the "configs" on the target in order that the |
3296 configs appear in the list. | 3374 configs appear in the list. |
3297 3. Those set on the "all_dependent_configs" on the target in order | 3375 3. Those set on the "all_dependent_configs" on the target in order |
(...skipping 11 matching lines...) Expand all Loading... |
3309 ``` | 3387 ``` |
3310 ## **cflags***: Flags passed to the C compiler. | 3388 ## **cflags***: Flags passed to the C compiler. |
3311 | 3389 |
3312 ``` | 3390 ``` |
3313 A list of strings. | 3391 A list of strings. |
3314 | 3392 |
3315 "cflags" are passed to all invocations of the C, C++, Objective C, | 3393 "cflags" are passed to all invocations of the C, C++, Objective C, |
3316 and Objective C++ compilers. | 3394 and Objective C++ compilers. |
3317 | 3395 |
3318 To target one of these variants individually, use "cflags_c", | 3396 To target one of these variants individually, use "cflags_c", |
3319 "cflags_cc", "cflags_objc", and "cflags_objcc", respectively. | 3397 "cflags_cc", "cflags_objc", and "cflags_objcc", |
3320 These variant-specific versions will be appended to the "cflags". | 3398 respectively. |
| 3399 |
| 3400 These variant-specific versions of cflags* will be appended to the |
| 3401 "cflags". |
3321 | 3402 |
3322 ``` | 3403 ``` |
3323 | 3404 |
3324 ### **Ordering of flags and values** | 3405 ### **Ordering of flags and values** |
3325 | 3406 |
3326 ``` | 3407 ``` |
3327 1. Those set on the current target (not in a config). | 3408 1. Those set on the current target (not in a config). |
3328 2. Those set on the "configs" on the target in order that the | 3409 2. Those set on the "configs" on the target in order that the |
3329 configs appear in the list. | 3410 configs appear in the list. |
3330 3. Those set on the "all_dependent_configs" on the target in order | 3411 3. Those set on the "all_dependent_configs" on the target in order |
(...skipping 11 matching lines...) Expand all Loading... |
3342 ``` | 3423 ``` |
3343 ## **cflags***: Flags passed to the C compiler. | 3424 ## **cflags***: Flags passed to the C compiler. |
3344 | 3425 |
3345 ``` | 3426 ``` |
3346 A list of strings. | 3427 A list of strings. |
3347 | 3428 |
3348 "cflags" are passed to all invocations of the C, C++, Objective C, | 3429 "cflags" are passed to all invocations of the C, C++, Objective C, |
3349 and Objective C++ compilers. | 3430 and Objective C++ compilers. |
3350 | 3431 |
3351 To target one of these variants individually, use "cflags_c", | 3432 To target one of these variants individually, use "cflags_c", |
3352 "cflags_cc", "cflags_objc", and "cflags_objcc", respectively. | 3433 "cflags_cc", "cflags_objc", and "cflags_objcc", |
3353 These variant-specific versions will be appended to the "cflags". | 3434 respectively. |
| 3435 |
| 3436 These variant-specific versions of cflags* will be appended to the |
| 3437 "cflags". |
3354 | 3438 |
3355 ``` | 3439 ``` |
3356 | 3440 |
3357 ### **Ordering of flags and values** | 3441 ### **Ordering of flags and values** |
3358 | 3442 |
3359 ``` | 3443 ``` |
3360 1. Those set on the current target (not in a config). | 3444 1. Those set on the current target (not in a config). |
3361 2. Those set on the "configs" on the target in order that the | 3445 2. Those set on the "configs" on the target in order that the |
3362 configs appear in the list. | 3446 configs appear in the list. |
3363 3. Those set on the "all_dependent_configs" on the target in order | 3447 3. Those set on the "all_dependent_configs" on the target in order |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3711 libraries will be linked into the current target. | 3795 libraries will be linked into the current target. |
3712 | 3796 |
3713 These dependencies are private in that it does not grant dependent | 3797 These dependencies are private in that it does not grant dependent |
3714 targets the ability to include headers from the dependency, and direct | 3798 targets the ability to include headers from the dependency, and direct |
3715 dependent configs are not forwarded. | 3799 dependent configs are not forwarded. |
3716 | 3800 |
3717 See also "public_deps" and "data_deps". | 3801 See also "public_deps" and "data_deps". |
3718 | 3802 |
3719 | 3803 |
3720 ``` | 3804 ``` |
3721 | |
3722 ``` | |
3723 ## **include_dirs**: Additional include directories. | 3805 ## **include_dirs**: Additional include directories. |
3724 | 3806 |
3725 ``` | 3807 ``` |
3726 A list of source directories. | 3808 A list of source directories. |
3727 | 3809 |
3728 The directories in this list will be added to the include path for | 3810 The directories in this list will be added to the include path for |
3729 the files in the affected target. | 3811 the files in the affected target. |
3730 | 3812 |
3731 ``` | 3813 ``` |
3732 | 3814 |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4789 ## **Runtime dependencies** | 4871 ## **Runtime dependencies** |
4790 | 4872 |
4791 ``` | 4873 ``` |
4792 Runtime dependencies of a target are exposed via the "runtime_deps" | 4874 Runtime dependencies of a target are exposed via the "runtime_deps" |
4793 category of "gn desc" (see "gn help desc") or they can be written | 4875 category of "gn desc" (see "gn help desc") or they can be written |
4794 at build generation time via "--runtime-deps-list-file" | 4876 at build generation time via "--runtime-deps-list-file" |
4795 (see "gn help --runtime-deps-list-file"). | 4877 (see "gn help --runtime-deps-list-file"). |
4796 | 4878 |
4797 To a first approximation, the runtime dependencies of a target are | 4879 To a first approximation, the runtime dependencies of a target are |
4798 the set of "data" files, data directories, and the shared libraries | 4880 the set of "data" files, data directories, and the shared libraries |
4799 from all transitive dependencies. Executables and shared libraries are | 4881 from all transitive dependencies. Executables, shared libraries, and |
4800 considered runtime dependencies of themselves. | 4882 loadable modules are considered runtime dependencies of themselves. |
4801 | 4883 |
4802 ``` | 4884 ``` |
4803 | 4885 |
4804 ### **Executables** | 4886 ### **Executables** |
4805 | 4887 |
4806 ``` | 4888 ``` |
4807 Executable targets and those executable targets' transitive | 4889 Executable targets and those executable targets' transitive |
4808 dependencies are not considered unless that executable is listed in | 4890 dependencies are not considered unless that executable is listed in |
4809 "data_deps". Otherwise, GN assumes that the executable (and | 4891 "data_deps". Otherwise, GN assumes that the executable (and |
4810 everything it requires) is a build-time dependency only. | 4892 everything it requires) is a build-time dependency only. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5001 ** -q**: Quiet mode. Don't print output on success. | 5083 ** -q**: Quiet mode. Don't print output on success. |
5002 ** \--root**: Explicitly specify source root. | 5084 ** \--root**: Explicitly specify source root. |
5003 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. | 5085 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. |
5004 ** \--threads**: Specify number of worker threads. | 5086 ** \--threads**: Specify number of worker threads. |
5005 ** \--time**: Outputs a summary of how long everything took. | 5087 ** \--time**: Outputs a summary of how long everything took. |
5006 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. | 5088 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. |
5007 ** -v**: Verbose logging. | 5089 ** -v**: Verbose logging. |
5008 ** \--version**: Prints the GN version number and exits. | 5090 ** \--version**: Prints the GN version number and exits. |
5009 | 5091 |
5010 ``` | 5092 ``` |
OLD | NEW |