OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/switches.h" | 5 #include "tools/gn/switches.h" |
6 | 6 |
7 namespace switches { | 7 namespace switches { |
8 | 8 |
9 const char kArgs[] = "args"; | 9 const char kArgs[] = "args"; |
10 const char kArgs_HelpShort[] = | 10 const char kArgs_HelpShort[] = |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 " This will spew logging events to the console for debugging issues.\n" | 156 " This will spew logging events to the console for debugging issues.\n" |
157 " Good luck!\n"; | 157 " Good luck!\n"; |
158 | 158 |
159 const char kVersion[] = "version"; | 159 const char kVersion[] = "version"; |
160 const char kVersion_HelpShort[] = | 160 const char kVersion_HelpShort[] = |
161 "--version: Prints the GN version number and exits."; | 161 "--version: Prints the GN version number and exits."; |
162 // It's impossible to see this since gn_main prints the version and exits | 162 // It's impossible to see this since gn_main prints the version and exits |
163 // immediately if this switch is used. | 163 // immediately if this switch is used. |
164 const char kVersion_Help[] = ""; | 164 const char kVersion_Help[] = ""; |
165 | 165 |
| 166 // ----------------------------------------------------------------------------- |
| 167 |
166 SwitchInfo::SwitchInfo() | 168 SwitchInfo::SwitchInfo() |
167 : short_help(""), | 169 : short_help(""), |
168 long_help("") { | 170 long_help("") { |
169 } | 171 } |
170 | 172 |
171 SwitchInfo::SwitchInfo(const char* short_help, const char* long_help) | 173 SwitchInfo::SwitchInfo(const char* short_help, const char* long_help) |
172 : short_help(short_help), | 174 : short_help(short_help), |
173 long_help(long_help) { | 175 long_help(long_help) { |
174 } | 176 } |
175 | 177 |
| 178 #define INSERT_VARIABLE(var) \ |
| 179 info_map[k##var] = SwitchInfo(k##var##_HelpShort, k##var##_Help); |
| 180 |
176 const SwitchInfoMap& GetSwitches() { | 181 const SwitchInfoMap& GetSwitches() { |
177 static SwitchInfoMap* switches = NULL; | 182 static SwitchInfoMap info_map; |
178 if (!switches) { | 183 if (info_map.empty()) { |
179 switches = new SwitchInfoMap; | 184 INSERT_VARIABLE(Args) |
180 | 185 INSERT_VARIABLE(Color) |
181 (*switches)[kArgs] = SwitchInfo(kArgs_HelpShort, kArgs_Help); | 186 INSERT_VARIABLE(Dotfile) |
182 (*switches)[kColor] = SwitchInfo(kColor_HelpShort, kColor_Help); | 187 INSERT_VARIABLE(NoColor) |
183 (*switches)[kDotfile] = SwitchInfo(kDotfile_HelpShort, kDotfile_Help); | 188 INSERT_VARIABLE(Root) |
184 (*switches)[kNoColor] = SwitchInfo(kNoColor_HelpShort, kNoColor_Help); | 189 INSERT_VARIABLE(Quiet) |
185 (*switches)[kRoot] = SwitchInfo(kRoot_HelpShort, kRoot_Help); | 190 INSERT_VARIABLE(Time) |
186 (*switches)[kQuiet] = SwitchInfo(kQuiet_HelpShort, kQuiet_Help); | 191 INSERT_VARIABLE(Tracelog) |
187 (*switches)[kTime] = SwitchInfo(kTime_HelpShort, kTime_Help); | 192 INSERT_VARIABLE(Verbose) |
188 (*switches)[kTracelog] = SwitchInfo(kTracelog_HelpShort, kTracelog_Help); | 193 INSERT_VARIABLE(Version) |
189 (*switches)[kVerbose] = SwitchInfo(kVerbose_HelpShort, kVerbose_Help); | |
190 (*switches)[kVersion] = SwitchInfo(kVersion_HelpShort, kVersion_Help); | |
191 } | 194 } |
192 return *switches; | 195 return info_map; |
193 } | 196 } |
194 | 197 |
| 198 #undef INSERT_VARIABLE |
| 199 |
195 } // namespace switches | 200 } // namespace switches |
OLD | NEW |