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

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

Issue 334333005: Add directory extraction to GN path handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge to new file template function Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/function_get_target_outputs.cc ('k') | tools/gn/ninja_action_target_writer.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 "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"
9 #include "tools/gn/settings.h"
10 #include "tools/gn/target.h"
11 #include "tools/gn/value_extractors.h"
8 12
9 namespace functions { 13 namespace functions {
10 14
11 const char kProcessFileTemplate[] = "process_file_template"; 15 const char kProcessFileTemplate[] = "process_file_template";
12 const char kProcessFileTemplate_HelpShort[] = 16 const char kProcessFileTemplate_HelpShort[] =
13 "process_file_template: Do template expansion over a list of files."; 17 "process_file_template: Do template expansion over a list of files.";
14 const char kProcessFileTemplate_Help[] = 18 const char kProcessFileTemplate_Help[] =
15 "process_file_template: Do template expansion over a list of files.\n" 19 "process_file_template: Do template expansion over a list of files.\n"
16 "\n" 20 "\n"
17 " process_file_template(source_list, template)\n" 21 " process_file_template(source_list, template)\n"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 64
61 Value RunProcessFileTemplate(Scope* scope, 65 Value RunProcessFileTemplate(Scope* scope,
62 const FunctionCallNode* function, 66 const FunctionCallNode* function,
63 const std::vector<Value>& args, 67 const std::vector<Value>& args,
64 Err* err) { 68 Err* err) {
65 if (args.size() != 2) { 69 if (args.size() != 2) {
66 *err = Err(function->function(), "Expected two arguments"); 70 *err = Err(function->function(), "Expected two arguments");
67 return Value(); 71 return Value();
68 } 72 }
69 73
70 FileTemplate file_template(args[1], err); 74 FileTemplate file_template(scope->settings(), args[1], err);
71 if (err->has_error()) 75 if (err->has_error())
72 return Value(); 76 return Value();
73 77
78 Target::FileList input_files;
79 if (!ExtractListOfRelativeFiles(scope->settings()->build_settings(), args[0],
80 scope->GetSourceDir(), &input_files, err))
81 return Value();
82
74 Value ret(function, Value::LIST); 83 Value ret(function, Value::LIST);
75 file_template.Apply(args[0], function, &ret.list_value(), err); 84
85 // Temporary holding place, allocate outside to re-use buffer.
86 std::vector<std::string> string_output;
87
88 for (size_t i = 0; i < input_files.size(); i++) {
89 string_output.clear();
90 file_template.Apply(input_files[i], &string_output);
91 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 }
76 return ret; 94 return ret;
77 } 95 }
78 96
79 } // namespace functions 97 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/function_get_target_outputs.cc ('k') | tools/gn/ninja_action_target_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698