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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/function_process_file_template.cc
diff --git a/tools/gn/function_process_file_template.cc b/tools/gn/function_process_file_template.cc
index 5d4c9d7b4ed5b5dd7bc96ec26ef0976c245a2878..061c9017db90ca89d112baa4f4434d3aa21c4172 100644
--- a/tools/gn/function_process_file_template.cc
+++ b/tools/gn/function_process_file_template.cc
@@ -5,6 +5,10 @@
#include "tools/gn/file_template.h"
#include "tools/gn/functions.h"
#include "tools/gn/parse_tree.h"
+#include "tools/gn/scope.h"
+#include "tools/gn/settings.h"
+#include "tools/gn/target.h"
+#include "tools/gn/value_extractors.h"
namespace functions {
@@ -67,12 +71,26 @@ Value RunProcessFileTemplate(Scope* scope,
return Value();
}
- FileTemplate file_template(args[1], err);
+ FileTemplate file_template(scope->settings(), args[1], err);
if (err->has_error())
return Value();
+ Target::FileList input_files;
+ if (!ExtractListOfRelativeFiles(scope->settings()->build_settings(), args[0],
+ scope->GetSourceDir(), &input_files, err))
+ return Value();
+
Value ret(function, Value::LIST);
- file_template.Apply(args[0], function, &ret.list_value(), err);
+
+ // Temporary holding place, allocate outside to re-use buffer.
+ std::vector<std::string> string_output;
+
+ for (size_t i = 0; i < input_files.size(); i++) {
+ string_output.clear();
+ file_template.Apply(input_files[i], &string_output);
+ for (size_t out_i = 0; out_i < string_output.size(); out_i++)
+ ret.list_value().push_back(Value(function, string_output[out_i]));
+ }
return ret;
}
« 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