[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / tools / gn / switches.cc
blob5e383e1c26fe67fdec0cbe29c5eb4532483c04fb
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "tools/gn/switches.h"
7 namespace switches {
9 const char kArgs[] = "args";
10 const char kArgs_HelpShort[] =
11 "--args: Specifies build arguments overrides.";
12 const char kArgs_Help[] =
13 "--args: Specifies build arguments overrides.\n"
14 "\n"
15 " See \"gn help buildargs\" for an overview of how build arguments work.\n"
16 "\n"
17 " Most operations take a build directory. The build arguments are taken\n"
18 " from the previous build done in that directory. If a command specifies\n"
19 " --args, it will override the previous arguments stored in the build\n"
20 " directory, and use the specified ones.\n"
21 "\n"
22 " The args specified will be saved to the build directory for subsequent\n"
23 " commands. Specifying --args=\"\" will clear all build arguments.\n"
24 "\n"
25 "Formatting\n"
26 "\n"
27 " The value of the switch is interpreted in GN syntax. For typical usage\n"
28 " of string arguments, you will need to be careful about escaping of\n"
29 " quotes.\n"
30 "\n"
31 "Examples\n"
32 "\n"
33 " gn gen out/Default --args=\"foo=\\\"bar\\\"\"\n"
34 "\n"
35 " gn gen out/Default --args='foo=\"bar\" enable=true blah=7'\n"
36 "\n"
37 " gn check out/Default --args=\"\"\n"
38 " Clears existing build args from the directory.\n"
39 "\n"
40 " gn desc out/Default --args=\"some_list=[1, false, \\\"foo\\\"]\"\n";
42 #define COLOR_HELP_LONG \
43 "--[no]color: Forces colored output on or off.\n"\
44 "\n"\
45 " Normally GN will try to detect whether it is outputting to a terminal\n"\
46 " and will enable or disable color accordingly. Use of these switches\n"\
47 " will override the default.\n"\
48 "\n"\
49 "Examples\n"\
50 "\n"\
51 " gn gen out/Default --color\n"\
52 "\n"\
53 " gn gen out/Default --nocolor\n"
54 const char kColor[] = "color";
55 const char kColor_HelpShort[] =
56 "--color: Force colored output.";
57 const char kColor_Help[] = COLOR_HELP_LONG;
59 const char kDotfile[] = "dotfile";
60 const char kDotfile_HelpShort[] =
61 "--dotfile: override the name of the \".gn\" file.";
62 const char kDotfile_Help[] =
63 "--dotfile: override the name of the \".gn\" file.\n"
64 "\n"
65 " Normally GN loads the \".gn\"file from the source root for some basic\n"
66 " configuration (see \"gn help dotfile\"). This flag allows you to\n"
67 " use a different file.\n"
68 "\n"
69 " Note that this interacts with \"--root\" in a possibly incorrect way.\n"
70 " It would be nice to test the edge cases and document or fix.\n";
72 const char kNoColor[] = "nocolor";
73 const char kNoColor_HelpShort[] =
74 "--nocolor: Force non-colored output.";
75 const char kNoColor_Help[] = COLOR_HELP_LONG;
77 const char kQuiet[] = "q";
78 const char kQuiet_HelpShort[] =
79 "-q: Quiet mode. Don't print output on success.";
80 const char kQuiet_Help[] =
81 "-q: Quiet mode. Don't print output on success.\n"
82 "\n"
83 " This is useful when running as a part of another script.\n";
85 const char kRoot[] = "root";
86 const char kRoot_HelpShort[] =
87 "--root: Explicitly specify source root.";
88 const char kRoot_Help[] =
89 "--root: Explicitly specify source root.\n"
90 "\n"
91 " Normally GN will look up in the directory tree from the current\n"
92 " directory to find a \".gn\" file. The source root directory specifies\n"
93 " the meaning of \"//\" beginning with paths, and the BUILD.gn file\n"
94 " in that directory will be the first thing loaded.\n"
95 "\n"
96 " Specifying --root allows GN to do builds in a specific directory\n"
97 " regardless of the current directory.\n"
98 "\n"
99 "Examples\n"
100 "\n"
101 " gn gen //out/Default --root=/home/baracko/src\n"
102 "\n"
103 " gn desc //out/Default --root=\"C:\\Users\\BObama\\My Documents\\foo\"\n";
105 const char kThreads[] = "threads";
106 const char kThreads_HelpShort[] =
107 "--threads: Specify number of worker threads.";
108 const char kThreads_Help[] =
109 "--threads: Specify number of worker threads.\n"
110 "\n"
111 " GN runs many threads to load and run build files. This can make\n"
112 " debugging challenging. Or you may want to experiment with different\n"
113 " values to see how it affects performance.\n"
114 "\n"
115 " The parameter is the number of worker threads. This does not count the\n"
116 " main thread (so there are always at least two).\n"
117 "\n"
118 "Examples\n"
119 "\n"
120 " gen gen out/Default --threads=1\n";
122 const char kTime[] = "time";
123 const char kTime_HelpShort[] =
124 "--time: Outputs a summary of how long everything took.";
125 const char kTime_Help[] =
126 "--time: Outputs a summary of how long everything took.\n"
127 "\n"
128 " Hopefully self-explanatory.\n"
129 "\n"
130 "Examples\n"
131 "\n"
132 " gn gen out/Default --time\n";
134 const char kTracelog[] = "tracelog";
135 const char kTracelog_HelpShort[] =
136 "--tracelog: Writes a Chrome-compatible trace log to the given file.";
137 const char kTracelog_Help[] =
138 "--tracelog: Writes a Chrome-compatible trace log to the given file.\n"
139 "\n"
140 " The trace log will show file loads, executions, scripts, and writes.\n"
141 " This allows performance analysis of the generation step.\n"
142 "\n"
143 " To view the trace, open Chrome and navigate to \"chrome://tracing/\",\n"
144 " then press \"Load\" and specify the file you passed to this parameter.\n"
145 "\n"
146 "Examples\n"
147 "\n"
148 " gn gen out/Default --tracelog=mytrace.trace\n";
150 const char kVerbose[] = "v";
151 const char kVerbose_HelpShort[] =
152 "-v: Verbose logging.";
153 const char kVerbose_Help[] =
154 "-v: Verbose logging.\n"
155 "\n"
156 " This will spew logging events to the console for debugging issues.\n"
157 " Good luck!\n";
159 const char kVersion[] = "version";
160 const char kVersion_HelpShort[] =
161 "--version: Prints the GN version number and exits.";
162 // It's impossible to see this since gn_main prints the version and exits
163 // immediately if this switch is used.
164 const char kVersion_Help[] = "";
166 // -----------------------------------------------------------------------------
168 SwitchInfo::SwitchInfo()
169 : short_help(""),
170 long_help("") {
173 SwitchInfo::SwitchInfo(const char* short_help, const char* long_help)
174 : short_help(short_help),
175 long_help(long_help) {
178 #define INSERT_VARIABLE(var) \
179 info_map[k##var] = SwitchInfo(k##var##_HelpShort, k##var##_Help);
181 const SwitchInfoMap& GetSwitches() {
182 static SwitchInfoMap info_map;
183 if (info_map.empty()) {
184 INSERT_VARIABLE(Args)
185 INSERT_VARIABLE(Color)
186 INSERT_VARIABLE(Dotfile)
187 INSERT_VARIABLE(NoColor)
188 INSERT_VARIABLE(Root)
189 INSERT_VARIABLE(Quiet)
190 INSERT_VARIABLE(Time)
191 INSERT_VARIABLE(Tracelog)
192 INSERT_VARIABLE(Verbose)
193 INSERT_VARIABLE(Version)
195 return info_map;
198 #undef INSERT_VARIABLE
200 } // namespace switches