summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--manual.asciidoc4
-rw-r--r--src/ninja.cc19
2 files changed, 22 insertions, 1 deletions
diff --git a/manual.asciidoc b/manual.asciidoc
index 8bfc2e7..53d6416 100644
--- a/manual.asciidoc
+++ b/manual.asciidoc
@@ -326,6 +326,10 @@ several times. If used like this +ninja -t targets all+ it
prints all the targets available without indentation and it is way faster
than the _depth_ mode. It returns non-zero if an error occurs.
+`rules`:: output the list of all rules with their description if they have
+one. It can be used to know which rule name to pass to
++ninja -t targets rule _name_+.
+
Ninja file reference
--------------------
diff --git a/src/ninja.cc b/src/ninja.cc
index 0bd51d5..3912139 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -59,7 +59,8 @@ void usage(const BuildConfig& config) {
" browse browse dependency graph in a web browser\n"
" graph output graphviz dot file for targets\n"
" query show inputs/outputs for a path\n"
-" targets list targets by their rule or depth in the DAG\n",
+" targets list targets by their rule or depth in the DAG\n"
+" rules list all rules\n",
config.parallelism);
}
@@ -261,6 +262,20 @@ int CmdTargets(State* state, int argc, char* argv[]) {
}
}
+int CmdRules(State* state, int argc, char* argv[]) {
+ for (map<string, const Rule*>::iterator i = state->rules_.begin();
+ i != state->rules_.end();
+ ++i) {
+ if (i->second->description_.unparsed_.empty())
+ printf("%s\n", i->first.c_str());
+ else
+ printf("%s: %s\n",
+ i->first.c_str(),
+ i->second->description_.unparsed_.c_str());
+ }
+ return 0;
+}
+
int main(int argc, char** argv) {
BuildConfig config;
const char* input_file = "build.ninja";
@@ -328,6 +343,8 @@ int main(int argc, char** argv) {
return CmdBrowse(&state, argc, argv);
if (tool == "targets")
return CmdTargets(&state, argc, argv);
+ if (tool == "rules")
+ return CmdRules(&state, argc, argv);
Error("unknown tool '%s'", tool.c_str());
}