| 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/build_settings.h" | 5 #include "tools/gn/build_settings.h" |
| 6 #include "tools/gn/filesystem_utils.h" | 6 #include "tools/gn/filesystem_utils.h" |
| 7 #include "tools/gn/functions.h" | 7 #include "tools/gn/functions.h" |
| 8 #include "tools/gn/parse_tree.h" | 8 #include "tools/gn/parse_tree.h" |
| 9 #include "tools/gn/scope.h" | 9 #include "tools/gn/scope.h" |
| 10 #include "tools/gn/settings.h" | 10 #include "tools/gn/settings.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 return result; | 246 return result; |
| 247 from_dir = | 247 from_dir = |
| 248 current_dir.ResolveRelativeDir(args[kArgIndexFrom].string_value()); | 248 current_dir.ResolveRelativeDir(args[kArgIndexFrom].string_value()); |
| 249 } else { | 249 } else { |
| 250 // Default to current directory if unspecified. | 250 // Default to current directory if unspecified. |
| 251 from_dir = current_dir; | 251 from_dir = current_dir; |
| 252 } | 252 } |
| 253 | 253 |
| 254 // Path conversion. | 254 // Path conversion. |
| 255 if (inputs.type() == Value::STRING) { | 255 if (inputs.type() == Value::STRING) { |
| 256 if (inputs.string_value() == "//foo") |
| 257 printf("foo\n"); |
| 256 return ConvertOnePath(scope, function, inputs, | 258 return ConvertOnePath(scope, function, inputs, |
| 257 from_dir, to_dir, convert_to_system_absolute, err); | 259 from_dir, to_dir, convert_to_system_absolute, err); |
| 258 | 260 |
| 259 } else if (inputs.type() == Value::LIST) { | 261 } else if (inputs.type() == Value::LIST) { |
| 260 result = Value(function, Value::LIST); | 262 result = Value(function, Value::LIST); |
| 261 result.list_value().reserve(inputs.list_value().size()); | 263 result.list_value().reserve(inputs.list_value().size()); |
| 262 | 264 |
| 263 for (size_t i = 0; i < inputs.list_value().size(); i++) { | 265 for (size_t i = 0; i < inputs.list_value().size(); i++) { |
| 264 result.list_value().push_back( | 266 result.list_value().push_back( |
| 265 ConvertOnePath(scope, function, inputs.list_value()[i], | 267 ConvertOnePath(scope, function, inputs.list_value()[i], |
| 266 from_dir, to_dir, convert_to_system_absolute, err)); | 268 from_dir, to_dir, convert_to_system_absolute, err)); |
| 267 if (err->has_error()) { | 269 if (err->has_error()) { |
| 268 result = Value(); | 270 result = Value(); |
| 269 return result; | 271 return result; |
| 270 } | 272 } |
| 271 } | 273 } |
| 272 return result; | 274 return result; |
| 273 } | 275 } |
| 274 | 276 |
| 275 *err = Err(function->function(), | 277 *err = Err(function->function(), |
| 276 "rebase_path requires a list or a string."); | 278 "rebase_path requires a list or a string."); |
| 277 return result; | 279 return result; |
| 278 } | 280 } |
| 279 | 281 |
| 280 } // namespace functions | 282 } // namespace functions |
| OLD | NEW |