Index: tools/gn/commands.cc |
diff --git a/tools/gn/commands.cc b/tools/gn/commands.cc |
index ed7a009d6af2c6f7a866d7d82e753b701d07760e..8682d920dfbb7b5deef8114d5525f4f4ba9c4c36 100644 |
--- a/tools/gn/commands.cc |
+++ b/tools/gn/commands.cc |
@@ -5,6 +5,7 @@ |
#include "tools/gn/commands.h" |
#include "base/command_line.h" |
+#include "base/strings/string_split.h" |
#include "tools/gn/builder.h" |
#include "tools/gn/filesystem_utils.h" |
#include "tools/gn/item.h" |
@@ -468,6 +469,27 @@ void FilterTargetsByPatterns(const std::vector<const Target*>& input, |
} |
} |
+bool FilterPatternsFromString(const BuildSettings* build_settings, |
+ const std::string& label_list_string, |
+ std::vector<LabelPattern>* filters, |
+ Err* err) { |
+ std::vector<std::string> tokens = base::SplitString( |
+ label_list_string, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
+ SourceDir root_dir = |
+ SourceDirForCurrentDirectory(build_settings->root_path()); |
+ |
+ filters->reserve(tokens.size()); |
+ for (const std::string& token : tokens) { |
+ LabelPattern pattern = |
+ LabelPattern::GetPattern(root_dir, Value(nullptr, token), err); |
+ if (err->has_error()) |
+ return false; |
+ filters->push_back(pattern); |
+ } |
+ |
+ return true; |
+} |
+ |
void FilterAndPrintTargets(bool indent, std::vector<const Target*>* targets) { |
if (targets->empty()) |
return; |