Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2362)

Unified Diff: tools/gn/command_gen.cc

Issue 1570113002: Visual Studio generators for GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move XmlElementWriter to separate file + minor fixes Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/gn/command_gen.cc
diff --git a/tools/gn/command_gen.cc b/tools/gn/command_gen.cc
index a8221a6d078283ce05310a18f6ea0763e8ca6725..f85a299b303d2fa89963c7fc21a0ccaaa04bc897 100644
--- a/tools/gn/command_gen.cc
+++ b/tools/gn/command_gen.cc
@@ -18,12 +18,15 @@
#include "tools/gn/standard_out.h"
#include "tools/gn/switches.h"
#include "tools/gn/target.h"
+#include "tools/gn/visual_studio_writer.h"
namespace commands {
namespace {
const char kSwitchCheck[] = "check";
+const char kSwitchIde[] = "ide";
+const char kSwitchIdeValueVs[] = "vs";
// Called on worker thread to write the ninja file.
void BackgroundDoWrite(const Target* target) {
@@ -144,6 +147,29 @@ bool CheckForInvalidGeneratedInputs(Setup* setup) {
return false;
}
+bool RunIdeWriter(const std::string& ide,
+ const BuildSettings* build_settings,
+ Builder* builder,
+ Err* err) {
+ if (ide == kSwitchIdeValueVs) {
+ base::TimeTicks begin_vs_gen = base::TimeTicks::Now();
+ bool res =
+ VisualStudioWriter::RunAndWriteFiles(build_settings, builder, err);
+ if (res &&
+ !base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kQuiet)) {
+ OutputString(
+ "Generating Visual Studio projects took " +
+ base::Int64ToString(
+ (base::TimeTicks::Now() - begin_vs_gen).InMilliseconds()) +
+ "ms\n");
+ }
+ return res;
+ }
+
+ *err = Err(Location(), "Unknown IDE: " + ide);
+ return false;
+}
+
} // namespace
const char kGen[] = "gen";
@@ -152,7 +178,7 @@ const char kGen_HelpShort[] =
const char kGen_Help[] =
"gn gen: Generate ninja files.\n"
"\n"
- " gn gen <out_dir>\n"
+ " gn gen [--ide=<ide_name>] <out_dir>\n"
"\n"
" Generates ninja files from the current tree and puts them in the given\n"
" output directory.\n"
@@ -162,6 +188,10 @@ const char kGen_Help[] =
" Or it can be a directory relative to the current directory such as:\n"
" out/foo\n"
"\n"
+ " --ide=<ide_name>\n"
+ " Also generate files for an IDE. Currently supported values:\n"
+ " 'vs' - Visual Studio project/solution files.\n"
+ "\n"
" See \"gn help switches\" for the common command-line switches.\n";
int RunGen(const std::vector<std::string>& args) {
@@ -179,7 +209,9 @@ int RunGen(const std::vector<std::string>& args) {
if (!setup->DoSetup(args[0], true))
return 1;
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchCheck))
+ const base::CommandLine* command_line =
+ base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(kSwitchCheck))
setup->set_check_public_headers(true);
// Cause the load to also generate the ninja files for each target. We wrap
@@ -210,9 +242,16 @@ int RunGen(const std::vector<std::string>& args) {
if (!CheckForInvalidGeneratedInputs(setup))
return 1;
+ if (command_line->HasSwitch(kSwitchIde) &&
+ !RunIdeWriter(command_line->GetSwitchValueASCII(kSwitchIde),
+ &setup->build_settings(), setup->builder(), &err)) {
+ err.PrintToStdout();
+ return 1;
+ }
+
base::TimeDelta elapsed_time = timer.Elapsed();
- if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kQuiet)) {
+ if (!command_line->HasSwitch(switches::kQuiet)) {
OutputString("Done. ", DECORATION_GREEN);
std::string stats = "Wrote " +
« no previous file with comments | « tools/gn/BUILD.gn ('k') | tools/gn/gn.gyp » ('j') | tools/gn/visual_studio_writer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698