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

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

Issue 2586073002: Revert GN declare_args() change. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | tools/gn/functions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 from 10 Most operations take a build directory. The build arguments are taken from
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 ``` 1634 ```
1635 Introduces the given arguments into the current scope. If they are not 1635 Introduces the given arguments into the current scope. If they are not
1636 specified on the command line or in a toolchain's arguments, the default 1636 specified on the command line or in a toolchain's arguments, the default
1637 values given in the declare_args block will be used. However, these defaults 1637 values given in the declare_args block will be used. However, these defaults
1638 will not override command-line values. 1638 will not override command-line values.
1639 1639
1640 See also "gn help buildargs" for an overview. 1640 See also "gn help buildargs" for an overview.
1641 1641
1642 The precise behavior of declare args is: 1642 The precise behavior of declare args is:
1643 1643
1644 1. The declare_args() block executes. Any variable defined in the enclosing 1644 1. The declare_arg block executes. Any variables in the enclosing scope are
1645 scope is available for reading, but any variable defined earlier in 1645 available for reading.
1646 the current scope is not (since the overrides haven't been applied yet).
1647 1646
1648 2. At the end of executing the block, any variables set within that scope 1647 2. At the end of executing the block, any variables set within that scope
1649 are saved globally as build arguments, with their current values being 1648 are saved globally as build arguments, with their current values being
1650 saved as the "default value" for that argument. 1649 saved as the "default value" for that argument.
1651 1650
1652 3. User-defined overrides are applied. Anything set in "gn args" now 1651 3. User-defined overrides are applied. Anything set in "gn args" now
1653 overrides any default values. The resulting set of variables is promoted 1652 overrides any default values. The resulting set of variables is promoted
1654 to be readable from the following code in the file. 1653 to be readable from the following code in the file.
1655 1654
1656 This has some ramifications that may not be obvious: 1655 This has some ramifications that may not be obvious:
1657 1656
1658 - You should not perform difficult work inside a declare_args block since 1657 - You should not perform difficult work inside a declare_args block since
1659 this only sets a default value that may be discarded. In particular, 1658 this only sets a default value that may be discarded. In particular,
1660 don't use the result of exec_script() to set the default value. If you 1659 don't use the result of exec_script() to set the default value. If you
1661 want to have a script-defined default, set some default "undefined" value 1660 want to have a script-defined default, set some default "undefined" value
1662 like [], "", or -1, and after the declare_args block, call exec_script if 1661 like [], "", or -1, and after the declare_args block, call exec_script if
1663 the value is unset by the user. 1662 the value is unset by the user.
1664 1663
1665 - Because you cannot read the value of a variable defined in the same 1664 - Any code inside of the declare_args block will see the default values of
1666 block, if you need to make the default value of one arg depend 1665 previous variables defined in the block rather than the user-overridden
1667 on the possibly-overridden value of another, write two separate 1666 value. This can be surprising because you will be used to seeing the
1668 declare_args() blocks: 1667 overridden value. If you need to make the default value of one arg
1668 dependent on the possibly-overridden value of another, write two separate
1669 declare_args blocks:
1669 1670
1670 declare_args() { 1671 declare_args() {
1671 enable_foo = true 1672 enable_foo = true
1672 } 1673 }
1673 declare_args() { 1674 declare_args() {
1674 # Bar defaults to same user-overridden state as foo. 1675 # Bar defaults to same user-overridden state as foo.
1675 enable_bar = enable_foo 1676 enable_bar = enable_foo
1676 } 1677 }
1677 1678
1678 ``` 1679 ```
(...skipping 4965 matching lines...) Expand 10 before | Expand all | Expand 10 after
6644 ** \--root**: Explicitly specify source root. 6645 ** \--root**: Explicitly specify source root.
6645 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. 6646 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file.
6646 ** \--script-executable**: Set the executable used to execute scripts. 6647 ** \--script-executable**: Set the executable used to execute scripts.
6647 ** \--threads**: Specify number of worker threads. 6648 ** \--threads**: Specify number of worker threads.
6648 ** \--time**: Outputs a summary of how long everything took. 6649 ** \--time**: Outputs a summary of how long everything took.
6649 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. 6650 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file.
6650 ** -v**: Verbose logging. 6651 ** -v**: Verbose logging.
6651 ** \--version**: Prints the GN version number and exits. 6652 ** \--version**: Prints the GN version number and exits.
6652 6653
6653 ``` 6654 ```
OLDNEW
« no previous file with comments | « no previous file | tools/gn/functions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698