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

Side by Side Diff: tools/gn/ninja_writer.cc

Issue 22290010: Add support for data deps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove switch 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/scope_per_file_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/ninja_writer.h" 5 #include "tools/gn/ninja_writer.h"
6 6
7 #include "tools/gn/location.h" 7 #include "tools/gn/location.h"
8 #include "tools/gn/ninja_build_writer.h" 8 #include "tools/gn/ninja_build_writer.h"
9 #include "tools/gn/ninja_toolchain_writer.h" 9 #include "tools/gn/ninja_toolchain_writer.h"
10 10
(...skipping 11 matching lines...) Expand all
22 return writer.WriteRootBuildfiles(); 22 return writer.WriteRootBuildfiles();
23 } 23 }
24 24
25 bool NinjaWriter::WriteRootBuildfiles() { 25 bool NinjaWriter::WriteRootBuildfiles() {
26 // Categorize all targets by toolchain. 26 // Categorize all targets by toolchain.
27 typedef std::map<Label, std::vector<const Target*> > CategorizedMap; 27 typedef std::map<Label, std::vector<const Target*> > CategorizedMap;
28 CategorizedMap categorized; 28 CategorizedMap categorized;
29 29
30 std::vector<const Target*> all_targets; 30 std::vector<const Target*> all_targets;
31 build_settings_->target_manager().GetAllTargets(&all_targets); 31 build_settings_->target_manager().GetAllTargets(&all_targets);
32 if (all_targets.empty()) {
33 Err(Location(), "No targets.",
34 "I could not find any targets to write, so I'm doing nothing.")
35 .PrintToStdout();
36 return false;
37 }
32 for (size_t i = 0; i < all_targets.size(); i++) { 38 for (size_t i = 0; i < all_targets.size(); i++) {
33 categorized[all_targets[i]->label().GetToolchainLabel()].push_back( 39 categorized[all_targets[i]->label().GetToolchainLabel()].push_back(
34 all_targets[i]); 40 all_targets[i]);
35 } 41 }
36 42
37 Label default_label = 43 Label default_label =
38 build_settings_->toolchain_manager().GetDefaultToolchainUnlocked(); 44 build_settings_->toolchain_manager().GetDefaultToolchainUnlocked();
39 45
40 // Write out the toolchain buildfiles, and also accumulate the set of 46 // Write out the toolchain buildfiles, and also accumulate the set of
41 // all settings and find the list of targets in the default toolchain. 47 // all settings and find the list of targets in the default toolchain.
42 std::vector<const Settings*> all_settings; 48 std::vector<const Settings*> all_settings;
43 const std::vector<const Target*>* default_targets = NULL; 49 const std::vector<const Target*>* default_targets = NULL;
44 for (CategorizedMap::const_iterator i = categorized.begin(); 50 for (CategorizedMap::const_iterator i = categorized.begin();
45 i != categorized.end(); ++i) { 51 i != categorized.end(); ++i) {
46 const Settings* settings; 52 const Settings* settings;
47 { 53 {
48 base::AutoLock lock(build_settings_->item_tree().lock()); 54 base::AutoLock lock(build_settings_->item_tree().lock());
49 Err ignored; 55 Err ignored;
50 settings = 56 settings =
51 build_settings_->toolchain_manager().GetSettingsForToolchainLocked( 57 build_settings_->toolchain_manager().GetSettingsForToolchainLocked(
52 LocationRange(), i->first, &ignored); 58 LocationRange(), i->first, &ignored);
53 } 59 }
54 if (i->first == default_label) 60 if (i->first == default_label)
55 default_targets = &i->second; 61 default_targets = &i->second;
56 all_settings.push_back(settings); 62 all_settings.push_back(settings);
57 if (!NinjaToolchainWriter::RunAndWriteFile(settings, i->second)) 63 if (!NinjaToolchainWriter::RunAndWriteFile(settings, i->second)) {
64 Err(Location(),
65 "Couldn't open toolchain buildfile(s) for writing").PrintToStdout();
58 return false; 66 return false;
67 }
59 } 68 }
60 69
61 // Write the root buildfile. 70 // Write the root buildfile.
62 return NinjaBuildWriter::RunAndWriteFile(build_settings_, all_settings, 71 if (!NinjaBuildWriter::RunAndWriteFile(build_settings_, all_settings,
63 *default_targets); 72 *default_targets)) {
73 Err(Location(),
74 "Couldn't open toolchain buildfile(s) for writing").PrintToStdout();
75 return false;
76 }
77 return true;
64 } 78 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_writer.h ('k') | tools/gn/scope_per_file_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698