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_build_writer.h" | 5 #include "tools/gn/ninja_build_writer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <fstream> | 9 #include <fstream> |
10 #include <map> | 10 #include <map> |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 std::unordered_set<const Pool*> used_pools; | 278 std::unordered_set<const Pool*> used_pools; |
279 for (const auto& pair : used_toolchains_) { | 279 for (const auto& pair : used_toolchains_) { |
280 for (int j = Toolchain::TYPE_NONE + 1; j < Toolchain::TYPE_NUMTYPES; j++) { | 280 for (int j = Toolchain::TYPE_NONE + 1; j < Toolchain::TYPE_NUMTYPES; j++) { |
281 Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(j); | 281 Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(j); |
282 const Tool* tool = pair.second->GetTool(tool_type); | 282 const Tool* tool = pair.second->GetTool(tool_type); |
283 if (tool && tool->pool().ptr) | 283 if (tool && tool->pool().ptr) |
284 used_pools.insert(tool->pool().ptr); | 284 used_pools.insert(tool->pool().ptr); |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
| 288 for (const Target* target : default_toolchain_targets_) { |
| 289 if (target->output_type() == Target::ACTION) { |
| 290 const LabelPtrPair<Pool>& pool = target->action_values().pool(); |
| 291 if (pool.ptr) |
| 292 used_pools.insert(pool.ptr); |
| 293 } |
| 294 } |
| 295 |
288 // Write pools sorted by their name, to make output deterministic. | 296 // Write pools sorted by their name, to make output deterministic. |
289 std::vector<const Pool*> sorted_pools(used_pools.begin(), used_pools.end()); | 297 std::vector<const Pool*> sorted_pools(used_pools.begin(), used_pools.end()); |
290 auto pool_name = [this](const Pool* pool) { | 298 auto pool_name = [this](const Pool* pool) { |
291 return pool->GetNinjaName(default_toolchain_->label()); | 299 return pool->GetNinjaName(default_toolchain_->label()); |
292 }; | 300 }; |
293 std::sort(sorted_pools.begin(), sorted_pools.end(), | 301 std::sort(sorted_pools.begin(), sorted_pools.end(), |
294 [&pool_name](const Pool* a, const Pool* b) { | 302 [&pool_name](const Pool* a, const Pool* b) { |
295 return pool_name(a) < pool_name(b); | 303 return pool_name(a) < pool_name(b); |
296 }); | 304 }); |
297 for (const Pool* pool : sorted_pools) { | 305 for (const Pool* pool : sorted_pools) { |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 EscapeOptions ninja_escape; | 568 EscapeOptions ninja_escape; |
561 ninja_escape.mode = ESCAPE_NINJA; | 569 ninja_escape.mode = ESCAPE_NINJA; |
562 | 570 |
563 // Escape for special chars Ninja will handle. | 571 // Escape for special chars Ninja will handle. |
564 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); | 572 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); |
565 | 573 |
566 out_ << "build " << escaped << ": phony "; | 574 out_ << "build " << escaped << ": phony "; |
567 path_output_.WriteFile(out_, target->dependency_output_file()); | 575 path_output_.WriteFile(out_, target->dependency_output_file()); |
568 out_ << std::endl; | 576 out_ << std::endl; |
569 } | 577 } |
OLD | NEW |