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

Side by Side 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, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/ninja_writer.h ('k') | tools/gn/operators.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "tools/gn/ninja_writer.h"
6
7 #include "tools/gn/location.h"
8 #include "tools/gn/ninja_build_writer.h"
9 #include "tools/gn/ninja_toolchain_writer.h"
10
11
12 NinjaWriter::NinjaWriter(const BuildSettings* build_settings)
13 : build_settings_(build_settings) {
14 }
15
16 NinjaWriter::~NinjaWriter() {
17 }
18
19 // static
20 bool NinjaWriter::RunAndWriteFiles(const BuildSettings* build_settings) {
21 NinjaWriter writer(build_settings);
22 return writer.WriteRootBuildfiles();
23 }
24
25 bool NinjaWriter::WriteRootBuildfiles() {
26 // Categorize all targets by toolchain.
27 typedef std::map<Label, std::vector<const Target*> > CategorizedMap;
28 CategorizedMap categorized;
29
30 std::vector<const Target*> all_targets;
31 build_settings_->target_manager().GetAllTargets(&all_targets);
32 for (size_t i = 0; i < all_targets.size(); i++) {
33 categorized[all_targets[i]->label().GetToolchainLabel()].push_back(
34 all_targets[i]);
35 }
36
37 Label default_label =
38 build_settings_->toolchain_manager().GetDefaultToolchainUnlocked();
39
40 // Write out the toolchain buildfiles, and also accumulate the set of
41 // all settings and find the list of targets in the default toolchain.
42 std::vector<const Settings*> all_settings;
43 const std::vector<const Target*>* default_targets = NULL;
44 for (CategorizedMap::const_iterator i = categorized.begin();
45 i != categorized.end(); ++i) {
46 const Settings* settings;
47 {
48 base::AutoLock lock(build_settings_->item_tree().lock());
49 Err ignored;
50 settings =
51 build_settings_->toolchain_manager().GetSettingsForToolchainLocked(
52 LocationRange(), i->first, &ignored);
53 }
54 if (i->first == default_label)
55 default_targets = &i->second;
56 all_settings.push_back(settings);
57 if (!NinjaToolchainWriter::RunAndWriteFile(settings, i->second))
58 return false;
59 }
60
61 // Write the root buildfile.
62 return NinjaBuildWriter::RunAndWriteFile(build_settings_, all_settings,
63 *default_targets);
64 }
OLDNEW
« 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