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

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

Issue 1606553002: Add support for Mac/iOS application bundles to GN tool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit tests & support for bundle_data_filter Created 4 years, 11 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 ## **\--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 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 sources = [ "data1.dat", "data2.dat", "data3.dat" ] 1104 sources = [ "data1.dat", "data2.dat", "data3.dat" ]
1105 1105
1106 # Use source expansion to generate output files with the 1106 # Use source expansion to generate output files with the
1107 # corresponding file names in the gen dir. This will just copy each 1107 # corresponding file names in the gen dir. This will just copy each
1108 # file. 1108 # file.
1109 outputs = [ "$target_gen_dir/{{source_file_part}}" ] 1109 outputs = [ "$target_gen_dir/{{source_file_part}}" ]
1110 } 1110 }
1111 1111
1112 1112
1113 ``` 1113 ```
1114 ## **copy_bundle_data**: Declare a target that copy "bundle_data" files.
1115
1116 ```
1117 Similar to the "copy" target, but the list of files to copy comes
1118 from the "bundle_data" property of all dependencies recursively.
1119 It can be used to copy files required at runtime by the application
1120 into a location where it can be found.
1121
1122 This uses the "copy_bundle_data" tool from the toolchain.
1123
1124 See "gn help copy" for more information.
1125
1126 ```
1127
1128 ### **Examples**
1129
1130 ```
1131 # A source_set that has a runtime dependency expressed as bundle_data
1132 source_set("icu") {
1133 sources = [ "icu.h", "icu.cc" ]
1134 bundle_data = [ "icudtl.dat" ]
1135 }
1136
1137 # Main application executable.
1138 executable("app.app") {
1139 visibility = [ ":app" ]
1140 deps = [ ":icu" ]
1141 output_name = "$root_build_dir/app.app/app"
1142 sources = [ "main.cc" ]
1143 }
1144
1145 # Copy runtime dependencies into the application bundle, filtering
1146 # the .xcassets files as they need to be compiled into a .car file
1147 # on Mac/iOS.
1148 copy_bundle_data("app.bundle") {
1149 visibility = [ ":app" ]
1150 deps = [ ":icu" ] # Same deps as the executable.
1151 outputs = [ $root_build_dir/app.app/{{source_file_name}}" ]
1152 bundle_data_filter = [ "*.xcassets" ]
1153 }
1154
1155 # Main application target.
1156 group("app") {
1157 deps = [ ":app.app", "app.bundle" ]
1158 }
1159
1160
1161 ```
1114 ## **declare_args**: Declare build arguments. 1162 ## **declare_args**: Declare build arguments.
1115 1163
1116 ``` 1164 ```
1117 Introduces the given arguments into the current scope. If they are 1165 Introduces the given arguments into the current scope. If they are
1118 not specified on the command line or in a toolchain's arguments, 1166 not specified on the command line or in a toolchain's arguments,
1119 the default values given in the declare_args block will be used. 1167 the default values given in the declare_args block will be used.
1120 However, these defaults will not override command-line values. 1168 However, these defaults will not override command-line values.
1121 1169
1122 See also "gn help buildargs" for an overview. 1170 See also "gn help buildargs" for an overview.
1123 1171
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 ## **executable**: Declare an executable target. 1325 ## **executable**: Declare an executable target.
1278 1326
1279 ### **Variables** 1327 ### **Variables**
1280 1328
1281 ``` 1329 ```
1282 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, 1330 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc,
1283 asmflags, defines, include_dirs, ldflags, lib_dirs, libs, 1331 asmflags, defines, include_dirs, ldflags, lib_dirs, libs,
1284 precompiled_header, precompiled_source 1332 precompiled_header, precompiled_source
1285 Deps: data_deps, deps, public_deps 1333 Deps: data_deps, deps, public_deps
1286 Dependent configs: all_dependent_configs, public_configs 1334 Dependent configs: all_dependent_configs, public_configs
1287 General: check_includes, configs, data, inputs, output_name, 1335 General: bundle_data, check_includes, configs, data, inputs,
1288 output_extension, public, sources, testonly, visibility 1336 output_name, output_extension, public, sources, testonly,
1337 visibility
1289 1338
1290 1339
1291 ``` 1340 ```
1292 ## **foreach**: Iterate over a list. 1341 ## **foreach**: Iterate over a list.
1293 1342
1294 ``` 1343 ```
1295 foreach(<loop_var>, <list>) { 1344 foreach(<loop_var>, <list>) {
1296 <loop contents> 1345 <loop contents>
1297 } 1346 }
1298 1347
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 ``` 1782 ```
1734 1783
1735 ### **Variables** 1784 ### **Variables**
1736 1785
1737 ``` 1786 ```
1738 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, 1787 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc,
1739 asmflags, defines, include_dirs, ldflags, lib_dirs, libs, 1788 asmflags, defines, include_dirs, ldflags, lib_dirs, libs,
1740 precompiled_header, precompiled_source 1789 precompiled_header, precompiled_source
1741 Deps: data_deps, deps, public_deps 1790 Deps: data_deps, deps, public_deps
1742 Dependent configs: all_dependent_configs, public_configs 1791 Dependent configs: all_dependent_configs, public_configs
1743 General: check_includes, configs, data, inputs, output_name, 1792 General: bundle_data, check_includes, configs, data, inputs,
1744 output_extension, public, sources, testonly, visibility 1793 output_name, output_extension, public, sources, testonly,
1794 visibility
1745 1795
1746 1796
1747 ``` 1797 ```
1748 ## **print**: Prints to the console. 1798 ## **print**: Prints to the console.
1749 1799
1750 ``` 1800 ```
1751 Prints all arguments to the console separated by spaces. A newline is 1801 Prints all arguments to the console separated by spaces. A newline is
1752 automatically appended to the end. 1802 automatically appended to the end.
1753 1803
1754 This function is intended for debugging. Note that build files are run 1804 This function is intended for debugging. Note that build files are run
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 ``` 2144 ```
2095 2145
2096 ### **Variables** 2146 ### **Variables**
2097 2147
2098 ``` 2148 ```
2099 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, 2149 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc,
2100 asmflags, defines, include_dirs, ldflags, lib_dirs, libs, 2150 asmflags, defines, include_dirs, ldflags, lib_dirs, libs,
2101 precompiled_header, precompiled_source 2151 precompiled_header, precompiled_source
2102 Deps: data_deps, deps, public_deps 2152 Deps: data_deps, deps, public_deps
2103 Dependent configs: all_dependent_configs, public_configs 2153 Dependent configs: all_dependent_configs, public_configs
2104 General: check_includes, configs, data, inputs, output_name, 2154 General: bundle_data, check_includes, configs, data, inputs,
2105 output_extension, public, sources, testonly, visibility 2155 output_name, output_extension, public, sources, testonly,
2156 visibility
2106 2157
2107 2158
2108 ``` 2159 ```
2109 ## **source_set**: Declare a source set target. 2160 ## **source_set**: Declare a source set target.
2110 2161
2111 ``` 2162 ```
2112 A source set is a collection of sources that get compiled, but are not 2163 A source set is a collection of sources that get compiled, but are not
2113 linked to produce any kind of library. Instead, the resulting object 2164 linked to produce any kind of library. Instead, the resulting object
2114 files are implicitly added to the linker line of all targets that 2165 files are implicitly added to the linker line of all targets that
2115 depend on the source set. 2166 depend on the source set.
(...skipping 19 matching lines...) Expand all
2135 ``` 2186 ```
2136 2187
2137 ### **Variables** 2188 ### **Variables**
2138 2189
2139 ``` 2190 ```
2140 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, 2191 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc,
2141 asmflags, defines, include_dirs, ldflags, lib_dirs, libs, 2192 asmflags, defines, include_dirs, ldflags, lib_dirs, libs,
2142 precompiled_header, precompiled_source 2193 precompiled_header, precompiled_source
2143 Deps: data_deps, deps, public_deps 2194 Deps: data_deps, deps, public_deps
2144 Dependent configs: all_dependent_configs, public_configs 2195 Dependent configs: all_dependent_configs, public_configs
2145 General: check_includes, configs, data, inputs, output_name, 2196 General: bundle_data, check_includes, configs, data, inputs,
2146 output_extension, public, sources, testonly, visibility 2197 output_name, output_extension, public, sources, testonly,
2198 visibility
2147 2199
2148 2200
2149 ``` 2201 ```
2150 ## **static_library**: Declare a static library target. 2202 ## **static_library**: Declare a static library target.
2151 2203
2152 ``` 2204 ```
2153 Make a ".a" / ".lib" file. 2205 Make a ".a" / ".lib" file.
2154 2206
2155 If you only need the static library for intermediate results in the 2207 If you only need the static library for intermediate results in the
2156 build, you should consider a source_set instead since it will skip 2208 build, you should consider a source_set instead since it will skip
2157 the (potentially slow) step of creating the intermediate library file. 2209 the (potentially slow) step of creating the intermediate library file.
2158 2210
2159 ``` 2211 ```
2160 2212
2161 ### **Variables** 2213 ### **Variables**
2162 2214
2163 ``` 2215 ```
2164 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc, 2216 Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc,
2165 asmflags, defines, include_dirs, ldflags, lib_dirs, libs, 2217 asmflags, defines, include_dirs, ldflags, lib_dirs, libs,
2166 precompiled_header, precompiled_source 2218 precompiled_header, precompiled_source
2167 Deps: data_deps, deps, public_deps 2219 Deps: data_deps, deps, public_deps
2168 Dependent configs: all_dependent_configs, public_configs 2220 Dependent configs: all_dependent_configs, public_configs
2169 General: check_includes, configs, data, inputs, output_name, 2221 General: bundle_data, check_includes, configs, data, inputs,
2170 output_extension, public, sources, testonly, visibility 2222 output_name, output_extension, public, sources, testonly,
2223 visibility
2171 2224
2172 2225
2173 ``` 2226 ```
2174 ## **target**: Declare an target with the given programmatic type. 2227 ## **target**: Declare an target with the given programmatic type.
2175 2228
2176 ``` 2229 ```
2177 target(target_type_string, target_name_string) { ... } 2230 target(target_type_string, target_name_string) { ... }
2178 2231
2179 The target() function is a way to invoke a built-in target or template 2232 The target() function is a way to invoke a built-in target or template
2180 with a type determined at runtime. This is useful for cases where the 2233 with a type determined at runtime. This is useful for cases where the
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
3345 those configs appear in the list. 3398 those configs appear in the list.
3346 5. all_dependent_configs pulled from dependencies, in the order of 3399 5. all_dependent_configs pulled from dependencies, in the order of
3347 the "deps" list. This is done recursively. If a config appears 3400 the "deps" list. This is done recursively. If a config appears
3348 more than once, only the first occurance will be used. 3401 more than once, only the first occurance will be used.
3349 6. public_configs pulled from dependencies, in the order of the 3402 6. public_configs pulled from dependencies, in the order of the
3350 "deps" list. If a dependency is public, they will be applied 3403 "deps" list. If a dependency is public, they will be applied
3351 recursively. 3404 recursively.
3352 3405
3353 3406
3354 ``` 3407 ```
3408 ## **bundle_data**: Runtime data dependency (Mac/iOS).
3409
3410 ```
3411 List files that are required at runtime by the current target and
3412 should be copied into the application bundle.
3413
3414 See also "gn help copy_bundle_data".
3415
3416
3417 ```
3355 ## **cflags***: Flags passed to the C compiler. 3418 ## **cflags***: Flags passed to the C compiler.
3356 3419
3357 ``` 3420 ```
3358 A list of strings. 3421 A list of strings.
3359 3422
3360 "cflags" are passed to all invocations of the C, C++, Objective C, 3423 "cflags" are passed to all invocations of the C, C++, Objective C,
3361 and Objective C++ compilers. 3424 and Objective C++ compilers.
3362 3425
3363 To target one of these variants individually, use "cflags_c", 3426 To target one of these variants individually, use "cflags_c",
3364 "cflags_cc", "cflags_objc", and "cflags_objcc", 3427 "cflags_cc", "cflags_objc", and "cflags_objcc",
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3417 those configs appear in the list. 3480 those configs appear in the list.
3418 5. all_dependent_configs pulled from dependencies, in the order of 3481 5. all_dependent_configs pulled from dependencies, in the order of
3419 the "deps" list. This is done recursively. If a config appears 3482 the "deps" list. This is done recursively. If a config appears
3420 more than once, only the first occurance will be used. 3483 more than once, only the first occurance will be used.
3421 6. public_configs pulled from dependencies, in the order of the 3484 6. public_configs pulled from dependencies, in the order of the
3422 "deps" list. If a dependency is public, they will be applied 3485 "deps" list. If a dependency is public, they will be applied
3423 recursively. 3486 recursively.
3424 3487
3425 3488
3426 ``` 3489 ```
3490 ## **bundle_data_filter**: Exclusions for copy_bundle_data.
3491
3492 ```
3493 List of file patterns that need to be excluded from the application
3494 bundle. All files matching this pattern will be excluded.
3495
3496 See also "gn help copy_bundle_data".
3497
3498
3499 ```
3427 ## **cflags***: Flags passed to the C compiler. 3500 ## **cflags***: Flags passed to the C compiler.
3428 3501
3429 ``` 3502 ```
3430 A list of strings. 3503 A list of strings.
3431 3504
3432 "cflags" are passed to all invocations of the C, C++, Objective C, 3505 "cflags" are passed to all invocations of the C, C++, Objective C,
3433 and Objective C++ compilers. 3506 and Objective C++ compilers.
3434 3507
3435 To target one of these variants individually, use "cflags_c", 3508 To target one of these variants individually, use "cflags_c",
3436 "cflags_cc", "cflags_objc", and "cflags_objcc", 3509 "cflags_cc", "cflags_objc", and "cflags_objcc",
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after
5222 ** -q**: Quiet mode. Don't print output on success. 5295 ** -q**: Quiet mode. Don't print output on success.
5223 ** \--root**: Explicitly specify source root. 5296 ** \--root**: Explicitly specify source root.
5224 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. 5297 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file.
5225 ** \--threads**: Specify number of worker threads. 5298 ** \--threads**: Specify number of worker threads.
5226 ** \--time**: Outputs a summary of how long everything took. 5299 ** \--time**: Outputs a summary of how long everything took.
5227 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. 5300 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file.
5228 ** -v**: Verbose logging. 5301 ** -v**: Verbose logging.
5229 ** \--version**: Prints the GN version number and exits. 5302 ** \--version**: Prints the GN version number and exits.
5230 5303
5231 ``` 5304 ```
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698