| 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" |
| 11 #include "tools/gn/ninja_toolchain_writer.h" | 11 #include "tools/gn/ninja_toolchain_writer.h" |
| 12 #include "tools/gn/settings.h" |
| 12 | 13 |
| 13 NinjaWriter::NinjaWriter(const BuildSettings* build_settings, | 14 NinjaWriter::NinjaWriter(const BuildSettings* build_settings, |
| 14 Builder* builder) | 15 Builder* builder) |
| 15 : build_settings_(build_settings), | 16 : build_settings_(build_settings), |
| 16 builder_(builder) { | 17 builder_(builder) { |
| 17 } | 18 } |
| 18 | 19 |
| 19 NinjaWriter::~NinjaWriter() { | 20 NinjaWriter::~NinjaWriter() { |
| 20 } | 21 } |
| 21 | 22 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 82 } |
| 82 } | 83 } |
| 83 | 84 |
| 84 *default_targets = categorized[default_label]; | 85 *default_targets = categorized[default_label]; |
| 85 return true; | 86 return true; |
| 86 } | 87 } |
| 87 | 88 |
| 88 bool NinjaWriter::WriteRootBuildfiles( | 89 bool NinjaWriter::WriteRootBuildfiles( |
| 89 const std::vector<const Settings*>& all_settings, | 90 const std::vector<const Settings*>& all_settings, |
| 90 const std::vector<const Target*>& default_targets) { | 91 const std::vector<const Target*>& default_targets) { |
| 92 // All Settings objects should have the same default toolchain, and there |
| 93 // should always be at least one settings object in the build. |
| 94 CHECK(!all_settings.empty()); |
| 95 const Toolchain* default_toolchain = |
| 96 builder_->GetToolchain(all_settings[0]->default_toolchain_label()); |
| 97 |
| 91 // Write the root buildfile. | 98 // Write the root buildfile. |
| 92 if (!NinjaBuildWriter::RunAndWriteFile(build_settings_, all_settings, | 99 if (!NinjaBuildWriter::RunAndWriteFile(build_settings_, all_settings, |
| 93 default_targets)) { | 100 default_toolchain, default_targets)) { |
| 94 Err(Location(), | 101 Err(Location(), |
| 95 "Couldn't open toolchain buildfile(s) for writing").PrintToStdout(); | 102 "Couldn't open toolchain buildfile(s) for writing").PrintToStdout(); |
| 96 return false; | 103 return false; |
| 97 } | 104 } |
| 98 return true; | 105 return true; |
| 99 } | 106 } |
| OLD | NEW |