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

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

Issue 986113002: tools/gn: Convert for loops to use the new range-based loops in C++11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review fixes Created 5 years, 9 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/command_clean.cc ('k') | tools/gn/err.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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "tools/gn/commands.h" 10 #include "tools/gn/commands.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 const std::string& heading, 250 const std::string& heading,
251 bool display_header) { 251 bool display_header) {
252 if (configs.empty()) 252 if (configs.empty())
253 return; 253 return;
254 254
255 // Don't sort since the order determines how things are processed. 255 // Don't sort since the order determines how things are processed.
256 if (display_header) 256 if (display_header)
257 OutputString("\n" + heading + " (in order applying):\n"); 257 OutputString("\n" + heading + " (in order applying):\n");
258 258
259 Label toolchain_label = target->label().GetToolchainLabel(); 259 Label toolchain_label = target->label().GetToolchainLabel();
260 for (size_t i = 0; i < configs.size(); i++) { 260 for (const auto& config : configs) {
261 OutputString(" " + 261 OutputString(" " + config.label.GetUserVisibleName(toolchain_label) +
262 configs[i].label.GetUserVisibleName(toolchain_label) + "\n"); 262 "\n");
263 } 263 }
264 } 264 }
265 265
266 void PrintConfigsVector(const Target* target, 266 void PrintConfigsVector(const Target* target,
267 const UniqueVector<LabelConfigPair>& configs, 267 const UniqueVector<LabelConfigPair>& configs,
268 const std::string& heading, 268 const std::string& heading,
269 bool display_header) { 269 bool display_header) {
270 if (configs.empty()) 270 if (configs.empty())
271 return; 271 return;
272 272
273 // Don't sort since the order determines how things are processed. 273 // Don't sort since the order determines how things are processed.
274 if (display_header) 274 if (display_header)
275 OutputString("\n" + heading + " (in order applying):\n"); 275 OutputString("\n" + heading + " (in order applying):\n");
276 276
277 Label toolchain_label = target->label().GetToolchainLabel(); 277 Label toolchain_label = target->label().GetToolchainLabel();
278 for (size_t i = 0; i < configs.size(); i++) { 278 for (const auto& config : configs) {
279 OutputString(" " + 279 OutputString(" " + config.label.GetUserVisibleName(toolchain_label) +
280 configs[i].label.GetUserVisibleName(toolchain_label) + "\n"); 280 "\n");
281 } 281 }
282 } 282 }
283 283
284 void PrintConfigs(const Target* target, bool display_header) { 284 void PrintConfigs(const Target* target, bool display_header) {
285 PrintConfigsVector(target, target->configs().vector(), "configs", 285 PrintConfigsVector(target, target->configs().vector(), "configs",
286 display_header); 286 display_header);
287 } 287 }
288 288
289 void PrintPublicConfigs(const Target* target, bool display_header) { 289 void PrintPublicConfigs(const Target* target, bool display_header) {
290 PrintConfigsVector(target, target->public_configs(), 290 PrintConfigsVector(target, target->public_configs(),
(...skipping 12 matching lines...) Expand all
303 if (files.empty()) 303 if (files.empty())
304 return; 304 return;
305 305
306 if (display_header) 306 if (display_header)
307 OutputString("\n" + header + ":\n"); 307 OutputString("\n" + header + ":\n");
308 308
309 std::string indent = indent_extra ? " " : " "; 309 std::string indent = indent_extra ? " " : " ";
310 310
311 Target::FileList sorted = files; 311 Target::FileList sorted = files;
312 std::sort(sorted.begin(), sorted.end()); 312 std::sort(sorted.begin(), sorted.end());
313 for (size_t i = 0; i < sorted.size(); i++) 313 for (const auto& elem : sorted)
314 OutputString(indent + sorted[i].value() + "\n"); 314 OutputString(indent + elem.value() + "\n");
315 } 315 }
316 316
317 void PrintSources(const Target* target, bool display_header) { 317 void PrintSources(const Target* target, bool display_header) {
318 PrintFileList(target->sources(), "sources", false, display_header); 318 PrintFileList(target->sources(), "sources", false, display_header);
319 } 319 }
320 320
321 void PrintInputs(const Target* target, bool display_header) { 321 void PrintInputs(const Target* target, bool display_header) {
322 PrintFileList(target->inputs(), "inputs", false, display_header); 322 PrintFileList(target->inputs(), "inputs", false, display_header);
323 } 323 }
324 324
325 void PrintOutputs(const Target* target, bool display_header) { 325 void PrintOutputs(const Target* target, bool display_header) {
326 if (display_header) 326 if (display_header)
327 OutputString("\noutputs:\n"); 327 OutputString("\noutputs:\n");
328 328
329 if (target->output_type() == Target::ACTION) { 329 if (target->output_type() == Target::ACTION) {
330 // Action, print out outputs, don't apply sources to it. 330 // Action, print out outputs, don't apply sources to it.
331 for (size_t i = 0; i < target->action_values().outputs().list().size(); 331 for (const auto& elem : target->action_values().outputs().list()) {
332 i++) { 332 OutputString(" " + elem.AsString() + "\n");
333 OutputString(" " +
334 target->action_values().outputs().list()[i].AsString() +
335 "\n");
336 } 333 }
337 } else { 334 } else {
338 const SubstitutionList& outputs = target->action_values().outputs(); 335 const SubstitutionList& outputs = target->action_values().outputs();
339 if (!outputs.required_types().empty()) { 336 if (!outputs.required_types().empty()) {
340 // Display the pattern and resolved pattern separately, since there are 337 // Display the pattern and resolved pattern separately, since there are
341 // subtitutions used. 338 // subtitutions used.
342 OutputString(" Output pattern:\n"); 339 OutputString(" Output pattern:\n");
343 for (size_t i = 0; i < outputs.list().size(); i++) 340 for (const auto& elem : outputs.list())
344 OutputString(" " + outputs.list()[i].AsString() + "\n"); 341 OutputString(" " + elem.AsString() + "\n");
345 342
346 // Now display what that resolves to given the sources. 343 // Now display what that resolves to given the sources.
347 OutputString("\n Resolved output file list:\n"); 344 OutputString("\n Resolved output file list:\n");
348 } 345 }
349 346
350 // Resolved output list. 347 // Resolved output list.
351 std::vector<SourceFile> output_files; 348 std::vector<SourceFile> output_files;
352 SubstitutionWriter::ApplyListToSources(target->settings(), outputs, 349 SubstitutionWriter::ApplyListToSources(target->settings(), outputs,
353 target->sources(), &output_files); 350 target->sources(), &output_files);
354 PrintFileList(output_files, "", true, false); 351 PrintFileList(output_files, "", true, false);
355 } 352 }
356 } 353 }
357 354
358 void PrintScript(const Target* target, bool display_header) { 355 void PrintScript(const Target* target, bool display_header) {
359 if (display_header) 356 if (display_header)
360 OutputString("\nscript:\n"); 357 OutputString("\nscript:\n");
361 OutputString(" " + target->action_values().script().value() + "\n"); 358 OutputString(" " + target->action_values().script().value() + "\n");
362 } 359 }
363 360
364 void PrintArgs(const Target* target, bool display_header) { 361 void PrintArgs(const Target* target, bool display_header) {
365 if (display_header) 362 if (display_header)
366 OutputString("\nargs:\n"); 363 OutputString("\nargs:\n");
367 for (size_t i = 0; i < target->action_values().args().list().size(); i++) { 364 for (const auto& elem : target->action_values().args().list()) {
368 OutputString(" " + 365 OutputString(" " + elem.AsString() + "\n");
369 target->action_values().args().list()[i].AsString() + "\n");
370 } 366 }
371 } 367 }
372 368
373 void PrintDepfile(const Target* target, bool display_header) { 369 void PrintDepfile(const Target* target, bool display_header) {
374 if (target->action_values().depfile().empty()) 370 if (target->action_values().depfile().empty())
375 return; 371 return;
376 if (display_header) 372 if (display_header)
377 OutputString("\ndepfile:\n"); 373 OutputString("\ndepfile:\n");
378 OutputString(" " + target->action_values().depfile().AsString() + "\n"); 374 OutputString(" " + target->action_values().depfile().AsString() + "\n");
379 } 375 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 // so always display them, even for groups and such. 716 // so always display them, even for groups and such.
721 PrintLibs(target, true); 717 PrintLibs(target, true);
722 PrintLibDirs(target, true); 718 PrintLibDirs(target, true);
723 719
724 PrintDeps(target, true); 720 PrintDeps(target, true);
725 721
726 return 0; 722 return 0;
727 } 723 }
728 724
729 } // namespace commands 725 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/command_clean.cc ('k') | tools/gn/err.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698