Add window.gc back to Smoothness.WillNavigateToPageHook
[chromium-blink-merge.git] / tools / gn / switches.cc
blob28e42e33a71a77e2401a8b68795f3c5399a1ccf8
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 kMarkdown[] = "markdown";
73 const char kMarkdown_HelpShort[] =
74 "--markdown: write the output in the Markdown format.";
75 const char kMarkdown_Help[] =
76 "--markdown: write the output in the Markdown format.\n";
78 const char kNoColor[] = "nocolor";
79 const char kNoColor_HelpShort[] =
80 "--nocolor: Force non-colored output.";
81 const char kNoColor_Help[] = COLOR_HELP_LONG;
83 const char kQuiet[] = "q";
84 const char kQuiet_HelpShort[] =
85 "-q: Quiet mode. Don't print output on success.";
86 const char kQuiet_Help[] =
87 "-q: Quiet mode. Don't print output on success.\n"
88 "\n"
89 " This is useful when running as a part of another script.\n";
91 const char kRoot[] = "root";
92 const char kRoot_HelpShort[] =
93 "--root: Explicitly specify source root.";
94 const char kRoot_Help[] =
95 "--root: Explicitly specify source root.\n"
96 "\n"
97 " Normally GN will look up in the directory tree from the current\n"
98 " directory to find a \".gn\" file. The source root directory specifies\n"
99 " the meaning of \"//\" beginning with paths, and the BUILD.gn file\n"
100 " in that directory will be the first thing loaded.\n"
101 "\n"
102 " Specifying --root allows GN to do builds in a specific directory\n"
103 " regardless of the current directory.\n"
104 "\n"
105 "Examples\n"
106 "\n"
107 " gn gen //out/Default --root=/home/baracko/src\n"
108 "\n"
109 " gn desc //out/Default --root=\"C:\\Users\\BObama\\My Documents\\foo\"\n";
111 const char kRuntimeDepsListFile[] = "runtime-deps-list-file";
112 const char kRuntimeDepsListFile_HelpShort[] =
113 "--runtime-deps-list-file: Save runtime dependencies for targets in file.";
114 const char kRuntimeDepsListFile_Help[] =
115 "--runtime-deps-list-file: Save runtime dependencies for targets in file.\n"
116 "\n"
117 " --runtime-deps-list-file=<filename>\n"
118 "\n"
119 " Where <filename> is a text file consisting of the labels, one per\n"
120 " line, of the targets for which runtime dependencies are desired.\n"
121 "\n"
122 " See \"gn help runtime_deps\" for a description of how runtime\n"
123 " dependencies are computed.\n"
124 "\n"
125 "Runtime deps output file\n"
126 "\n"
127 " For each target requested, GN will write a separate runtime dependency\n"
128 " file. The runtime dependency file will be in the output directory\n"
129 " alongside the output file of the target, with a \".runtime_deps\"\n"
130 " extension. For example, if the target \"//foo:bar\" is listed in the\n"
131 " input file, and that target produces an output file \"bar.so\", GN\n"
132 " will create a file \"bar.so.runtime_deps\" in the build directory.\n"
133 "\n"
134 " If a source set, action, copy, or group is listed, the runtime deps\n"
135 " file will correspond to the .stamp file corresponding to that target.\n"
136 " This is probably not useful; the use-case for this feature is\n"
137 " generally executable targets.\n"
138 "\n"
139 " The runtime dependency file will list one file per line, with no\n"
140 " escaping. The files will be relative to the root_build_dir. The first\n"
141 " line of the file will be the main output file of the target itself\n"
142 " (in the above example, \"bar.so\").\n";
144 const char kThreads[] = "threads";
145 const char kThreads_HelpShort[] =
146 "--threads: Specify number of worker threads.";
147 const char kThreads_Help[] =
148 "--threads: Specify number of worker threads.\n"
149 "\n"
150 " GN runs many threads to load and run build files. This can make\n"
151 " debugging challenging. Or you may want to experiment with different\n"
152 " values to see how it affects performance.\n"
153 "\n"
154 " The parameter is the number of worker threads. This does not count the\n"
155 " main thread (so there are always at least two).\n"
156 "\n"
157 "Examples\n"
158 "\n"
159 " gen gen out/Default --threads=1\n";
161 const char kTime[] = "time";
162 const char kTime_HelpShort[] =
163 "--time: Outputs a summary of how long everything took.";
164 const char kTime_Help[] =
165 "--time: Outputs a summary of how long everything took.\n"
166 "\n"
167 " Hopefully self-explanatory.\n"
168 "\n"
169 "Examples\n"
170 "\n"
171 " gn gen out/Default --time\n";
173 const char kTracelog[] = "tracelog";
174 const char kTracelog_HelpShort[] =
175 "--tracelog: Writes a Chrome-compatible trace log to the given file.";
176 const char kTracelog_Help[] =
177 "--tracelog: Writes a Chrome-compatible trace log to the given file.\n"
178 "\n"
179 " The trace log will show file loads, executions, scripts, and writes.\n"
180 " This allows performance analysis of the generation step.\n"
181 "\n"
182 " To view the trace, open Chrome and navigate to \"chrome://tracing/\",\n"
183 " then press \"Load\" and specify the file you passed to this parameter.\n"
184 "\n"
185 "Examples\n"
186 "\n"
187 " gn gen out/Default --tracelog=mytrace.trace\n";
189 const char kVerbose[] = "v";
190 const char kVerbose_HelpShort[] =
191 "-v: Verbose logging.";
192 const char kVerbose_Help[] =
193 "-v: Verbose logging.\n"
194 "\n"
195 " This will spew logging events to the console for debugging issues.\n"
196 " Good luck!\n";
198 const char kVersion[] = "version";
199 const char kVersion_HelpShort[] =
200 "--version: Prints the GN version number and exits.";
201 // It's impossible to see this since gn_main prints the version and exits
202 // immediately if this switch is used.
203 const char kVersion_Help[] = "";
205 // -----------------------------------------------------------------------------
207 SwitchInfo::SwitchInfo()
208 : short_help(""),
209 long_help("") {
212 SwitchInfo::SwitchInfo(const char* short_help, const char* long_help)
213 : short_help(short_help),
214 long_help(long_help) {
217 #define INSERT_VARIABLE(var) \
218 info_map[k##var] = SwitchInfo(k##var##_HelpShort, k##var##_Help);
220 const SwitchInfoMap& GetSwitches() {
221 static SwitchInfoMap info_map;
222 if (info_map.empty()) {
223 INSERT_VARIABLE(Args)
224 INSERT_VARIABLE(Color)
225 INSERT_VARIABLE(Dotfile)
226 INSERT_VARIABLE(Markdown)
227 INSERT_VARIABLE(NoColor)
228 INSERT_VARIABLE(Root)
229 INSERT_VARIABLE(Quiet)
230 INSERT_VARIABLE(RuntimeDepsListFile)
231 INSERT_VARIABLE(Time)
232 INSERT_VARIABLE(Tracelog)
233 INSERT_VARIABLE(Verbose)
234 INSERT_VARIABLE(Version)
236 return info_map;
239 #undef INSERT_VARIABLE
241 } // namespace switches