| OLD | NEW |
| 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/builder.h" | 7 #include "tools/gn/builder.h" |
| 8 #include "tools/gn/loader.h" | 8 #include "tools/gn/loader.h" |
| 9 #include "tools/gn/location.h" | 9 #include "tools/gn/location.h" |
| 10 #include "tools/gn/ninja_build_writer.h" | 10 #include "tools/gn/ninja_build_writer.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool NinjaWriter::WriteToolchains(std::vector<const Settings*>* all_settings, | 47 bool NinjaWriter::WriteToolchains(std::vector<const Settings*>* all_settings, |
| 48 std::vector<const Target*>* default_targets, | 48 std::vector<const Target*>* default_targets, |
| 49 Err* err) { | 49 Err* err) { |
| 50 // Categorize all targets by toolchain. | 50 // Categorize all targets by toolchain. |
| 51 typedef std::map<Label, std::vector<const Target*> > CategorizedMap; | 51 typedef std::map<Label, std::vector<const Target*> > CategorizedMap; |
| 52 CategorizedMap categorized; | 52 CategorizedMap categorized; |
| 53 | 53 |
| 54 std::vector<const BuilderRecord*> all_records = builder_->GetAllRecords(); | 54 std::vector<const BuilderRecord*> all_records = builder_->GetAllRecords(); |
| 55 for (size_t i = 0; i < all_records.size(); i++) { | 55 for (const auto& all_record : all_records) { |
| 56 if (all_records[i]->type() == BuilderRecord::ITEM_TARGET && | 56 if (all_record->type() == BuilderRecord::ITEM_TARGET && |
| 57 all_records[i]->should_generate()) { | 57 all_record->should_generate()) { |
| 58 categorized[all_records[i]->label().GetToolchainLabel()].push_back( | 58 categorized[all_record->label().GetToolchainLabel()].push_back( |
| 59 all_records[i]->item()->AsTarget()); | 59 all_record->item()->AsTarget()); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 if (categorized.empty()) { | 62 if (categorized.empty()) { |
| 63 Err(Location(), "No targets.", | 63 Err(Location(), "No targets.", |
| 64 "I could not find any targets to write, so I'm doing nothing.") | 64 "I could not find any targets to write, so I'm doing nothing.") |
| 65 .PrintToStdout(); | 65 .PrintToStdout(); |
| 66 return false; | 66 return false; |
| 67 } | 67 } |
| 68 | 68 |
| 69 Label default_label = builder_->loader()->GetDefaultToolchain(); | 69 Label default_label = builder_->loader()->GetDefaultToolchain(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 97 // should always be at least one settings object in the build. | 97 // should always be at least one settings object in the build. |
| 98 CHECK(!all_settings.empty()); | 98 CHECK(!all_settings.empty()); |
| 99 const Toolchain* default_toolchain = | 99 const Toolchain* default_toolchain = |
| 100 builder_->GetToolchain(all_settings[0]->default_toolchain_label()); | 100 builder_->GetToolchain(all_settings[0]->default_toolchain_label()); |
| 101 | 101 |
| 102 // Write the root buildfile. | 102 // Write the root buildfile. |
| 103 return NinjaBuildWriter::RunAndWriteFile(build_settings_, all_settings, | 103 return NinjaBuildWriter::RunAndWriteFile(build_settings_, all_settings, |
| 104 default_toolchain, default_targets, | 104 default_toolchain, default_targets, |
| 105 err); | 105 err); |
| 106 } | 106 } |
| OLD | NEW |