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

Unified Diff: tools/gn/command_gen.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/command_desc.cc ('k') | tools/gn/commands.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/command_gen.cc
diff --git a/tools/gn/command_gen.cc b/tools/gn/command_gen.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ab64a8d5c72150c5f6e2ff672e862c2d4e594023
--- /dev/null
+++ b/tools/gn/command_gen.cc
@@ -0,0 +1,66 @@
+// 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/bind.h"
+#include "base/command_line.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/time/time.h"
+#include "tools/gn/build_settings.h"
+#include "tools/gn/commands.h"
+#include "tools/gn/ninja_target_writer.h"
+#include "tools/gn/ninja_writer.h"
+#include "tools/gn/scheduler.h"
+#include "tools/gn/setup.h"
+#include "tools/gn/standard_out.h"
+
+namespace {
+
+// Suppress output on success.
+const char kSwitchQuiet[] = "q";
+
+} // namespace
+
+int RunGenCommand(const std::vector<std::string>& args) {
+ base::TimeTicks begin_time = base::TimeTicks::Now();
+
+ // Deliberately leaked to avoid expensive process teardown.
+ Setup* setup = new Setup;
+ if (!setup->DoSetup())
+ return 1;
+
+ // Cause the load to also generate the ninja files for each target.
+ setup->build_settings().set_target_resolved_callback(
+ base::Bind(&NinjaTargetWriter::RunAndWriteFile));
+
+ // Do the actual load. This will also write out the target ninja files.
+ if (!setup->Run())
+ return 1;
+
+ // Write the root ninja files.
+ if (!NinjaWriter::RunAndWriteFiles(&setup->build_settings())) {
+ Err(Location(),
+ "Couldn't open root buildfile(s) for writing").PrintToStdout();
+ return 1;
+ }
+
+ base::TimeTicks end_time = base::TimeTicks::Now();
+
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(kSwitchQuiet)) {
+ OutputString("Done. ", DECORATION_GREEN);
+
+ // TODO(brettw) get the number of targets without getting the entire list.
+ std::vector<const Target*> all_targets;
+ setup->build_settings().target_manager().GetAllTargets(&all_targets);
+ std::string stats = "Generated " +
+ base::IntToString(static_cast<int>(all_targets.size())) +
+ " targets from " +
+ base::IntToString(
+ setup->scheduler().input_file_manager()->GetInputFileCount()) +
+ " files in " +
+ base::IntToString((end_time - begin_time).InMilliseconds()) + "ms\n";
+ OutputString(stats);
+ }
+
+ return 0;
+}
« no previous file with comments | « tools/gn/command_desc.cc ('k') | tools/gn/commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698