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 "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/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 | 94 |
95 const Settings* settings = scope->settings(); | 95 const Settings* settings = scope->settings(); |
96 const BuildSettings* build_settings = settings->build_settings(); | 96 const BuildSettings* build_settings = settings->build_settings(); |
97 const SourceDir& cur_dir = scope->GetSourceDir(); | 97 const SourceDir& cur_dir = scope->GetSourceDir(); |
98 | 98 |
99 // Find the python script to run. | 99 // Find the python script to run. |
100 if (!args[0].VerifyTypeIs(Value::STRING, err)) | 100 if (!args[0].VerifyTypeIs(Value::STRING, err)) |
101 return Value(); | 101 return Value(); |
102 SourceFile script_source = | 102 SourceFile script_source = |
103 cur_dir.ResolveRelativeFile(args[0].string_value()); | 103 cur_dir.ResolveRelativeFile(args[0].string_value(), |
| 104 scope->settings()->build_settings()->root_path_utf8()); |
104 base::FilePath script_path = build_settings->GetFullPath(script_source); | 105 base::FilePath script_path = build_settings->GetFullPath(script_source); |
105 if (!build_settings->secondary_source_path().empty() && | 106 if (!build_settings->secondary_source_path().empty() && |
106 !base::PathExists(script_path)) { | 107 !base::PathExists(script_path)) { |
107 // Fall back to secondary source root when the file doesn't exist. | 108 // Fall back to secondary source root when the file doesn't exist. |
108 script_path = build_settings->GetFullPathSecondary(script_source); | 109 script_path = build_settings->GetFullPathSecondary(script_source); |
109 } | 110 } |
110 | 111 |
111 ScopedTrace trace(TraceItem::TRACE_SCRIPT_EXECUTE, script_source.value()); | 112 ScopedTrace trace(TraceItem::TRACE_SCRIPT_EXECUTE, script_source.value()); |
112 trace.SetToolchain(settings->toolchain_label()); | 113 trace.SetToolchain(settings->toolchain_label()); |
113 | 114 |
114 // Add all dependencies of this script, including the script itself, to the | 115 // Add all dependencies of this script, including the script itself, to the |
115 // build deps. | 116 // build deps. |
116 g_scheduler->AddGenDependency(script_path); | 117 g_scheduler->AddGenDependency(script_path); |
117 if (args.size() == 4) { | 118 if (args.size() == 4) { |
118 const Value& deps_value = args[3]; | 119 const Value& deps_value = args[3]; |
119 if (!deps_value.VerifyTypeIs(Value::LIST, err)) | 120 if (!deps_value.VerifyTypeIs(Value::LIST, err)) |
120 return Value(); | 121 return Value(); |
121 | 122 |
122 for (const auto& dep : deps_value.list_value()) { | 123 for (const auto& dep : deps_value.list_value()) { |
123 if (!dep.VerifyTypeIs(Value::STRING, err)) | 124 if (!dep.VerifyTypeIs(Value::STRING, err)) |
124 return Value(); | 125 return Value(); |
125 g_scheduler->AddGenDependency( | 126 g_scheduler->AddGenDependency( |
126 build_settings->GetFullPath(cur_dir.ResolveRelativeFile( | 127 build_settings->GetFullPath(cur_dir.ResolveRelativeFile( |
127 dep.string_value()))); | 128 dep.string_value(), |
| 129 scope->settings()->build_settings()->root_path_utf8()))); |
128 } | 130 } |
129 } | 131 } |
130 | 132 |
131 // Make the command line. | 133 // Make the command line. |
132 const base::FilePath& python_path = build_settings->python_path(); | 134 const base::FilePath& python_path = build_settings->python_path(); |
133 CommandLine cmdline(python_path); | 135 CommandLine cmdline(python_path); |
134 cmdline.AppendArgPath(script_path); | 136 cmdline.AppendArgPath(script_path); |
135 | 137 |
136 if (args.size() >= 2) { | 138 if (args.size() >= 2) { |
137 // Optional command-line arguments to the script. | 139 // Optional command-line arguments to the script. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 msg); | 206 msg); |
205 return Value(); | 207 return Value(); |
206 } | 208 } |
207 | 209 |
208 // Default to None value for the input conversion if unspecified. | 210 // Default to None value for the input conversion if unspecified. |
209 return ConvertInputToValue(scope->settings(), output, function, | 211 return ConvertInputToValue(scope->settings(), output, function, |
210 args.size() >= 3 ? args[2] : Value(), err); | 212 args.size() >= 3 ? args[2] : Value(), err); |
211 } | 213 } |
212 | 214 |
213 } // namespace functions | 215 } // namespace functions |
OLD | NEW |