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_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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // MSVC deps don't have a depfile. | 107 // MSVC deps don't have a depfile. |
107 out_ << kIndent << "deps = msvc" << std::endl; | 108 out_ << kIndent << "deps = msvc" << std::endl; |
108 } | 109 } |
109 | 110 |
110 // The link pool applies to linker tools. Don't count TYPE_ALINK since | 111 // The link pool applies to linker tools. Don't count TYPE_ALINK since |
111 // static libraries are not generally intensive to write. | 112 // static libraries are not generally intensive to write. |
112 if (type == Toolchain::TYPE_SOLINK || | 113 if (type == Toolchain::TYPE_SOLINK || |
113 type == Toolchain::TYPE_SOLINK_MODULE || | 114 type == Toolchain::TYPE_SOLINK_MODULE || |
114 type == Toolchain::TYPE_LINK) { | 115 type == Toolchain::TYPE_LINK) { |
115 out_ << kIndent << "pool = link_pool\n"; | 116 out_ << kIndent << "pool = link_pool\n"; |
| 117 } else if (tool->pool().ptr) { |
| 118 std::string pool_name = |
| 119 tool->pool().ptr->GetNinjaName(settings_->default_toolchain_label()); |
| 120 out_ << kIndent << "pool = " << pool_name << std::endl; |
116 } | 121 } |
117 | 122 |
118 if (tool->restat()) | 123 if (tool->restat()) |
119 out_ << kIndent << "restat = 1" << std::endl; | 124 out_ << kIndent << "restat = 1" << std::endl; |
120 } | 125 } |
121 | 126 |
122 void NinjaToolchainWriter::WriteRulePattern(const char* name, | 127 void NinjaToolchainWriter::WriteRulePattern(const char* name, |
123 const SubstitutionPattern& pattern, | 128 const SubstitutionPattern& pattern, |
124 const EscapeOptions& options) { | 129 const EscapeOptions& options) { |
125 if (pattern.empty()) | 130 if (pattern.empty()) |
126 return; | 131 return; |
127 out_ << kIndent << name << " = "; | 132 out_ << kIndent << name << " = "; |
128 SubstitutionWriter::WriteWithNinjaVariables(pattern, options, out_); | 133 SubstitutionWriter::WriteWithNinjaVariables(pattern, options, out_); |
129 out_ << std::endl; | 134 out_ << std::endl; |
130 } | 135 } |
131 | 136 |
132 void NinjaToolchainWriter::WriteSubninjas() { | 137 void NinjaToolchainWriter::WriteSubninjas() { |
133 // Write subninja commands for each generated target. | 138 // Write subninja commands for each generated target. |
134 for (const auto& target : targets_) { | 139 for (const auto& target : targets_) { |
135 OutputFile ninja_file(target->settings()->build_settings(), | 140 OutputFile ninja_file(target->settings()->build_settings(), |
136 GetNinjaFileForTarget(target)); | 141 GetNinjaFileForTarget(target)); |
137 out_ << "subninja "; | 142 out_ << "subninja "; |
138 path_output_.WriteFile(out_, ninja_file); | 143 path_output_.WriteFile(out_, ninja_file); |
139 out_ << std::endl; | 144 out_ << std::endl; |
140 } | 145 } |
141 out_ << std::endl; | 146 out_ << std::endl; |
142 } | 147 } |
OLD | NEW |