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

Side by Side Diff: tools/gn/args.cc

Issue 2470643002: Allow raw string literals and add a sample usage. (Closed)
Patch Set: Resync 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 unified diff | Download patch
« no previous file with comments | « styleguide/c++/c++11.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/sys_info.h" 7 #include "base/sys_info.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "tools/gn/variables.h" 9 #include "tools/gn/variables.h"
10 10
11 const char kBuildArgs_Help[] = 11 const char kBuildArgs_Help[] =
12 "Build Arguments Overview\n" 12 R"(Build Arguments Overview
13 "\n" 13
14 " Build arguments are variables passed in from outside of the build\n" 14 Build arguments are variables passed in from outside of the build
15 " that build files can query to determine how the build works.\n" 15 that build files can query to determine how the build works.
16 "\n" 16
17 "How build arguments are set\n" 17 How build arguments are set
18 "\n" 18
19 " First, system default arguments are set based on the current system.\n" 19 First, system default arguments are set based on the current system.
20 " The built-in arguments are:\n" 20 The built-in arguments are:
21 " - host_cpu\n" 21 - host_cpu
22 " - host_os\n" 22 - host_os
23 " - current_cpu\n" 23 - current_cpu
24 " - current_os\n" 24 - current_os
25 " - target_cpu\n" 25 - target_cpu
26 " - target_os\n" 26 - target_os
27 "\n" 27
28 " If specified, arguments from the --args command line flag are used. If\n" 28 If specified, arguments from the --args command line flag are used. If
29 " that flag is not specified, args from previous builds in the build\n" 29 that flag is not specified, args from previous builds in the build
30 " directory will be used (this is in the file args.gn in the build\n" 30 directory will be used (this is in the file args.gn in the build
31 " directory).\n" 31 directory).
32 "\n" 32
33 " Last, for targets being compiled with a non-default toolchain, the\n" 33 Last, for targets being compiled with a non-default toolchain, the
34 " toolchain overrides are applied. These are specified in the\n" 34 toolchain overrides are applied. These are specified in the
35 " toolchain_args section of a toolchain definition. The use-case for\n" 35 toolchain_args section of a toolchain definition. The use-case for
36 " this is that a toolchain may be building code for a different\n" 36 this is that a toolchain may be building code for a different
37 " platform, and that it may want to always specify Posix, for example.\n" 37 platform, and that it may want to always specify Posix, for example.
38 " See \"gn help toolchain\" for more.\n" 38 See "gn help toolchain" for more.
39 "\n" 39
40 " If you specify an override for a build argument that never appears in\n" 40 If you specify an override for a build argument that never appears in
41 " a \"declare_args\" call, a nonfatal error will be displayed.\n" 41 a "declare_args" call, a nonfatal error will be displayed.
42 "\n" 42
43 "Examples\n" 43 Examples
44 "\n" 44
45 " gn args out/FooBar\n" 45 gn args out/FooBar
46 " Create the directory out/FooBar and open an editor. You would type\n" 46 Create the directory out/FooBar and open an editor. You would type
47 " something like this into that file:\n" 47 something like this into that file:
48 " enable_doom_melon=false\n" 48 enable_doom_melon=false
49 " os=\"android\"\n" 49 os="android"
50 "\n" 50
51 " gn gen out/FooBar --args=\"enable_doom_melon=true os=\\\"android\\\"\"\n" 51 gn gen out/FooBar --args="enable_doom_melon=true os=\"android\""
52 " This will overwrite the build directory with the given arguments.\n" 52 This will overwrite the build directory with the given arguments.
53 " (Note that the quotes inside the args command will usually need to\n" 53 (Note that the quotes inside the args command will usually need to
54 " be escaped for your shell to pass through strings values.)\n" 54 be escaped for your shell to pass through strings values.)
55 "\n" 55
56 "How build arguments are used\n" 56 How build arguments are used
57 "\n" 57
58 " If you want to use an argument, you use declare_args() and specify\n" 58 If you want to use an argument, you use declare_args() and specify
59 " default values. These default values will apply if none of the steps\n" 59 default values. These default values will apply if none of the steps
60 " listed in the \"How build arguments are set\" section above apply to\n" 60 listed in the "How build arguments are set" section above apply to
61 " the given argument, but the defaults will not override any of these.\n" 61 the given argument, but the defaults will not override any of these.
62 "\n" 62
63 " Often, the root build config file will declare global arguments that\n" 63 Often, the root build config file will declare global arguments that
64 " will be passed to all buildfiles. Individual build files can also\n" 64 will be passed to all buildfiles. Individual build files can also
65 " specify arguments that apply only to those files. It is also useful\n" 65 specify arguments that apply only to those files. It is also useful
66 " to specify build args in an \"import\"-ed file if you want such\n" 66 to specify build args in an "import"-ed file if you want such
67 " arguments to apply to multiple buildfiles.\n"; 67 arguments to apply to multiple buildfiles.
68 )";
68 69
69 namespace { 70 namespace {
70 71
71 // Removes all entries in |overrides| that are in |declared_overrides|. 72 // Removes all entries in |overrides| that are in |declared_overrides|.
72 void RemoveDeclaredOverrides(const Scope::KeyValueMap& declared_arguments, 73 void RemoveDeclaredOverrides(const Scope::KeyValueMap& declared_arguments,
73 Scope::KeyValueMap* overrides) { 74 Scope::KeyValueMap* overrides) {
74 for (Scope::KeyValueMap::iterator override = overrides->begin(); 75 for (Scope::KeyValueMap::iterator override = overrides->begin();
75 override != overrides->end();) { 76 override != overrides->end();) {
76 if (declared_arguments.find(override->first) == declared_arguments.end()) 77 if (declared_arguments.find(override->first) == declared_arguments.end())
77 ++override; 78 ++override;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 Scope* scope) const { 355 Scope* scope) const {
355 lock_.AssertAcquired(); 356 lock_.AssertAcquired();
356 return declared_arguments_per_toolchain_[scope->settings()]; 357 return declared_arguments_per_toolchain_[scope->settings()];
357 } 358 }
358 359
359 Scope::KeyValueMap& Args::OverridesForToolchainLocked( 360 Scope::KeyValueMap& Args::OverridesForToolchainLocked(
360 Scope* scope) const { 361 Scope* scope) const {
361 lock_.AssertAcquired(); 362 lock_.AssertAcquired();
362 return toolchain_overrides_[scope->settings()]; 363 return toolchain_overrides_[scope->settings()];
363 } 364 }
OLDNEW
« no previous file with comments | « styleguide/c++/c++11.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698