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 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 Prints: | 1320 Prints: |
1321 a | 1321 a |
1322 b | 1322 b |
1323 c | 1323 c |
1324 | 1324 |
1325 | 1325 |
1326 ``` | 1326 ``` |
1327 ## **forward_variables_from**: Copies variables from a different scope. | 1327 ## **forward_variables_from**: Copies variables from a different scope. |
1328 | 1328 |
1329 ``` | 1329 ``` |
1330 forward_variables_from(from_scope, variable_list_or_star) | 1330 forward_variables_from(from_scope, variable_list_or_star, |
| 1331 variable_to_not_forward_list = []) |
1331 | 1332 |
1332 Copies the given variables from the given scope to the local scope | 1333 Copies the given variables from the given scope to the local scope |
1333 if they exist. This is normally used in the context of templates to | 1334 if they exist. This is normally used in the context of templates to |
1334 use the values of variables defined in the template invocation to | 1335 use the values of variables defined in the template invocation to |
1335 a template-defined target. | 1336 a template-defined target. |
1336 | 1337 |
1337 The variables in the given variable_list will be copied if they exist | 1338 The variables in the given variable_list will be copied if they exist |
1338 in the given scope or any enclosing scope. If they do not exist, | 1339 in the given scope or any enclosing scope. If they do not exist, |
1339 nothing will happen and they be left undefined in the current scope. | 1340 nothing will happen and they be left undefined in the current scope. |
1340 | 1341 |
1341 As a special case, if the variable_list is a string with the value of | 1342 As a special case, if the variable_list is a string with the value of |
1342 "*", all variables from the given scope will be copied. "*" only | 1343 "*", all variables from the given scope will be copied. "*" only |
1343 copies variables set directly on the from_scope, not enclosing ones. | 1344 copies variables set directly on the from_scope, not enclosing ones. |
1344 Otherwise it would duplicate all global variables. | 1345 Otherwise it would duplicate all global variables. |
1345 | 1346 |
1346 When an explicit list of variables is supplied, if the variable exists | 1347 When an explicit list of variables is supplied, if the variable exists |
1347 in the current (destination) scope already, an error will be thrown. | 1348 in the current (destination) scope already, an error will be thrown. |
1348 If "*" is specified, variables in the current scope will be | 1349 If "*" is specified, variables in the current scope will be |
1349 clobbered (the latter is important because most targets have an | 1350 clobbered (the latter is important because most targets have an |
1350 implicit configs list, which means it wouldn't work at all if it | 1351 implicit configs list, which means it wouldn't work at all if it |
1351 didn't clobber). | 1352 didn't clobber). |
1352 | 1353 |
1353 The sources assignment filter (see "gn help set_sources_assignment_filter") | 1354 The sources assignment filter (see "gn help set_sources_assignment_filter") |
1354 is never applied by this function. It's assumed than any desired | 1355 is never applied by this function. It's assumed than any desired |
1355 filtering was already done when sources was set on the from_scope. | 1356 filtering was already done when sources was set on the from_scope. |
1356 | 1357 |
| 1358 If variables_to_not_forward_list is non-empty, then it must contains |
| 1359 a list of variable names that will not be forwarded. This is mostly |
| 1360 useful when variable_list_or_star has a value of "*". |
| 1361 |
1357 ``` | 1362 ``` |
1358 | 1363 |
1359 ### **Examples** | 1364 ### **Examples** |
1360 | 1365 |
1361 ``` | 1366 ``` |
1362 # This is a common action template. It would invoke a script with | 1367 # This is a common action template. It would invoke a script with |
1363 # some given parameters, and wants to use the various types of deps | 1368 # some given parameters, and wants to use the various types of deps |
1364 # and the visibility from the invoker if it's defined. It also injects | 1369 # and the visibility from the invoker if it's defined. It also injects |
1365 # an additional dependency to all targets. | 1370 # an additional dependency to all targets. |
1366 template("my_test") { | 1371 template("my_test") { |
1367 action(target_name) { | 1372 action(target_name) { |
1368 forward_variables_from(invoker, [ "data_deps", "deps", | 1373 forward_variables_from(invoker, [ "data_deps", "deps", |
1369 "public_deps", "visibility" ]) | 1374 "public_deps", "visibility" ]) |
1370 # Add our test code to the dependencies. | 1375 # Add our test code to the dependencies. |
1371 # "deps" may or may not be defined at this point. | 1376 # "deps" may or may not be defined at this point. |
1372 if (defined(deps)) { | 1377 if (defined(deps)) { |
1373 deps += [ "//tools/doom_melon" ] | 1378 deps += [ "//tools/doom_melon" ] |
1374 } else { | 1379 } else { |
1375 deps = [ "//tools/doom_melon" ] | 1380 deps = [ "//tools/doom_melon" ] |
1376 } | 1381 } |
1377 } | 1382 } |
1378 } | 1383 } |
1379 | 1384 |
1380 # This is a template around either a target whose type depends on a | 1385 # This is a template around either a target whose type depends on a |
1381 # global variable. It forwards all values from the invoker. | 1386 # global variable. It forwards all values from the invoker. |
1382 template("my_wrapper") { | 1387 template("my_wrapper") { |
1383 target(my_wrapper_target_type, target_name) { | 1388 target(my_wrapper_target_type, target_name) { |
1384 forward_variables_from(invoker, "*") | 1389 forward_variables_from(invoker, "*") |
1385 } | 1390 } |
1386 } | 1391 } |
| 1392 |
| 1393 # A template that wraps another. It adds behavior based on one |
| 1394 # variable, and forwards all others to the nested target. |
| 1395 template("my_ios_test_app") { |
| 1396 ios_test_app(target_name) { |
| 1397 forward_variables_from(invoker, "*", ["test_bundle_name"]) |
| 1398 if (!defined(extra_substitutions)) { |
| 1399 extra_substitutions = [] |
| 1400 } |
| 1401 extra_substitutions += [ "BUNDLE_ID_TEST_NAME=$test_bundle_name" ] |
| 1402 } |
| 1403 } |
1387 | 1404 |
1388 | 1405 |
1389 ``` | 1406 ``` |
1390 ## **get_label_info**: Get an attribute from a target's label. | 1407 ## **get_label_info**: Get an attribute from a target's label. |
1391 | 1408 |
1392 ``` | 1409 ``` |
1393 get_label_info(target_label, what) | 1410 get_label_info(target_label, what) |
1394 | 1411 |
1395 Given the label of a target, returns some attribute of that target. | 1412 Given the label of a target, returns some attribute of that target. |
1396 The target need not have been previously defined in the same file, | 1413 The target need not have been previously defined in the same file, |
(...skipping 3808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5205 ** -q**: Quiet mode. Don't print output on success. | 5222 ** -q**: Quiet mode. Don't print output on success. |
5206 ** \--root**: Explicitly specify source root. | 5223 ** \--root**: Explicitly specify source root. |
5207 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. | 5224 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. |
5208 ** \--threads**: Specify number of worker threads. | 5225 ** \--threads**: Specify number of worker threads. |
5209 ** \--time**: Outputs a summary of how long everything took. | 5226 ** \--time**: Outputs a summary of how long everything took. |
5210 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. | 5227 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. |
5211 ** -v**: Verbose logging. | 5228 ** -v**: Verbose logging. |
5212 ** \--version**: Prints the GN version number and exits. | 5229 ** \--version**: Prints the GN version number and exits. |
5213 | 5230 |
5214 ``` | 5231 ``` |
OLD | NEW |