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

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

Issue 2006923004: Add support for user defined "pool" to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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/files/file_util.h" 9 #include "base/files/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/filesystem_utils.h" 12 #include "tools/gn/filesystem_utils.h"
13 #include "tools/gn/ninja_utils.h" 13 #include "tools/gn/ninja_utils.h"
14 #include "tools/gn/pool.h"
14 #include "tools/gn/settings.h" 15 #include "tools/gn/settings.h"
15 #include "tools/gn/substitution_writer.h" 16 #include "tools/gn/substitution_writer.h"
16 #include "tools/gn/target.h" 17 #include "tools/gn/target.h"
17 #include "tools/gn/toolchain.h" 18 #include "tools/gn/toolchain.h"
18 #include "tools/gn/trace.h" 19 #include "tools/gn/trace.h"
19 20
20 namespace { 21 namespace {
21 22
22 const char kIndent[] = " "; 23 const char kIndent[] = " ";
23 24
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return false; 64 return false;
64 65
65 NinjaToolchainWriter gen(settings, toolchain, targets, file); 66 NinjaToolchainWriter gen(settings, toolchain, targets, file);
66 gen.Run(); 67 gen.Run();
67 return true; 68 return true;
68 } 69 }
69 70
70 void NinjaToolchainWriter::WriteRules() { 71 void NinjaToolchainWriter::WriteRules() {
71 std::string rule_prefix = GetNinjaRulePrefixForToolchain(settings_); 72 std::string rule_prefix = GetNinjaRulePrefixForToolchain(settings_);
72 73
74 UniqueVector<const Pool*> pools;
75 for (int i = Toolchain::TYPE_NONE + 1; i < Toolchain::TYPE_NUMTYPES; i++) {
76 Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(i);
77 const Tool* tool = toolchain_->GetTool(tool_type);
78 if (tool && tool->pool_label_pair().ptr)
79 pools.push_back(tool->pool_label_pair().ptr);
80 }
81
82 if (!pools.empty()) {
83 for (const Pool* pool : pools) {
84 out_ << "pool " << rule_prefix << pool->label().name() << std::endl;
brettw 2016/05/24 22:03:31 How the naming works here is a bit suspicious. In
sdefresne 2016/05/26 15:38:37 Done.
85 out_ << kIndent << "depth = " << pool->depth() << std::endl;
86 }
87 out_ << std::endl;
88 }
89
73 for (int i = Toolchain::TYPE_NONE + 1; i < Toolchain::TYPE_NUMTYPES; i++) { 90 for (int i = Toolchain::TYPE_NONE + 1; i < Toolchain::TYPE_NUMTYPES; i++) {
74 Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(i); 91 Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(i);
75 const Tool* tool = toolchain_->GetTool(tool_type); 92 const Tool* tool = toolchain_->GetTool(tool_type);
76 if (tool) 93 if (tool)
77 WriteToolRule(tool_type, tool, rule_prefix); 94 WriteToolRule(tool_type, tool, rule_prefix);
78 } 95 }
79 out_ << std::endl; 96 out_ << std::endl;
80 } 97 }
81 98
82 void NinjaToolchainWriter::WriteToolRule(const Toolchain::ToolType type, 99 void NinjaToolchainWriter::WriteToolRule(const Toolchain::ToolType type,
(...skipping 27 matching lines...) Expand all
110 // The link pool applies to linker tools. Don't count TYPE_ALINK since 127 // The link pool applies to linker tools. Don't count TYPE_ALINK since
111 // static libraries are not generally intensive to write. 128 // static libraries are not generally intensive to write.
112 if (type == Toolchain::TYPE_SOLINK || 129 if (type == Toolchain::TYPE_SOLINK ||
113 type == Toolchain::TYPE_SOLINK_MODULE || 130 type == Toolchain::TYPE_SOLINK_MODULE ||
114 type == Toolchain::TYPE_LINK) { 131 type == Toolchain::TYPE_LINK) {
115 out_ << kIndent << "pool = link_pool\n"; 132 out_ << kIndent << "pool = link_pool\n";
116 } 133 }
117 134
118 if (tool->restat()) 135 if (tool->restat())
119 out_ << kIndent << "restat = 1" << std::endl; 136 out_ << kIndent << "restat = 1" << std::endl;
137
138 if (tool->pool_label_pair().ptr) {
139 out_ << kIndent << "pool = "
140 << rule_prefix << tool->pool_label_pair().label.name() << std::endl;
141 }
120 } 142 }
121 143
122 void NinjaToolchainWriter::WriteRulePattern(const char* name, 144 void NinjaToolchainWriter::WriteRulePattern(const char* name,
123 const SubstitutionPattern& pattern, 145 const SubstitutionPattern& pattern,
124 const EscapeOptions& options) { 146 const EscapeOptions& options) {
125 if (pattern.empty()) 147 if (pattern.empty())
126 return; 148 return;
127 out_ << kIndent << name << " = "; 149 out_ << kIndent << name << " = ";
128 SubstitutionWriter::WriteWithNinjaVariables(pattern, options, out_); 150 SubstitutionWriter::WriteWithNinjaVariables(pattern, options, out_);
129 out_ << std::endl; 151 out_ << std::endl;
130 } 152 }
131 153
132 void NinjaToolchainWriter::WriteSubninjas() { 154 void NinjaToolchainWriter::WriteSubninjas() {
133 // Write subninja commands for each generated target. 155 // Write subninja commands for each generated target.
134 for (const auto& target : targets_) { 156 for (const auto& target : targets_) {
135 OutputFile ninja_file(target->settings()->build_settings(), 157 OutputFile ninja_file(target->settings()->build_settings(),
136 GetNinjaFileForTarget(target)); 158 GetNinjaFileForTarget(target));
137 out_ << "subninja "; 159 out_ << "subninja ";
138 path_output_.WriteFile(out_, ninja_file); 160 path_output_.WriteFile(out_, ninja_file);
139 out_ << std::endl; 161 out_ << std::endl;
140 } 162 }
141 out_ << std::endl; 163 out_ << std::endl;
142 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698