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

Unified Diff: tools/gn/docs/reference.md

Issue 2509333003: Change GN to disallow reading args defined in the same declare_args() call. (Closed)
Patch Set: update w/ review feedback Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: tools/gn/docs/reference.md
diff --git a/tools/gn/docs/reference.md b/tools/gn/docs/reference.md
index 1aa56f1d4542e1623bb07afb7f12549834472f46..ab3233aa4ed5f32d6e2e2bf2388477a6fc5cbea8 100644
--- a/tools/gn/docs/reference.md
+++ b/tools/gn/docs/reference.md
@@ -1641,8 +1641,9 @@
The precise behavior of declare args is:
- 1. The declare_arg block executes. Any variables in the enclosing scope are
- available for reading.
+ 1. The declare_args() block executes. Any variable defined in the enclosing
+ scope is available for reading, but any variable defined earlier in
+ the current scope is not (since the overrides haven't been applied yet).
2. At the end of executing the block, any variables set within that scope
are saved globally as build arguments, with their current values being
@@ -1661,12 +1662,10 @@
like [], "", or -1, and after the declare_args block, call exec_script if
the value is unset by the user.
- - Any code inside of the declare_args block will see the default values of
- previous variables defined in the block rather than the user-overridden
- value. This can be surprising because you will be used to seeing the
- overridden value. If you need to make the default value of one arg
- dependent on the possibly-overridden value of another, write two separate
- declare_args blocks:
+ - Because you cannot read the value of a variable defined in the same
+ block, if you need to make the default value of one arg depend
+ on the possibly-overridden value of another, write two separate
+ declare_args() blocks:
declare_args() {
enable_foo = true
« no previous file with comments | « build/config/ui.gni ('k') | tools/gn/functions.h » ('j') | tools/gn/functions.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698