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

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

Issue 610293003: Replace more for loops in GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 6 years, 2 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/err.cc ('k') | tools/gn/function_foreach.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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/process/kill.h" 8 #include "base/process/kill.h"
9 #include "base/process/launch.h" 9 #include "base/process/launch.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 trace.SetToolchain(settings->toolchain_label()); 318 trace.SetToolchain(settings->toolchain_label());
319 319
320 // Add all dependencies of this script, including the script itself, to the 320 // Add all dependencies of this script, including the script itself, to the
321 // build deps. 321 // build deps.
322 g_scheduler->AddGenDependency(script_path); 322 g_scheduler->AddGenDependency(script_path);
323 if (args.size() == 4) { 323 if (args.size() == 4) {
324 const Value& deps_value = args[3]; 324 const Value& deps_value = args[3];
325 if (!deps_value.VerifyTypeIs(Value::LIST, err)) 325 if (!deps_value.VerifyTypeIs(Value::LIST, err))
326 return Value(); 326 return Value();
327 327
328 for (size_t i = 0; i < deps_value.list_value().size(); i++) { 328 for (const auto& dep : deps_value.list_value()) {
329 if (!deps_value.list_value()[0].VerifyTypeIs(Value::STRING, err)) 329 if (!dep.VerifyTypeIs(Value::STRING, err))
330 return Value(); 330 return Value();
331 g_scheduler->AddGenDependency( 331 g_scheduler->AddGenDependency(
332 build_settings->GetFullPath(cur_dir.ResolveRelativeFile( 332 build_settings->GetFullPath(cur_dir.ResolveRelativeFile(
333 deps_value.list_value()[0].string_value()))); 333 dep.string_value())));
334 } 334 }
335 } 335 }
336 336
337 // Make the command line. 337 // Make the command line.
338 const base::FilePath& python_path = build_settings->python_path(); 338 const base::FilePath& python_path = build_settings->python_path();
339 CommandLine cmdline(python_path); 339 CommandLine cmdline(python_path);
340 cmdline.AppendArgPath(script_path); 340 cmdline.AppendArgPath(script_path);
341 341
342 if (args.size() >= 2) { 342 if (args.size() >= 2) {
343 // Optional command-line arguments to the script. 343 // Optional command-line arguments to the script.
344 const Value& script_args = args[1]; 344 const Value& script_args = args[1];
345 if (!script_args.VerifyTypeIs(Value::LIST, err)) 345 if (!script_args.VerifyTypeIs(Value::LIST, err))
346 return Value(); 346 return Value();
347 for (size_t i = 0; i < script_args.list_value().size(); i++) { 347 for (const auto& arg : script_args.list_value()) {
348 if (!script_args.list_value()[i].VerifyTypeIs(Value::STRING, err)) 348 if (!arg.VerifyTypeIs(Value::STRING, err))
349 return Value(); 349 return Value();
350 cmdline.AppendArg(script_args.list_value()[i].string_value()); 350 cmdline.AppendArg(arg.string_value());
351 } 351 }
352 } 352 }
353 353
354 // Log command line for debugging help. 354 // Log command line for debugging help.
355 trace.SetCommandLine(cmdline); 355 trace.SetCommandLine(cmdline);
356 base::TimeTicks begin_exec; 356 base::TimeTicks begin_exec;
357 if (g_scheduler->verbose_logging()) { 357 if (g_scheduler->verbose_logging()) {
358 #if defined(OS_WIN) 358 #if defined(OS_WIN)
359 g_scheduler->Log("Pythoning", 359 g_scheduler->Log("Pythoning",
360 base::UTF16ToUTF8(cmdline.GetCommandLineString())); 360 base::UTF16ToUTF8(cmdline.GetCommandLineString()));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 msg); 408 msg);
409 return Value(); 409 return Value();
410 } 410 }
411 411
412 // Default to None value for the input conversion if unspecified. 412 // Default to None value for the input conversion if unspecified.
413 return ConvertInputToValue(scope->settings(), output, function, 413 return ConvertInputToValue(scope->settings(), output, function,
414 args.size() >= 3 ? args[2] : Value(), err); 414 args.size() >= 3 ? args[2] : Value(), err);
415 } 415 }
416 416
417 } // namespace functions 417 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/err.cc ('k') | tools/gn/function_foreach.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698