summaryrefslogtreecommitdiffstats
path: root/src/ninja.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninja.cc')
-rw-r--r--src/ninja.cc19
1 files changed, 18 insertions, 1 deletions
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());
}