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

Unified Diff: tools/gn/substitution_writer.cc

Issue 462103004: GN: Bug fixes in process_file_template (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
Index: tools/gn/substitution_writer.cc
diff --git a/tools/gn/substitution_writer.cc b/tools/gn/substitution_writer.cc
index 0738b6f7e0a070fa23092ea6049fb65e26e85e36..d677cc81998993204970902f3c3ec90bf8307cfb 100644
--- a/tools/gn/substitution_writer.cc
+++ b/tools/gn/substitution_writer.cc
@@ -129,6 +129,20 @@ SourceFile SubstitutionWriter::ApplyPatternToSource(
const Settings* settings,
const SubstitutionPattern& pattern,
const SourceFile& source) {
+ std::string result_value = ApplyPatternToSourceAsString(
+ settings, pattern, source);
+ CHECK(!result_value.empty() && result_value[0] == '/')
+ << "The result of the pattern \""
+ << pattern.AsString()
+ << "\" was not a path beginning in \"/\" or \"//\".";
+ return SourceFile(SourceFile::SWAP_IN, &result_value);
+}
+
+// static
+std::string SubstitutionWriter::ApplyPatternToSourceAsString(
+ const Settings* settings,
+ const SubstitutionPattern& pattern,
+ const SourceFile& source) {
std::string result_value;
for (size_t i = 0; i < pattern.ranges().size(); i++) {
const SubstitutionPattern::Subrange& subrange = pattern.ranges()[i];
@@ -140,11 +154,7 @@ SourceFile SubstitutionWriter::ApplyPatternToSource(
OUTPUT_ABSOLUTE, SourceDir()));
}
}
- CHECK(!result_value.empty() && result_value[0] == '/')
- << "The result of the pattern \""
- << pattern.AsString()
- << "\" was not a path beginning in \"/\" or \"//\".";
- return SourceFile(SourceFile::SWAP_IN, &result_value);
+ return result_value;
}
// static
@@ -175,6 +185,18 @@ void SubstitutionWriter::ApplyListToSource(
}
// static
+void SubstitutionWriter::ApplyListToSourceAsString(
+ const Settings* settings,
+ const SubstitutionList& list,
+ const SourceFile& source,
+ std::vector<std::string>* output) {
+ for (size_t i = 0; i < list.list().size(); i++) {
+ output->push_back(ApplyPatternToSourceAsString(
+ settings, list.list()[i], source));
+ }
+}
+
+// static
void SubstitutionWriter::ApplyListToSourceAsOutputFile(
const Settings* settings,
const SubstitutionList& list,
@@ -198,6 +220,17 @@ void SubstitutionWriter::ApplyListToSources(
}
// static
+void SubstitutionWriter::ApplyListToSourcesAsString(
+ const Settings* settings,
+ const SubstitutionList& list,
+ const std::vector<SourceFile>& sources,
+ std::vector<std::string>* output) {
+ output->clear();
+ for (size_t i = 0; i < sources.size(); i++)
+ ApplyListToSourceAsString(settings, list, sources[i], output);
+}
+
+// static
void SubstitutionWriter::ApplyListToSourcesAsOutputFile(
const Settings* settings,
const SubstitutionList& list,
« tools/gn/function_process_file_template.cc ('K') | « tools/gn/substitution_writer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698