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

Unified Diff: tools/gn/gn_main.cc

Issue 21114002: Add initial prototype for the GN meta-buildsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add owners and readme Created 7 years, 5 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
« no previous file with comments | « tools/gn/gn.gyp ('k') | tools/gn/import_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/gn_main.cc
diff --git a/tools/gn/gn_main.cc b/tools/gn/gn_main.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6f5b31e8299f522ae1681ebd58d99f0a78571a61
--- /dev/null
+++ b/tools/gn/gn_main.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/at_exit.h"
+#include "base/command_line.h"
+#include "base/strings/utf_string_conversions.h"
+#include "tools/gn/commands.h"
+#include "tools/gn/err.h"
+#include "tools/gn/location.h"
+
+namespace {
+
+std::vector<std::string> GetArgs(const CommandLine& cmdline) {
+ CommandLine::StringVector in_args = cmdline.GetArgs();
+#if defined(OS_WIN)
+ std::vector<std::string> out_args;
+ for (size_t i = 0; i < in_args.size(); i++)
+ out_args.push_back(base::WideToUTF8(in_args[i]));
+ return out_args;
+#else
+ return in_args;
+#endif
+}
+
+} // namespace
+
+int main(int argc, char** argv) {
+ base::AtExitManager at_exit;
+ CommandLine::Init(argc, argv);
+
+ std::vector<std::string> args = GetArgs(*CommandLine::ForCurrentProcess());
+
+ std::string command;
+ if (args.empty()) {
+ command = "gen";
+ } else {
+ command = args[0];
+ args.erase(args.begin());
+ }
+
+ int retval = 0;
+ if (command == "gen") {
+ retval = RunGenCommand(args);
+ } else if (command == "desc" || command == "wtf") {
+ retval = RunDescCommand(args);
+ } else if (command == "deps") {
+ retval = RunDepsCommand(args);
+ } else if (command == "tree") {
+ retval = RunTreeCommand(args);
+ } else {
+ Err(Location(),
+ "Command \"" + command + "\" unknown.").PrintToStdout();
+ retval = 1;
+ }
+
+ exit(retval); // Don't free memory, it can be really slow!
+ return retval;
+}
« no previous file with comments | « tools/gn/gn.gyp ('k') | tools/gn/import_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698