| 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/ninja_target_writer.h" | 14 #include "tools/gn/ninja_target_writer.h" |
| 14 #include "tools/gn/ninja_writer.h" | 15 #include "tools/gn/ninja_writer.h" |
| 15 #include "tools/gn/runtime_deps.h" | 16 #include "tools/gn/runtime_deps.h" |
| 16 #include "tools/gn/scheduler.h" | 17 #include "tools/gn/scheduler.h" |
| 17 #include "tools/gn/setup.h" | 18 #include "tools/gn/setup.h" |
| 18 #include "tools/gn/standard_out.h" | 19 #include "tools/gn/standard_out.h" |
| 19 #include "tools/gn/switches.h" | 20 #include "tools/gn/switches.h" |
| 20 #include "tools/gn/target.h" | 21 #include "tools/gn/target.h" |
| 21 #include "tools/gn/visual_studio_writer.h" | 22 #include "tools/gn/visual_studio_writer.h" |
| 22 | 23 |
| 23 namespace commands { | 24 namespace commands { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 const char kSwitchCheck[] = "check"; | 28 const char kSwitchCheck[] = "check"; |
| 28 const char kSwitchIde[] = "ide"; | 29 const char kSwitchIde[] = "ide"; |
| 30 const char kSwitchIdeValueEclipse[] = "eclipse"; |
| 29 const char kSwitchIdeValueVs[] = "vs"; | 31 const char kSwitchIdeValueVs[] = "vs"; |
| 30 | 32 |
| 31 // Called on worker thread to write the ninja file. | 33 // Called on worker thread to write the ninja file. |
| 32 void BackgroundDoWrite(const Target* target) { | 34 void BackgroundDoWrite(const Target* target) { |
| 33 NinjaTargetWriter::RunAndWriteFile(target); | 35 NinjaTargetWriter::RunAndWriteFile(target); |
| 34 g_scheduler->DecrementWorkCount(); | 36 g_scheduler->DecrementWorkCount(); |
| 35 } | 37 } |
| 36 | 38 |
| 37 // Called on the main thread. | 39 // Called on the main thread. |
| 38 void ItemResolvedCallback(base::subtle::Atomic32* write_counter, | 40 void ItemResolvedCallback(base::subtle::Atomic32* write_counter, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 OutputString(base::StringPrintf("\n%d generated input errors found.\n", | 146 OutputString(base::StringPrintf("\n%d generated input errors found.\n", |
| 145 errors_found), DECORATION_YELLOW); | 147 errors_found), DECORATION_YELLOW); |
| 146 } | 148 } |
| 147 return false; | 149 return false; |
| 148 } | 150 } |
| 149 | 151 |
| 150 bool RunIdeWriter(const std::string& ide, | 152 bool RunIdeWriter(const std::string& ide, |
| 151 const BuildSettings* build_settings, | 153 const BuildSettings* build_settings, |
| 152 Builder* builder, | 154 Builder* builder, |
| 153 Err* err) { | 155 Err* err) { |
| 154 if (ide == kSwitchIdeValueVs) { | 156 base::ElapsedTimer timer; |
| 155 base::ElapsedTimer timer; | 157 if (ide == kSwitchIdeValueEclipse) { |
| 158 bool res = EclipseWriter::RunAndWriteFile(build_settings, builder, err); |
| 159 if (res) { |
| 160 OutputString("Generating Eclipse settings took " + |
| 161 base::Int64ToString(timer.Elapsed().InMilliseconds()) + |
| 162 "ms\n"); |
| 163 } |
| 164 return res; |
| 165 } else if (ide == kSwitchIdeValueVs) { |
| 156 bool res = | 166 bool res = |
| 157 VisualStudioWriter::RunAndWriteFiles(build_settings, builder, err); | 167 VisualStudioWriter::RunAndWriteFiles(build_settings, builder, err); |
| 158 if (res && | 168 if (res && |
| 159 !base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kQuiet)) { | 169 !base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kQuiet)) { |
| 160 OutputString("Generating Visual Studio projects took " + | 170 OutputString("Generating Visual Studio projects took " + |
| 161 base::Int64ToString(timer.Elapsed().InMilliseconds()) + | 171 base::Int64ToString(timer.Elapsed().InMilliseconds()) + |
| 162 "ms\n"); | 172 "ms\n"); |
| 163 } | 173 } |
| 164 return res; | 174 return res; |
| 165 } | 175 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 182 " output directory.\n" | 192 " output directory.\n" |
| 183 "\n" | 193 "\n" |
| 184 " The output directory can be a source-repo-absolute path name such as:\n" | 194 " The output directory can be a source-repo-absolute path name such as:\n" |
| 185 " //out/foo\n" | 195 " //out/foo\n" |
| 186 " Or it can be a directory relative to the current directory such as:\n" | 196 " Or it can be a directory relative to the current directory such as:\n" |
| 187 " out/foo\n" | 197 " out/foo\n" |
| 188 "\n" | 198 "\n" |
| 189 " --ide=<ide_name>\n" | 199 " --ide=<ide_name>\n" |
| 190 " Also generate files for an IDE. Currently supported values:\n" | 200 " Also generate files for an IDE. Currently supported values:\n" |
| 191 " 'vs' - Visual Studio project/solution files.\n" | 201 " 'vs' - Visual Studio project/solution files.\n" |
| 202 " 'eclipse' - Eclipse CDT settings file.\n" |
| 192 "\n" | 203 "\n" |
| 193 " See \"gn help switches\" for the common command-line switches.\n"; | 204 " See \"gn help switches\" for the common command-line switches.\n" |
| 205 "\n" |
| 206 "Eclipse IDE Support\n" |
| 207 "\n" |
| 208 " GN DOES NOT generate Eclipse CDT projects. Instead, it generates a\n" |
| 209 " settings file which can be imported into an Eclipse CDT project. The\n" |
| 210 " XML file contains a list of include paths and defines. Because GN does\n" |
| 211 " not generate a full .cproject definition, it is not possible to\n" |
| 212 " properly define includes/defines for each file individually.\n" |
| 213 " Instead, one set of includes/defines is generated for the entire\n" |
| 214 " project. This works fairly well but may still result in a few indexer\n" |
| 215 " issues here and there.\n"; |
| 194 | 216 |
| 195 int RunGen(const std::vector<std::string>& args) { | 217 int RunGen(const std::vector<std::string>& args) { |
| 196 base::ElapsedTimer timer; | 218 base::ElapsedTimer timer; |
| 197 | 219 |
| 198 if (args.size() != 1) { | 220 if (args.size() != 1) { |
| 199 Err(Location(), "Need exactly one build directory to generate.", | 221 Err(Location(), "Need exactly one build directory to generate.", |
| 200 "I expected something more like \"gn gen out/foo\"\n" | 222 "I expected something more like \"gn gen out/foo\"\n" |
| 201 "You can also see \"gn help gen\".").PrintToStdout(); | 223 "You can also see \"gn help gen\".").PrintToStdout(); |
| 202 return 1; | 224 return 1; |
| 203 } | 225 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 setup->scheduler().input_file_manager()->GetInputFileCount()) + | 281 setup->scheduler().input_file_manager()->GetInputFileCount()) + |
| 260 " files in " + | 282 " files in " + |
| 261 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; | 283 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; |
| 262 OutputString(stats); | 284 OutputString(stats); |
| 263 } | 285 } |
| 264 | 286 |
| 265 return 0; | 287 return 0; |
| 266 } | 288 } |
| 267 | 289 |
| 268 } // namespace commands | 290 } // namespace commands |
| OLD | NEW |