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