diff options
author | Peter Wu <peter@lekensteyn.nl> | 2016-03-11 23:24:00 (GMT) |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2016-03-11 23:24:00 (GMT) |
commit | 048ad189e16917b26c370669c9b978d9fd23bae2 (patch) | |
tree | 03718671c2673f15e91b4e7f5aaf708807e7af8e /src/browse.cc | |
parent | f7491398a2e97c7c76d5a28cfb3b8ce1a0a1a580 (diff) | |
download | Ninja-048ad189e16917b26c370669c9b978d9fd23bae2.zip Ninja-048ad189e16917b26c370669c9b978d9fd23bae2.tar.gz Ninja-048ad189e16917b26c370669c9b978d9fd23bae2.tar.bz2 |
browse: support --port and --no-browser options
Add --port option to override the default port (8000).
Add --no-browser option to avoid opening a web browser (useful over
SSH).
Make the target name optional, using "all" if omitted.
Diffstat (limited to 'src/browse.cc')
-rw-r--r-- | src/browse.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/browse.cc b/src/browse.cc index 8673919..46434d7 100644 --- a/src/browse.cc +++ b/src/browse.cc @@ -17,11 +17,12 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <vector> #include "build/browse_py.h" void RunBrowsePython(State* state, const char* ninja_command, - const char* initial_target) { + int argc, char* argv[]) { // Fork off a Python process and have it run our code via its stdin. // (Actually the Python process becomes the parent.) int pipefd[2]; @@ -44,11 +45,16 @@ void RunBrowsePython(State* state, const char* ninja_command, break; } - // exec Python, telling it to run the program from stdin. - const char* command[] = { - NINJA_PYTHON, "-", ninja_command, initial_target, NULL - }; - execvp(command[0], (char**)command); + std::vector<const char *> command; + command.push_back(NINJA_PYTHON); + command.push_back("-"); + command.push_back("--ninja-command"); + command.push_back(ninja_command); + for (int i = 0; i < argc; i++) { + command.push_back(argv[i]); + } + command.push_back(NULL); + execvp(command[0], (char**)&command[0]); perror("ninja: execvp"); } while (false); _exit(1); |