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

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

Issue 51693002: GN: toolchain threading cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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_target_writer.cc ('k') | tools/gn/scope_per_file_provider.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_toolchain_writer.h" 5 #include "tools/gn/ninja_toolchain_writer.h"
6 6
7 #include <fstream> 7 #include <fstream>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/strings/stringize_macros.h" 10 #include "base/strings/stringize_macros.h"
11 #include "tools/gn/build_settings.h" 11 #include "tools/gn/build_settings.h"
12 #include "tools/gn/item_node.h" 12 #include "tools/gn/item_node.h"
13 #include "tools/gn/settings.h" 13 #include "tools/gn/settings.h"
14 #include "tools/gn/target.h" 14 #include "tools/gn/target.h"
15 #include "tools/gn/toolchain.h" 15 #include "tools/gn/toolchain.h"
16 #include "tools/gn/toolchain_manager.h"
16 #include "tools/gn/trace.h" 17 #include "tools/gn/trace.h"
17 18
18 NinjaToolchainWriter::NinjaToolchainWriter( 19 NinjaToolchainWriter::NinjaToolchainWriter(
19 const Settings* settings, 20 const Settings* settings,
20 const std::vector<const Target*>& targets, 21 const std::vector<const Target*>& targets,
21 const std::set<std::string>& skip_files, 22 const std::set<std::string>& skip_files,
22 std::ostream& out) 23 std::ostream& out)
23 : settings_(settings), 24 : settings_(settings),
24 targets_(targets), 25 targets_(targets),
25 skip_files_(skip_files), 26 skip_files_(skip_files),
(...skipping 29 matching lines...) Expand all
55 std::ios_base::out | std::ios_base::binary); 56 std::ios_base::out | std::ios_base::binary);
56 if (file.fail()) 57 if (file.fail())
57 return false; 58 return false;
58 59
59 NinjaToolchainWriter gen(settings, targets, skip_files, file); 60 NinjaToolchainWriter gen(settings, targets, skip_files, file);
60 gen.Run(); 61 gen.Run();
61 return true; 62 return true;
62 } 63 }
63 64
64 void NinjaToolchainWriter::WriteRules() { 65 void NinjaToolchainWriter::WriteRules() {
65 const Toolchain* tc = settings_->toolchain(); 66 const Toolchain* tc = settings_->build_settings()->toolchain_manager()
67 .GetToolchainDefinitionUnlocked(settings_->toolchain_label());
68 CHECK(tc);
69
66 std::string indent(" "); 70 std::string indent(" ");
67 71
68 NinjaHelper helper(settings_->build_settings()); 72 NinjaHelper helper(settings_->build_settings());
69 std::string rule_prefix = helper.GetRulePrefix(tc); 73 std::string rule_prefix = helper.GetRulePrefix(settings_);
70 74
71 for (int i = Toolchain::TYPE_NONE + 1; i < Toolchain::TYPE_NUMTYPES; i++) { 75 for (int i = Toolchain::TYPE_NONE + 1; i < Toolchain::TYPE_NUMTYPES; i++) {
72 Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(i); 76 Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(i);
73 const Toolchain::Tool& tool = tc->GetTool(tool_type); 77 const Toolchain::Tool& tool = tc->GetTool(tool_type);
74 if (tool.command.empty()) 78 if (tool.command.empty())
75 continue; 79 continue;
76 80
77 out_ << "rule " << rule_prefix << Toolchain::ToolTypeToName(tool_type) 81 out_ << "rule " << rule_prefix << Toolchain::ToolTypeToName(tool_type)
78 << std::endl; 82 << std::endl;
79 83
(...skipping 24 matching lines...) Expand all
104 OutputFile ninja_file = helper_.GetNinjaFileForTarget(targets_[i]); 108 OutputFile ninja_file = helper_.GetNinjaFileForTarget(targets_[i]);
105 if (skip_files_.find(ninja_file.value()) != skip_files_.end()) 109 if (skip_files_.find(ninja_file.value()) != skip_files_.end())
106 continue; 110 continue;
107 111
108 out_ << "subninja "; 112 out_ << "subninja ";
109 path_output_.WriteFile(out_, ninja_file); 113 path_output_.WriteFile(out_, ninja_file);
110 out_ << std::endl; 114 out_ << std::endl;
111 } 115 }
112 out_ << std::endl; 116 out_ << std::endl;
113 } 117 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_target_writer.cc ('k') | tools/gn/scope_per_file_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698