diff options
author | Evan Martin <martine@danga.com> | 2011-01-28 17:50:58 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-01-28 17:50:58 (GMT) |
commit | f7a4d42b6d8753d6d141020726591bddfbcd7855 (patch) | |
tree | af9d83d838f210a3f479ce54dec482426396f0ab | |
parent | 4e646c299b555a83776aaa6cd265a07f6aedce48 (diff) | |
download | Ninja-f7a4d42b6d8753d6d141020726591bddfbcd7855.zip Ninja-f7a4d42b6d8753d6d141020726591bddfbcd7855.tar.gz Ninja-f7a4d42b6d8753d6d141020726591bddfbcd7855.tar.bz2 |
move tools into a flag
-rw-r--r-- | build.ninja | 2 | ||||
-rwxr-xr-x | src/browse.py | 3 | ||||
-rw-r--r-- | src/ninja.cc | 39 |
3 files changed, 21 insertions, 23 deletions
diff --git a/build.ninja b/build.ninja index 2ab2211..a444264 100644 --- a/build.ninja +++ b/build.ninja @@ -59,7 +59,7 @@ build ninja_test: link $builddir/build_test.o $builddir/build_log_test.o \ # Generate a graph using the -g flag. rule gendot - command = ./ninja -g all > $out + command = ./ninja -t graph all > $out rule gengraph command = dot -Tpng $in > $out diff --git a/src/browse.py b/src/browse.py index d326af3..dd7b5dc 100755 --- a/src/browse.py +++ b/src/browse.py @@ -83,7 +83,8 @@ tt { print '</td></tr></table>' def ninja_dump(target): - proc = subprocess.Popen(['./ninja', '-q', target], stdout=subprocess.PIPE) + proc = subprocess.Popen(['./ninja', '-t', 'query', target], + stdout=subprocess.PIPE) return proc.communicate()[0] class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): 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); |