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

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

Issue 2926013002: Support explicit pools in actions (Closed)
Patch Set: Remove console altogether Created 3 years, 5 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
« no previous file with comments | « tools/gn/ninja_action_target_writer_unittest.cc ('k') | tools/gn/ninja_toolchain_writer.cc » ('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_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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 std::unordered_set<const Pool*> used_pools; 279 std::unordered_set<const Pool*> used_pools;
280 for (const auto& pair : used_toolchains_) { 280 for (const auto& pair : used_toolchains_) {
281 for (int j = Toolchain::TYPE_NONE + 1; j < Toolchain::TYPE_NUMTYPES; j++) { 281 for (int j = Toolchain::TYPE_NONE + 1; j < Toolchain::TYPE_NUMTYPES; j++) {
282 Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(j); 282 Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(j);
283 const Tool* tool = pair.second->GetTool(tool_type); 283 const Tool* tool = pair.second->GetTool(tool_type);
284 if (tool && tool->pool().ptr) 284 if (tool && tool->pool().ptr)
285 used_pools.insert(tool->pool().ptr); 285 used_pools.insert(tool->pool().ptr);
286 } 286 }
287 } 287 }
288 288
289 for (const Target* target : default_toolchain_targets_) {
290 if (target->output_type() == Target::ACTION) {
291 const LabelPtrPair<Pool>& pool = target->action_values().pool();
292 if (pool.ptr)
293 used_pools.insert(pool.ptr);
294 }
295 }
296
289 // Write pools sorted by their name, to make output deterministic. 297 // Write pools sorted by their name, to make output deterministic.
290 std::vector<const Pool*> sorted_pools(used_pools.begin(), used_pools.end()); 298 std::vector<const Pool*> sorted_pools(used_pools.begin(), used_pools.end());
291 auto pool_name = [this](const Pool* pool) { 299 auto pool_name = [this](const Pool* pool) {
292 return pool->GetNinjaName(default_toolchain_->label()); 300 return pool->GetNinjaName(default_toolchain_->label());
293 }; 301 };
294 std::sort(sorted_pools.begin(), sorted_pools.end(), 302 std::sort(sorted_pools.begin(), sorted_pools.end(),
295 [&pool_name](const Pool* a, const Pool* b) { 303 [&pool_name](const Pool* a, const Pool* b) {
296 return pool_name(a) < pool_name(b); 304 return pool_name(a) < pool_name(b);
297 }); 305 });
298 for (const Pool* pool : sorted_pools) { 306 for (const Pool* pool : sorted_pools) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 EscapeOptions ninja_escape; 569 EscapeOptions ninja_escape;
562 ninja_escape.mode = ESCAPE_NINJA; 570 ninja_escape.mode = ESCAPE_NINJA;
563 571
564 // Escape for special chars Ninja will handle. 572 // Escape for special chars Ninja will handle.
565 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); 573 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr);
566 574
567 out_ << "build " << escaped << ": phony "; 575 out_ << "build " << escaped << ": phony ";
568 path_output_.WriteFile(out_, target->dependency_output_file()); 576 path_output_.WriteFile(out_, target->dependency_output_file());
569 out_ << std::endl; 577 out_ << std::endl;
570 } 578 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_action_target_writer_unittest.cc ('k') | tools/gn/ninja_toolchain_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698