Index: tools/gn/command_refs.cc |
diff --git a/tools/gn/command_refs.cc b/tools/gn/command_refs.cc |
index 832f53a7f29a957f11d0b6b121f308ef0b7578c8..5b91822b9bfee0cd5a32ebf3801af4c5b033960d 100644 |
--- a/tools/gn/command_refs.cc |
+++ b/tools/gn/command_refs.cc |
@@ -6,6 +6,8 @@ |
#include <set> |
#include "base/command_line.h" |
+#include "base/files/file_util.h" |
+#include "base/strings/string_split.h" |
#include "tools/gn/commands.h" |
#include "tools/gn/deps_iterator.h" |
#include "tools/gn/filesystem_utils.h" |
@@ -266,7 +268,8 @@ const char kRefs[] = "refs"; |
const char kRefs_HelpShort[] = |
"refs: Find stuff referencing a target or file."; |
const char kRefs_Help[] = |
- "gn refs <out_dir> (<label_pattern>|<label>|<file>)* [--all]\n" |
+ "gn refs <out_dir> (<label_pattern>|<label>|<file>|<response_file>)* " |
brettw
2015/04/17 02:44:27
Can you make this ...|@<response_file>...
Dirk Pranke
2015/04/17 02:58:12
Will do.
|
+ "[--all]\n" |
" [--all-toolchains] [--as=...] [--testonly=...] [--type=...]\n" |
"\n" |
" Finds reverse dependencies (which targets reference something). The\n" |
@@ -287,6 +290,11 @@ const char kRefs_Help[] = |
" that does not contain wildcards and does not match a target or a\n" |
" config will be treated as a file.\n" |
"\n" |
+ " - Response file: If the input starts with an \"@\", it will be\n" |
+ " interpreted as a path to a file containing a list of labels or\n" |
+ " file names, one per line. This allows us to handle long lists\n" |
+ " of inputs without worrying about command line limits.\n" |
+ "\n" |
"Options\n" |
"\n" |
" --all\n" |
@@ -388,7 +396,26 @@ int RunRefs(const std::vector<std::string>& args) { |
return 1; |
// The inputs are everything but the first arg (which is the build dir). |
- std::vector<std::string> inputs(args.begin() + 1, args.end()); |
+ std::vector<std::string> inputs; |
+ for (auto it = args.begin() + 1; it != args.end(); it++) { |
+ auto arg = *it; |
+ |
+ if (arg[0] == '@') { |
+ // The argument is as a path to a response file. |
+ std::string contents; |
+ bool ret = base::ReadFileToString(base::FilePath(arg.substr(1)), |
+ &contents); |
+ if (!ret) { |
+ Err(Location(), "Response file " + arg.substr(1) + " not found.") |
+ .PrintToStdout(); |
+ return 1; |
+ } |
+ base::SplitStringAlongWhitespace(contents, &inputs); |
Dirk Pranke
2015/04/17 01:27:41
I'm not sure if this is the best base routine to u
brettw
2015/04/17 02:44:27
Yeah, this will fall over for command-lines that i
Dirk Pranke
2015/04/17 02:58:12
That works for me (the layout tests actually suppo
|
+ } else { |
+ // The argument is a label or a path. |
+ inputs.push_back(*it); |
+ } |
+ } |
// Get the matches for the command-line input. |
UniqueVector<const Target*> target_matches; |