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

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: 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..159edfdf168b241065707916523d35eecc7b1b36 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,17 @@ bool CheckForInvalidGeneratedInputs(Setup* setup) {
return false;
}
+bool RunIdeWriter(const std::string& ide,
+ const BuildSettings* build_settings,
+ Builder* builder,
+ Err* err) {
+ if (ide == kSwitchIdeValueVs)
+ return VisualStudioWriter::RunAndWriteFiles(build_settings, builder, err);
+
+ *err = Err(Location(), "Unknown IDE: " + ide);
+ return false;
+}
+
} // namespace
const char kGen[] = "gen";
@@ -152,7 +166,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] <out_dir>\n"
brettw 2016/01/08 23:51:50 --ide=<ide_name> (and same below) to make more cle
Tomasz Moniuszko 2016/01/21 10:50:02 Done.
"\n"
" Generates ninja files from the current tree and puts them in the given\n"
" output directory.\n"
@@ -162,6 +176,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\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 +197,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,6 +230,13 @@ 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)) {
« 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