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_helper.h" | 5 #include "tools/gn/ninja_helper.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "tools/gn/filesystem_utils.h" | 8 #include "tools/gn/filesystem_utils.h" |
9 #include "tools/gn/string_utils.h" | 9 #include "tools/gn/string_utils.h" |
10 #include "tools/gn/target.h" | 10 #include "tools/gn/target.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 target->label().dir().SourceAbsoluteWithOneSlash()); | 182 target->label().dir().SourceAbsoluteWithOneSlash()); |
183 ret.value().append(prefix); | 183 ret.value().append(prefix); |
184 ret.value().append(name); | 184 ret.value().append(name); |
185 if (extension[0]) { | 185 if (extension[0]) { |
186 ret.value().push_back('.'); | 186 ret.value().push_back('.'); |
187 ret.value().append(extension); | 187 ret.value().append(extension); |
188 } | 188 } |
189 return ret; | 189 return ret; |
190 } | 190 } |
191 | 191 |
192 std::string NinjaHelper::GetRulePrefix(const Toolchain* toolchain) const { | 192 std::string NinjaHelper::GetRulePrefix(const Settings* settings) const { |
193 // This code doesn't prefix the default toolchain commands. This is disabled | 193 // Don't prefix the default toolchain so it looks prettier, prefix everything |
194 // so we can coexist with GYP's commands (which aren't prefixed). If we don't | 194 // else. |
195 // need to coexist with GYP anymore, we can uncomment this to make things a | 195 if (settings->is_default()) |
196 // bit prettier. | 196 return std::string(); // Default toolchain has no prefix. |
197 //if (toolchain->is_default()) | 197 return settings->toolchain_label().name() + "_"; |
198 // return std::string(); // Default toolchain has no prefix. | |
199 return toolchain->label().name() + "_"; | |
200 } | 198 } |
201 | 199 |
202 std::string NinjaHelper::GetRuleForSourceType(const Settings* settings, | 200 std::string NinjaHelper::GetRuleForSourceType(const Settings* settings, |
203 const Toolchain* toolchain, | |
204 SourceFileType type) const { | 201 SourceFileType type) const { |
205 // This function may be hot since it will be called for every source file | 202 // This function may be hot since it will be called for every source file |
206 // in the tree. We could cache the results to avoid making a string for | 203 // in the tree. We could cache the results to avoid making a string for |
207 // every invocation. | 204 // every invocation. |
208 std::string prefix = GetRulePrefix(toolchain); | 205 std::string prefix = GetRulePrefix(settings); |
209 | 206 |
210 if (type == SOURCE_C) | 207 if (type == SOURCE_C) |
211 return prefix + "cc"; | 208 return prefix + "cc"; |
212 if (type == SOURCE_CC) | 209 if (type == SOURCE_CC) |
213 return prefix + "cxx"; | 210 return prefix + "cxx"; |
214 | 211 |
215 // TODO(brettw) asm files. | 212 // TODO(brettw) asm files. |
216 | 213 |
217 if (settings->IsMac()) { | 214 if (settings->IsMac()) { |
218 if (type == SOURCE_M) | 215 if (type == SOURCE_M) |
219 return prefix + "objc"; | 216 return prefix + "objc"; |
220 if (type == SOURCE_MM) | 217 if (type == SOURCE_MM) |
221 return prefix + "objcxx"; | 218 return prefix + "objcxx"; |
222 } | 219 } |
223 | 220 |
224 if (settings->IsWin()) { | 221 if (settings->IsWin()) { |
225 if (type == SOURCE_RC) | 222 if (type == SOURCE_RC) |
226 return prefix + "rc"; | 223 return prefix + "rc"; |
227 } else { | 224 } else { |
228 if (type == SOURCE_S) | 225 if (type == SOURCE_S) |
229 return prefix + "cc"; // Assembly files just get compiled by CC. | 226 return prefix + "cc"; // Assembly files just get compiled by CC. |
230 } | 227 } |
231 | 228 |
232 return std::string(); | 229 return std::string(); |
233 } | 230 } |
OLD | NEW |