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, |