Remove `gn meta` specific switches from switches.h
This CL simplifies and fixes some code and documentation
related to the `gn meta` switches --rebase, --walk and --data:
- Update the documentation to indicate that the lists for
--data and --walk are comma-separated, and fix the example
(which didn't work).
- Fix the handling of `--rebase` (the code actually was looking
for `--rebase-files` instead).
- Remove the kMetaXXX declarations from switches.h since one
of them was misnamed (kMetaRebaseFiles), and their help
text was never used at runtime anyway. Besides the switches
are already documented in `gn help meta`, and do not affect
GN globally, like most other switches in switches.h
Bug: None
Change-Id: I96ce5d511efbdcb93441110c58ff92a9783ee296
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/12860
Reviewed-by: Brett Wilson <brettw@chromium.org>
Commit-Queue: David Turner <digit@google.com>
diff --git a/src/gn/command_meta.cc b/src/gn/command_meta.cc
index 27897e2..aa5e88c 100644
--- a/src/gn/command_meta.cc
+++ b/src/gn/command_meta.cc
@@ -35,17 +35,18 @@
A list of target labels from which to initiate the walk.
--data
- A list of keys from which to extract data. In each target walked, its metadata
- scope is checked for the presence of these keys. If present, the contents of
- those variable in the scope are appended to the results list.
+ A comma-separated list of keys from which to extract data. In each target
+ walked, its metadata scope is checked for the presence of these keys. If
+ present, the contents of those variable in the scope are appended to the
+ results list.
--walk (optional)
- A list of keys from which to control the walk. In each target walked, its
- metadata scope is checked for the presence of any of these keys. If present,
- the contents of those variables is checked to ensure that it is a label of
- a valid dependency of the target and then added to the set of targets to walk.
- If the empty string ("") is present in any of these keys, all deps and data_deps
- are added to the walk set.
+ A comma-separated list of keys from which to control the walk. In each
+ target walked, its metadata scope is checked for the presence of any of
+ these keys. If present, the contents of those variables is checked to ensure
+ that it is a label of a valid dependency of the target and then added to the
+ set of targets to walk. If the empty string ("") is present in any of these
+ keys, all deps and data_deps are added to the walk set.
--rebase (optional)
A destination directory onto which to rebase any paths found. If set, all
@@ -58,7 +59,7 @@
Lists collected metaresults for the `files` key in the //base/foo:foo
target and all of its dependency tree.
- gn meta out/Debug "//base/foo" --data=files --data=other
+ gn meta out/Debug "//base/foo" --data=files,other
Lists collected metaresults for the `files` and `other` keys in the
//base/foo:foo target and all of its dependency tree.
@@ -86,12 +87,9 @@
return 1;
const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
- std::string rebase_dir =
- cmdline->GetSwitchValueASCII(switches::kMetaRebaseFiles);
- std::string data_keys_str =
- cmdline->GetSwitchValueASCII(switches::kMetaDataKeys);
- std::string walk_keys_str =
- cmdline->GetSwitchValueASCII(switches::kMetaWalkKeys);
+ std::string rebase_dir = cmdline->GetSwitchValueASCII("rebase");
+ std::string data_keys_str = cmdline->GetSwitchValueASCII("data");
+ std::string walk_keys_str = cmdline->GetSwitchValueASCII("walk");
std::vector<std::string> inputs(args.begin() + 1, args.end());
diff --git a/src/gn/switches.cc b/src/gn/switches.cc
index fb63b30..6caec3a 100644
--- a/src/gn/switches.cc
+++ b/src/gn/switches.cc
@@ -123,39 +123,6 @@
and exec_script calls will be executed directly.
)";
-const char kMetaDataKeys[] = "data";
-const char kMetaDataKeys_HelpShort[] =
- "--data: list of data keys to concatenate when collecting metadata.";
-const char kMetaDataKeys_Help[] =
- R"(--data: list of data keys to concatenate when collecting metadata.
-
- Data keys identify which variables in the given targets' `metadata`
- scopes should be collected. At least one data key must be specified.
-)";
-
-const char kMetaWalkKeys[] = "walk";
-const char kMetaWalkKeys_HelpShort[] =
- "--walk: list of walk keys to traverse when collecting metadata.";
-const char kMetaWalkKeys_Help[] =
- R"(--walk: list of walk keys to traverse when collecting metadata.
-
- Walk keys identify which variables in the given targets' `metadata`
- scopes contain the list of dependencies to walk next. Absence of any
- walk keys indicates that all deps and data_deps should be walked.
-)";
-
-const char kMetaRebaseFiles[] = "rebase-files";
-const char kMetaRebaseFiles_HelpShort[] =
- "--rebase-files (boolean): whether to rebase the paths of the collected "
- "metadata.";
-const char kMetaRebaseFiles_Help[] =
- R"(--rebase-files: whether to rebase the paths of the collected metadata.
-
- This flag indicates whether or not to rebase the collected results onto their
- declaring source directory path. Note that this requires the data key(s) to
- contain only lists of strings, which will be interpreted as file names.
-)";
-
const char kQuiet[] = "q";
const char kQuiet_HelpShort[] =
"-q: Quiet mode. Don't print output on success.";
diff --git a/src/gn/switches.h b/src/gn/switches.h
index 2382bb7..22099d3 100644
--- a/src/gn/switches.h
+++ b/src/gn/switches.h
@@ -46,18 +46,6 @@
extern const char kMarkdown_HelpShort[];
extern const char kMarkdown_Help[];
-extern const char kMetaDataKeys[];
-extern const char kMetaDataKeys_HelpShort[];
-extern const char kMetaDataKeys_Help[];
-
-extern const char kMetaWalkKeys[];
-extern const char kMetaWalkKeys_HelpShort[];
-extern const char kMetaWalkKeys_Help[];
-
-extern const char kMetaRebaseFiles[];
-extern const char kMetaRebaseFiles_HelpShort[];
-extern const char kMetaRebaseFiles_Help[];
-
extern const char kNinjaExecutable[];
extern const char kNinjaExecutable_HelpShort[];
extern const char kNinjaExecutable_Help[];