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

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

Issue 630223002: gn: Support build directories outside the source tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated patch set 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
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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 300
301 const Settings* settings = scope->settings(); 301 const Settings* settings = scope->settings();
302 const BuildSettings* build_settings = settings->build_settings(); 302 const BuildSettings* build_settings = settings->build_settings();
303 const SourceDir& cur_dir = scope->GetSourceDir(); 303 const SourceDir& cur_dir = scope->GetSourceDir();
304 304
305 // Find the python script to run. 305 // Find the python script to run.
306 if (!args[0].VerifyTypeIs(Value::STRING, err)) 306 if (!args[0].VerifyTypeIs(Value::STRING, err))
307 return Value(); 307 return Value();
308 SourceFile script_source = 308 SourceFile script_source =
309 cur_dir.ResolveRelativeFile(args[0].string_value()); 309 cur_dir.ResolveRelativeFile(args[0].string_value(),
310 scope->settings()->build_settings()->root_path());
310 base::FilePath script_path = build_settings->GetFullPath(script_source); 311 base::FilePath script_path = build_settings->GetFullPath(script_source);
311 if (!build_settings->secondary_source_path().empty() && 312 if (!build_settings->secondary_source_path().empty() &&
312 !base::PathExists(script_path)) { 313 !base::PathExists(script_path)) {
313 // Fall back to secondary source root when the file doesn't exist. 314 // Fall back to secondary source root when the file doesn't exist.
314 script_path = build_settings->GetFullPathSecondary(script_source); 315 script_path = build_settings->GetFullPathSecondary(script_source);
315 } 316 }
316 317
317 ScopedTrace trace(TraceItem::TRACE_SCRIPT_EXECUTE, script_source.value()); 318 ScopedTrace trace(TraceItem::TRACE_SCRIPT_EXECUTE, script_source.value());
318 trace.SetToolchain(settings->toolchain_label()); 319 trace.SetToolchain(settings->toolchain_label());
319 320
320 // Add all dependencies of this script, including the script itself, to the 321 // Add all dependencies of this script, including the script itself, to the
321 // build deps. 322 // build deps.
322 g_scheduler->AddGenDependency(script_path); 323 g_scheduler->AddGenDependency(script_path);
323 if (args.size() == 4) { 324 if (args.size() == 4) {
324 const Value& deps_value = args[3]; 325 const Value& deps_value = args[3];
325 if (!deps_value.VerifyTypeIs(Value::LIST, err)) 326 if (!deps_value.VerifyTypeIs(Value::LIST, err))
326 return Value(); 327 return Value();
327 328
328 for (const auto& dep : deps_value.list_value()) { 329 for (const auto& dep : deps_value.list_value()) {
329 if (!dep.VerifyTypeIs(Value::STRING, err)) 330 if (!dep.VerifyTypeIs(Value::STRING, err))
330 return Value(); 331 return Value();
331 g_scheduler->AddGenDependency( 332 g_scheduler->AddGenDependency(
332 build_settings->GetFullPath(cur_dir.ResolveRelativeFile( 333 build_settings->GetFullPath(cur_dir.ResolveRelativeFile(
333 dep.string_value()))); 334 dep.string_value(),
335 scope->settings()->build_settings()->root_path())));
334 } 336 }
335 } 337 }
336 338
337 // Make the command line. 339 // Make the command line.
338 const base::FilePath& python_path = build_settings->python_path(); 340 const base::FilePath& python_path = build_settings->python_path();
339 CommandLine cmdline(python_path); 341 CommandLine cmdline(python_path);
340 cmdline.AppendArgPath(script_path); 342 cmdline.AppendArgPath(script_path);
341 343
342 if (args.size() >= 2) { 344 if (args.size() >= 2) {
343 // Optional command-line arguments to the script. 345 // Optional command-line arguments to the script.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 msg); 410 msg);
409 return Value(); 411 return Value();
410 } 412 }
411 413
412 // Default to None value for the input conversion if unspecified. 414 // Default to None value for the input conversion if unspecified.
413 return ConvertInputToValue(scope->settings(), output, function, 415 return ConvertInputToValue(scope->settings(), output, function,
414 args.size() >= 3 ? args[2] : Value(), err); 416 args.size() >= 3 ? args[2] : Value(), err);
415 } 417 }
416 418
417 } // namespace functions 419 } // namespace functions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698