| 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/file_template.h" | 5 #include "tools/gn/file_template.h" |
| 6 #include "tools/gn/functions.h" | 6 #include "tools/gn/functions.h" |
| 7 #include "tools/gn/parse_tree.h" | 7 #include "tools/gn/parse_tree.h" |
| 8 #include "tools/gn/scope.h" | 8 #include "tools/gn/scope.h" |
| 9 #include "tools/gn/settings.h" | 9 #include "tools/gn/settings.h" |
| 10 #include "tools/gn/target.h" | 10 #include "tools/gn/target.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 Value RunProcessFileTemplate(Scope* scope, | 65 Value RunProcessFileTemplate(Scope* scope, |
| 66 const FunctionCallNode* function, | 66 const FunctionCallNode* function, |
| 67 const std::vector<Value>& args, | 67 const std::vector<Value>& args, |
| 68 Err* err) { | 68 Err* err) { |
| 69 if (args.size() != 2) { | 69 if (args.size() != 2) { |
| 70 *err = Err(function->function(), "Expected two arguments"); | 70 *err = Err(function->function(), "Expected two arguments"); |
| 71 return Value(); | 71 return Value(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 FileTemplate file_template(scope->settings(), args[1], err); | 74 FileTemplate file_template(scope->settings(), args[1], |
| 75 FileTemplate::OUTPUT_ABSOLUTE, SourceDir(), err); |
| 75 if (err->has_error()) | 76 if (err->has_error()) |
| 76 return Value(); | 77 return Value(); |
| 77 | 78 |
| 78 Target::FileList input_files; | 79 Target::FileList input_files; |
| 79 if (!ExtractListOfRelativeFiles(scope->settings()->build_settings(), args[0], | 80 if (!ExtractListOfRelativeFiles(scope->settings()->build_settings(), args[0], |
| 80 scope->GetSourceDir(), &input_files, err)) | 81 scope->GetSourceDir(), &input_files, err)) |
| 81 return Value(); | 82 return Value(); |
| 82 | 83 |
| 83 Value ret(function, Value::LIST); | 84 Value ret(function, Value::LIST); |
| 84 | 85 |
| 85 // Temporary holding place, allocate outside to re-use buffer. | 86 // Temporary holding place, allocate outside to re-use buffer. |
| 86 std::vector<std::string> string_output; | 87 std::vector<std::string> string_output; |
| 87 | 88 |
| 88 for (size_t i = 0; i < input_files.size(); i++) { | 89 for (size_t i = 0; i < input_files.size(); i++) { |
| 89 string_output.clear(); | 90 string_output.clear(); |
| 90 file_template.Apply(input_files[i], &string_output); | 91 file_template.Apply(input_files[i], &string_output); |
| 91 for (size_t out_i = 0; out_i < string_output.size(); out_i++) | 92 for (size_t out_i = 0; out_i < string_output.size(); out_i++) |
| 92 ret.list_value().push_back(Value(function, string_output[out_i])); | 93 ret.list_value().push_back(Value(function, string_output[out_i])); |
| 93 } | 94 } |
| 94 return ret; | 95 return ret; |
| 95 } | 96 } |
| 96 | 97 |
| 97 } // namespace functions | 98 } // namespace functions |
| OLD | NEW |