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

Unified Diff: tools/gn/ninja_writer.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/ninja_writer.h ('k') | tools/gn/operators.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/ninja_writer.cc
diff --git a/tools/gn/ninja_writer.cc b/tools/gn/ninja_writer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8b69a3fc73536a7eaaf258b6d5a1220652bcc9d6
--- /dev/null
+++ b/tools/gn/ninja_writer.cc
@@ -0,0 +1,64 @@
+// 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 "tools/gn/ninja_writer.h"
+
+#include "tools/gn/location.h"
+#include "tools/gn/ninja_build_writer.h"
+#include "tools/gn/ninja_toolchain_writer.h"
+
+
+NinjaWriter::NinjaWriter(const BuildSettings* build_settings)
+ : build_settings_(build_settings) {
+}
+
+NinjaWriter::~NinjaWriter() {
+}
+
+// static
+bool NinjaWriter::RunAndWriteFiles(const BuildSettings* build_settings) {
+ NinjaWriter writer(build_settings);
+ return writer.WriteRootBuildfiles();
+}
+
+bool NinjaWriter::WriteRootBuildfiles() {
+ // Categorize all targets by toolchain.
+ typedef std::map<Label, std::vector<const Target*> > CategorizedMap;
+ CategorizedMap categorized;
+
+ std::vector<const Target*> all_targets;
+ build_settings_->target_manager().GetAllTargets(&all_targets);
+ for (size_t i = 0; i < all_targets.size(); i++) {
+ categorized[all_targets[i]->label().GetToolchainLabel()].push_back(
+ all_targets[i]);
+ }
+
+ Label default_label =
+ build_settings_->toolchain_manager().GetDefaultToolchainUnlocked();
+
+ // Write out the toolchain buildfiles, and also accumulate the set of
+ // all settings and find the list of targets in the default toolchain.
+ std::vector<const Settings*> all_settings;
+ const std::vector<const Target*>* default_targets = NULL;
+ for (CategorizedMap::const_iterator i = categorized.begin();
+ i != categorized.end(); ++i) {
+ const Settings* settings;
+ {
+ base::AutoLock lock(build_settings_->item_tree().lock());
+ Err ignored;
+ settings =
+ build_settings_->toolchain_manager().GetSettingsForToolchainLocked(
+ LocationRange(), i->first, &ignored);
+ }
+ if (i->first == default_label)
+ default_targets = &i->second;
+ all_settings.push_back(settings);
+ if (!NinjaToolchainWriter::RunAndWriteFile(settings, i->second))
+ return false;
+ }
+
+ // Write the root buildfile.
+ return NinjaBuildWriter::RunAndWriteFile(build_settings_, all_settings,
+ *default_targets);
+}
« no previous file with comments | « tools/gn/ninja_writer.h ('k') | tools/gn/operators.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698