summaryrefslogtreecommitdiffstats
path: root/src/ninja.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-01-28 17:50:58 (GMT)
committerEvan Martin <martine@danga.com>2011-01-28 17:50:58 (GMT)
commitf7a4d42b6d8753d6d141020726591bddfbcd7855 (patch)
treeaf9d83d838f210a3f479ce54dec482426396f0ab /src/ninja.cc
parent4e646c299b555a83776aaa6cd265a07f6aedce48 (diff)
downloadNinja-f7a4d42b6d8753d6d141020726591bddfbcd7855.zip
Ninja-f7a4d42b6d8753d6d141020726591bddfbcd7855.tar.gz
Ninja-f7a4d42b6d8753d6d141020726591bddfbcd7855.tar.bz2
move tools into a flag
Diffstat (limited to 'src/ninja.cc')
-rw-r--r--src/ninja.cc39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/ninja.cc b/src/ninja.cc
index dc878d0..6100357 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -31,12 +31,14 @@ void usage() {
"usage: ninja [options] target\n"
"\n"
"options:\n"
-" -g output graphviz dot file for targets and exit\n"
" -i FILE specify input build file [default=build.ninja]\n"
" -n dry run (don't run commands but pretend they succeeded)\n"
" -v show all command lines\n"
-" -q show inputs/outputs of target (query mode)\n"
-" -b browse dependency graph of target in a web browser\n"
+"\n"
+" -t TOOL run a subtool. tools are:\n"
+" 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"
);
}
@@ -110,16 +112,11 @@ int CmdBrowse(State* state, int argc, char* argv[]) {
int main(int argc, char** argv) {
BuildConfig config;
const char* input_file = "build.ninja";
- bool graph = false;
- bool query = false;
- bool browse = false;
+ string tool;
int opt;
- while ((opt = getopt_long(argc, argv, "bghi:nvq", options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "hi:nt:v", options, NULL)) != -1) {
switch (opt) {
- case 'g':
- graph = true;
- break;
case 'i':
input_file = optarg;
break;
@@ -129,11 +126,8 @@ int main(int argc, char** argv) {
case 'v':
config.verbosity = BuildConfig::VERBOSE;
break;
- case 'q':
- query = true;
- break;
- case 'b':
- browse = true;
+ case 't':
+ tool = optarg;
break;
case 'h':
default:
@@ -164,12 +158,15 @@ int main(int argc, char** argv) {
return 1;
}
- if (graph)
- return CmdGraph(&state, argc, argv);
- if (query)
- return CmdQuery(&state, argc, argv);
- if (browse)
- return CmdBrowse(&state, argc, argv);
+ if (!tool.empty()) {
+ if (tool == "graph")
+ return CmdGraph(&state, argc, argv);
+ if (tool == "query")
+ return CmdQuery(&state, argc, argv);
+ if (tool == "browse")
+ return CmdBrowse(&state, argc, argv);
+ fprintf(stderr, "unknown tool '%s'\n", tool.c_str());
+ }
BuildLog build_log;
build_log.SetConfig(&config);