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

Unified Diff: tools/gn/functions.cc

Issue 1386713002: Make GN use_custom_libcxx work properly with sanitizers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Typo Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/config/sanitizers/sanitizers.gni ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/functions.cc
diff --git a/tools/gn/functions.cc b/tools/gn/functions.cc
index 86043f0a73ab930c5c00fd28832e434b7a208331..01d0aeb027b04b2ee36467ff99b2577392ffb360 100644
--- a/tools/gn/functions.cc
+++ b/tools/gn/functions.cc
@@ -344,7 +344,46 @@ const char kDeclareArgs_Help[] =
"\n"
" See also \"gn help buildargs\" for an overview.\n"
"\n"
- "Example:\n"
+ " The precise behavior of declare args is:\n"
+ "\n"
+ " 1. The declare_arg block executes. Any variables in the enclosing\n"
+ " scope are available for reading.\n"
+ "\n"
+ " 2. At the end of executing the block, any variables set within that\n"
+ " scope are saved globally as build arguments, with their current\n"
+ " values being saved as the \"default value\" for that argument.\n"
+ "\n"
+ " 3. User-defined overrides are applied. Anything set in \"gn args\"\n"
+ " now overrides any default values. The resulting set of variables\n"
+ " is promoted to be readable from the following code in the file.\n"
+ "\n"
+ " This has some ramifications that may not be obvious:\n"
+ "\n"
+ " - You should not perform difficult work inside a declare_args block\n"
+ " since this only sets a default value that may be discarded. In\n"
+ " particular, don't use the result of exec_script() to set the\n"
+ " default value. If you want to have a script-defined default, set\n"
+ " some default \"undefined\" value like [], \"\", or -1, and after\n"
+ " the declare_args block, call exec_script if the value is unset by\n"
+ " the user.\n"
+ "\n"
+ " - Any code inside of the declare_args block will see the default\n"
+ " values of previous variables defined in the block rather than\n"
+ " the user-overridden value. This can be surprising because you will\n"
+ " be used to seeing the overridden value. If you need to make the\n"
+ " default value of one arg dependent on the possibly-overridden\n"
+ " value of another, write two separate declare_args blocks:\n"
+ "\n"
+ " declare_args() {\n"
+ " enable_foo = true\n"
+ " }\n"
+ " declare_args() {\n"
+ " # Bar defaults to same user-overridden state as foo.\n"
+ " enable_bar = enable_foo\n"
+ " }\n"
+ "\n"
+ "Example\n"
+ "\n"
" declare_args() {\n"
" enable_teleporter = true\n"
" enable_doom_melon = false\n"
« no previous file with comments | « build/config/sanitizers/sanitizers.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698