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

Unified Diff: tools/gn/file_template.cc

Issue 269723006: Add get_target_outputs function to GN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 7 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/file_template.h ('k') | tools/gn/file_template_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/file_template.cc
diff --git a/tools/gn/file_template.cc b/tools/gn/file_template.cc
index ec34993229038fc5241a0477eeebc1d33c4bbc2c..b27087bbcda5075cff8786752e5fe859475f7426 100644
--- a/tools/gn/file_template.cc
+++ b/tools/gn/file_template.cc
@@ -91,6 +91,13 @@ FileTemplate::FileTemplate(const std::vector<std::string>& t)
ParseOneTemplateString(t[i]);
}
+FileTemplate::FileTemplate(const std::vector<SourceFile>& t)
+ : has_substitutions_(false) {
+ std::fill(types_required_, &types_required_[Subrange::NUM_TYPES], false);
+ for (size_t i = 0; i < t.size(); i++)
+ ParseOneTemplateString(t[i].value());
+}
+
FileTemplate::~FileTemplate() {
}
@@ -121,6 +128,7 @@ void FileTemplate::Apply(const Value& sources,
const std::vector<Value>& sources_list = sources.list_value();
for (size_t i = 0; i < sources_list.size(); i++) {
+ string_output.clear();
if (!sources_list[i].VerifyTypeIs(Value::STRING, err))
return;
@@ -140,17 +148,18 @@ void FileTemplate::ApplyString(const std::string& str,
subst[i] = GetSubstitution(str, static_cast<Subrange::Type>(i));
}
- output->resize(templates_.container().size());
+ size_t first_output_index = output->size();
+ output->resize(output->size() + templates_.container().size());
for (size_t template_i = 0;
template_i < templates_.container().size(); template_i++) {
const Template& t = templates_[template_i];
- (*output)[template_i].clear();
+ std::string& cur_output = (*output)[first_output_index + template_i];
for (size_t subrange_i = 0; subrange_i < t.container().size();
subrange_i++) {
if (t[subrange_i].type == Subrange::LITERAL)
- (*output)[template_i].append(t[subrange_i].literal);
+ cur_output.append(t[subrange_i].literal);
else
- (*output)[template_i].append(subst[t[subrange_i].type]);
+ cur_output.append(subst[t[subrange_i].type]);
}
}
}
« no previous file with comments | « tools/gn/file_template.h ('k') | tools/gn/file_template_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698