diff options
author | Nicolas Despres <nicolas.despres@gmail.com> | 2011-04-10 16:29:13 (GMT) |
---|---|---|
committer | Nicolas Despres <nicolas.despres@gmail.com> | 2011-04-26 11:23:06 (GMT) |
commit | 7b67e48a1479c6fc7326c55756088bd57d64fc82 (patch) | |
tree | f5a2b65bebf8d591f6c24fc7ee72786b91b9a05e /src/ninja.cc | |
parent | 3ad977241b24ea8077073f1f3feecab7b8dc0b55 (diff) | |
download | Ninja-7b67e48a1479c6fc7326c55756088bd57d64fc82.zip Ninja-7b67e48a1479c6fc7326c55756088bd57d64fc82.tar.gz Ninja-7b67e48a1479c6fc7326c55756088bd57d64fc82.tar.bz2 |
Add the 'rules' tool.
It can be useful in conjunction with the 'targets' tool for writing shell
completion scripts and when debugging.
Diffstat (limited to 'src/ninja.cc')
-rw-r--r-- | src/ninja.cc | 19 |
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()); } |