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

Unified Diff: tools/gn/function_process_file_template.cc

Issue 429423002: Refactor GN source expansions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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_unittest.cc ('k') | tools/gn/function_write_file.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 0c561345e04cc3dbcaf57b2db22665c6a2c6d96d..2e540f4fbfdc78400d39170f9437291a9e31ee91 100644
--- a/tools/gn/function_process_file_template.cc
+++ b/tools/gn/function_process_file_template.cc
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#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/substitution_list.h"
+#include "tools/gn/substitution_writer.h"
#include "tools/gn/target.h"
#include "tools/gn/value_extractors.h"
@@ -71,27 +72,26 @@ Value RunProcessFileTemplate(Scope* scope,
return Value();
}
- FileTemplate file_template(scope->settings(), args[1],
- FileTemplate::OUTPUT_ABSOLUTE, SourceDir(), err);
- if (err->has_error())
- return Value();
-
+ // Source list.
Target::FileList input_files;
if (!ExtractListOfRelativeFiles(scope->settings()->build_settings(), args[0],
scope->GetSourceDir(), &input_files, err))
return Value();
- Value ret(function, Value::LIST);
+ // Template.
+ SubstitutionList subst;
+ if (!subst.Parse(args[1], err))
+ return Value();
- // Temporary holding place, allocate outside to re-use buffer.
- std::vector<std::string> string_output;
+ std::vector<SourceFile> result_files;
+ SubstitutionWriter::ApplyListToSources(
+ scope->settings(), subst, input_files, &result_files);
+
+ Value ret(function, Value::LIST);
+ ret.list_value().reserve(result_files.size());
+ for (size_t i = 0; i < result_files.size(); i++)
+ ret.list_value().push_back(Value(function, result_files[i].value()));
- 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_unittest.cc ('k') | tools/gn/function_write_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698