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

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

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

Powered by Google App Engine
This is Rietveld 408576698