OLD | NEW |
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 "base/atomicops.h" | 5 #include "base/atomicops.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
11 #include "tools/gn/build_settings.h" | 11 #include "tools/gn/build_settings.h" |
12 #include "tools/gn/commands.h" | 12 #include "tools/gn/commands.h" |
13 #include "tools/gn/eclipse_writer.h" | 13 #include "tools/gn/eclipse_writer.h" |
14 #include "tools/gn/ninja_target_writer.h" | 14 #include "tools/gn/ninja_target_writer.h" |
15 #include "tools/gn/ninja_writer.h" | 15 #include "tools/gn/ninja_writer.h" |
16 #include "tools/gn/runtime_deps.h" | 16 #include "tools/gn/runtime_deps.h" |
17 #include "tools/gn/scheduler.h" | 17 #include "tools/gn/scheduler.h" |
18 #include "tools/gn/setup.h" | 18 #include "tools/gn/setup.h" |
19 #include "tools/gn/standard_out.h" | 19 #include "tools/gn/standard_out.h" |
20 #include "tools/gn/switches.h" | 20 #include "tools/gn/switches.h" |
21 #include "tools/gn/target.h" | 21 #include "tools/gn/target.h" |
22 #include "tools/gn/visual_studio_writer.h" | 22 #include "tools/gn/visual_studio_writer.h" |
| 23 #include "tools/gn/xcode_writer.h" |
23 | 24 |
24 namespace commands { | 25 namespace commands { |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 const char kSwitchCheck[] = "check"; | 29 const char kSwitchCheck[] = "check"; |
29 const char kSwitchFilters[] = "filters"; | 30 const char kSwitchFilters[] = "filters"; |
30 const char kSwitchIde[] = "ide"; | 31 const char kSwitchIde[] = "ide"; |
31 const char kSwitchIdeValueEclipse[] = "eclipse"; | 32 const char kSwitchIdeValueEclipse[] = "eclipse"; |
32 const char kSwitchIdeValueVs[] = "vs"; | 33 const char kSwitchIdeValueVs[] = "vs"; |
33 const char kSwitchIdeValueVs2013[] = "vs2013"; | 34 const char kSwitchIdeValueVs2013[] = "vs2013"; |
34 const char kSwitchIdeValueVs2015[] = "vs2015"; | 35 const char kSwitchIdeValueVs2015[] = "vs2015"; |
| 36 const char kSwitchIdeValueXcode[] = "xcode"; |
| 37 const char kSwitchNinjaExtraArgs[] = "ninja-extra-args"; |
| 38 const char kSwitchRootTarget[] = "root-target"; |
35 const char kSwitchSln[] = "sln"; | 39 const char kSwitchSln[] = "sln"; |
| 40 const char kSwitchWorkspace[] = "workspace"; |
36 | 41 |
37 // Called on worker thread to write the ninja file. | 42 // Called on worker thread to write the ninja file. |
38 void BackgroundDoWrite(const Target* target) { | 43 void BackgroundDoWrite(const Target* target) { |
39 NinjaTargetWriter::RunAndWriteFile(target); | 44 NinjaTargetWriter::RunAndWriteFile(target); |
40 g_scheduler->DecrementWorkCount(); | 45 g_scheduler->DecrementWorkCount(); |
41 } | 46 } |
42 | 47 |
43 // Called on the main thread. | 48 // Called on the main thread. |
44 void ItemResolvedCallback(base::subtle::Atomic32* write_counter, | 49 void ItemResolvedCallback(base::subtle::Atomic32* write_counter, |
45 scoped_refptr<Builder> builder, | 50 scoped_refptr<Builder> builder, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 if (command_line->HasSwitch(kSwitchFilters)) | 186 if (command_line->HasSwitch(kSwitchFilters)) |
182 filters = command_line->GetSwitchValueASCII(kSwitchFilters); | 187 filters = command_line->GetSwitchValueASCII(kSwitchFilters); |
183 bool res = VisualStudioWriter::RunAndWriteFiles( | 188 bool res = VisualStudioWriter::RunAndWriteFiles( |
184 build_settings, builder, version, sln_name, filters, err); | 189 build_settings, builder, version, sln_name, filters, err); |
185 if (res && !command_line->HasSwitch(switches::kQuiet)) { | 190 if (res && !command_line->HasSwitch(switches::kQuiet)) { |
186 OutputString("Generating Visual Studio projects took " + | 191 OutputString("Generating Visual Studio projects took " + |
187 base::Int64ToString(timer.Elapsed().InMilliseconds()) + | 192 base::Int64ToString(timer.Elapsed().InMilliseconds()) + |
188 "ms\n"); | 193 "ms\n"); |
189 } | 194 } |
190 return res; | 195 return res; |
| 196 } else if (ide == kSwitchIdeValueXcode) { |
| 197 bool res = XcodeWriter::RunAndWriteFiles( |
| 198 command_line->GetSwitchValueASCII(kSwitchWorkspace), |
| 199 command_line->GetSwitchValueASCII(kSwitchRootTarget), |
| 200 command_line->GetSwitchValueASCII(kSwitchNinjaExtraArgs), |
| 201 command_line->GetSwitchValueASCII(kSwitchFilters), build_settings, |
| 202 builder, err); |
| 203 if (res && !command_line->HasSwitch(switches::kQuiet)) { |
| 204 OutputString("Generating Xcode projects took " + |
| 205 base::Int64ToString(timer.Elapsed().InMilliseconds()) + |
| 206 "ms\n"); |
| 207 } |
| 208 return res; |
191 } | 209 } |
192 | 210 |
193 *err = Err(Location(), "Unknown IDE: " + ide); | 211 *err = Err(Location(), "Unknown IDE: " + ide); |
194 return false; | 212 return false; |
195 } | 213 } |
196 | 214 |
197 } // namespace | 215 } // namespace |
198 | 216 |
199 const char kGen[] = "gen"; | 217 const char kGen[] = "gen"; |
200 const char kGen_HelpShort[] = | 218 const char kGen_HelpShort[] = |
(...skipping 17 matching lines...) Expand all Loading... |
218 "\n" | 236 "\n" |
219 " GN optionally generates files for IDE. Possibilities for <ide options>\n" | 237 " GN optionally generates files for IDE. Possibilities for <ide options>\n" |
220 "\n" | 238 "\n" |
221 " --ide=<ide_name>\n" | 239 " --ide=<ide_name>\n" |
222 " Generate files for an IDE. Currently supported values:\n" | 240 " Generate files for an IDE. Currently supported values:\n" |
223 " \"eclipse\" - Eclipse CDT settings file.\n" | 241 " \"eclipse\" - Eclipse CDT settings file.\n" |
224 " \"vs\" - Visual Studio project/solution files.\n" | 242 " \"vs\" - Visual Studio project/solution files.\n" |
225 " (default Visual Studio version: 2015)\n" | 243 " (default Visual Studio version: 2015)\n" |
226 " \"vs2013\" - Visual Studio 2013 project/solution files.\n" | 244 " \"vs2013\" - Visual Studio 2013 project/solution files.\n" |
227 " \"vs2015\" - Visual Studio 2015 project/solution files.\n" | 245 " \"vs2015\" - Visual Studio 2015 project/solution files.\n" |
228 "\n" | 246 " \"xcode\" - Xcode workspace/solution files.\n" |
229 " --sln=<file_name>\n" | |
230 " Override default sln file name (\"all\"). Solution file is written\n" | |
231 " to the root build directory. Only for Visual Studio.\n" | |
232 "\n" | 247 "\n" |
233 " --filters=<path_prefixes>\n" | 248 " --filters=<path_prefixes>\n" |
234 " Semicolon-separated list of label patterns used to limit the set\n" | 249 " Semicolon-separated list of label patterns used to limit the set\n" |
235 " of generated projects (see \"gn help label_pattern\"). Only\n" | 250 " of generated projects (see \"gn help label_pattern\"). Only\n" |
236 " matching targets will be included to the solution. Only for Visual\n" | 251 " matching targets will be included to the solution. Only used for\n" |
237 " Studio.\n" | 252 " Visual Studio and Xcode.\n" |
| 253 "\n" |
| 254 "Visual Studio Flags\n" |
| 255 "\n" |
| 256 " --sln=<file_name>\n" |
| 257 " Override default sln file name (\"all\"). Solution file is written\n" |
| 258 " to the root build directory.\n" |
| 259 "\n" |
| 260 "Xcode Flags\n" |
| 261 "\n" |
| 262 " --workspace=<file_name>\n" |
| 263 " Override defaut workspace file name (\"all\"). The workspace file\n" |
| 264 " is written to the root build directory.\n" |
| 265 "\n" |
| 266 " --ninja-extra-args=<string>\n" |
| 267 " This string is passed without any quoting to the ninja invocation\n" |
| 268 " command-line. Can be used to configure ninja flags, like \"-j\" if\n" |
| 269 " using goma for example.\n" |
| 270 "\n" |
| 271 " --root-target=<target_name>\n" |
| 272 " Name of the target corresponding to \"All\" target in Xcode. If\n" |
| 273 " unset, \"All\" invokes ninja without any target thus build all the\n" |
| 274 " targets.\n" |
238 "\n" | 275 "\n" |
239 "Eclipse IDE Support\n" | 276 "Eclipse IDE Support\n" |
240 "\n" | 277 "\n" |
241 " GN DOES NOT generate Eclipse CDT projects. Instead, it generates a\n" | 278 " GN DOES NOT generate Eclipse CDT projects. Instead, it generates a\n" |
242 " settings file which can be imported into an Eclipse CDT project. The\n" | 279 " settings file which can be imported into an Eclipse CDT project. The\n" |
243 " XML file contains a list of include paths and defines. Because GN does\n" | 280 " XML file contains a list of include paths and defines. Because GN does\n" |
244 " not generate a full .cproject definition, it is not possible to\n" | 281 " not generate a full .cproject definition, it is not possible to\n" |
245 " properly define includes/defines for each file individually.\n" | 282 " properly define includes/defines for each file individually.\n" |
246 " Instead, one set of includes/defines is generated for the entire\n" | 283 " Instead, one set of includes/defines is generated for the entire\n" |
247 " project. This works fairly well but may still result in a few indexer\n" | 284 " project. This works fairly well but may still result in a few indexer\n" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 setup->scheduler().input_file_manager()->GetInputFileCount()) + | 351 setup->scheduler().input_file_manager()->GetInputFileCount()) + |
315 " files in " + | 352 " files in " + |
316 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; | 353 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; |
317 OutputString(stats); | 354 OutputString(stats); |
318 } | 355 } |
319 | 356 |
320 return 0; | 357 return 0; |
321 } | 358 } |
322 | 359 |
323 } // namespace commands | 360 } // namespace commands |
OLD | NEW |