diff options
-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); |