OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/args.h" | 5 #include "tools/gn/args.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "tools/gn/variables.h" | 8 #include "tools/gn/variables.h" |
9 | 9 |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
12 #endif | 12 #endif |
13 | 13 |
14 const char kBuildArgs_Help[] = | 14 const char kBuildArgs_Help[] = |
15 "Build Arguments Overview\n" | 15 "Build Arguments Overview\n" |
16 "\n" | 16 "\n" |
17 " Build arguments are variables passed in from outside of the build\n" | 17 " Build arguments are variables passed in from outside of the build\n" |
18 " that build files can query to determine how the build works.\n" | 18 " that build files can query to determine how the build works.\n" |
19 "\n" | 19 "\n" |
20 "How build arguments are set\n" | 20 "How build arguments are set\n" |
21 "\n" | 21 "\n" |
22 " First, system default arguments are set based on the current system.\n" | 22 " First, system default arguments are set based on the current system.\n" |
23 " The built-in arguments are:\n" | 23 " The built-in arguments are:\n" |
24 " - cpu_arch (by default this is the same as \"default_cpu_arch\")\n" | 24 " - cpu_arch (by default this is the same as \"default_cpu_arch\")\n" |
25 " - default_cpu_arch\n" | 25 " - default_cpu_arch\n" |
26 " - default_os\n" | 26 " - default_os\n" |
27 " - os (by default this is the same as \"default_os\")\n" | 27 " - os (by default this is the same as \"default_os\")\n" |
28 "\n" | 28 "\n" |
29 " Second, arguments specified on the command-line via \"--args\" are\n" | 29 " If specified, arguments from the --args command line flag are used. If\n" |
30 " applied. These can override the system default ones, and add new ones.\n" | 30 " that flag is not specified, args from previous builds in the build\n" |
31 " These are whitespace-separated. For example:\n" | 31 " directory will be used (this is in the file gn.args in the build\n" |
tfarina
2014/05/01 18:06:46
so does that mean the sequence of commands you be
| |
32 " directory).\n" | |
32 "\n" | 33 "\n" |
33 " gn --args=\"enable_doom_melon=false\" os=\\\"beos\\\"\n" | 34 " Last, for targets being compiled with a non-default toolchain, the\n" |
34 "\n" | 35 " toolchain overrides are applied. These are specified in the\n" |
35 " Third, toolchain overrides are applied. These are specified in the\n" | |
36 " toolchain_args section of a toolchain definition. The use-case for\n" | 36 " toolchain_args section of a toolchain definition. The use-case for\n" |
37 " this is that a toolchain may be building code for a different\n" | 37 " this is that a toolchain may be building code for a different\n" |
38 " platform, and that it may want to always specify Posix, for example.\n" | 38 " platform, and that it may want to always specify Posix, for example.\n" |
39 " See \"gn help toolchain_args\" for more.\n" | 39 " See \"gn help toolchain_args\" for more.\n" |
40 "\n" | 40 "\n" |
41 " It is an error to specify an override for a build argument that never\n" | 41 " If you specify an override for a build argument that never appears in\n" |
42 " appears in a \"declare_args\" call.\n" | 42 " a \"declare_args\" call, a nonfatal error will be displayed.\n" |
43 "\n" | |
44 "Examples\n" | |
45 "\n" | |
46 " gn args out/FooBar\n" | |
47 " Create the directory out/FooBar and open an editor. You would type\n" | |
48 " something like this into that file:\n" | |
49 " enable_doom_melon=false\n" | |
50 " os=\"android\"\n" | |
51 "\n" | |
52 " gn gen out/FooBar --args=\"enable_doom_melon=true os=\\\"android\\\"\"\n" | |
53 " This will overwrite the build directory with the given arguments.\n" | |
54 " (Note that the quotes inside the args command will usually need to\n" | |
55 " be escaped for your shell to pass through strings values.)\n" | |
43 "\n" | 56 "\n" |
44 "How build arguments are used\n" | 57 "How build arguments are used\n" |
45 "\n" | 58 "\n" |
46 " If you want to use an argument, you use declare_args() and specify\n" | 59 " If you want to use an argument, you use declare_args() and specify\n" |
47 " default values. These default values will apply if none of the steps\n" | 60 " default values. These default values will apply if none of the steps\n" |
48 " listed in the \"How build arguments are set\" section above apply to\n" | 61 " listed in the \"How build arguments are set\" section above apply to\n" |
49 " the given argument, but the defaults will not override any of these.\n" | 62 " the given argument, but the defaults will not override any of these.\n" |
50 "\n" | 63 "\n" |
51 " Often, the root build config file will declare global arguments that\n" | 64 " Often, the root build config file will declare global arguments that\n" |
52 " will be passed to all buildfiles. Individual build files can also\n" | 65 " will be passed to all buildfiles. Individual build files can also\n" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 i != values.end(); ++i) | 291 i != values.end(); ++i) |
279 scope->SetValue(i->first, i->second, i->second.origin()); | 292 scope->SetValue(i->first, i->second, i->second.origin()); |
280 } | 293 } |
281 | 294 |
282 void Args::SaveOverrideRecordLocked(const Scope::KeyValueMap& values) const { | 295 void Args::SaveOverrideRecordLocked(const Scope::KeyValueMap& values) const { |
283 lock_.AssertAcquired(); | 296 lock_.AssertAcquired(); |
284 for (Scope::KeyValueMap::const_iterator i = values.begin(); | 297 for (Scope::KeyValueMap::const_iterator i = values.begin(); |
285 i != values.end(); ++i) | 298 i != values.end(); ++i) |
286 all_overrides_[i->first] = i->second; | 299 all_overrides_[i->first] = i->second; |
287 } | 300 } |
OLD | NEW |