summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/browse.cc5
-rw-r--r--src/browse.h6
-rwxr-xr-xsrc/browse.py4
-rw-r--r--src/ninja.cc8
4 files changed, 14 insertions, 9 deletions
diff --git a/src/browse.cc b/src/browse.cc
index f65e537..d51bb44 100644
--- a/src/browse.cc
+++ b/src/browse.cc
@@ -20,7 +20,8 @@
#include "../build/browse_py.h"
#include "ninja.h"
-void RunBrowsePython(State* state, const char* ninja_command) {
+void RunBrowsePython(State* state, const char* ninja_command,
+ const char* initial_target) {
// Fork off a Python process and have it run our code via its stdin.
// (Actually the Python process becomes the parent.)
int pipefd[2];
@@ -45,7 +46,7 @@ void RunBrowsePython(State* state, const char* ninja_command) {
// exec Python, telling it to run the program from stdin.
const char* command[] = {
- "python", "-", ninja_command, NULL
+ "python", "-", ninja_command, initial_target, NULL
};
execvp(command[0], (char**)command);
perror("ninja: execvp");
diff --git a/src/browse.h b/src/browse.h
index d46cbf0..263641f 100644
--- a/src/browse.h
+++ b/src/browse.h
@@ -18,8 +18,10 @@
struct State;
/// Run in "browse" mode, which execs a Python webserver.
-/// |command| is the command used to invoke ninja.
+/// \a ninja_command is the command used to invoke ninja.
+/// \a initial_target is the first target to load.
/// This function does not return if it runs successfully.
-void RunBrowsePython(State* state, const char* ninja_command);
+void RunBrowsePython(State* state, const char* ninja_command,
+ const char* initial_target);
#endif // NINJA_BROWSE_H_
diff --git a/src/browse.py b/src/browse.py
index 1860df3..c671535 100755
--- a/src/browse.py
+++ b/src/browse.py
@@ -99,7 +99,7 @@ tt {
print '</td></tr></table>'
def ninja_dump(target):
- proc = subprocess.Popen(['./ninja', '-t', 'query', target],
+ proc = subprocess.Popen([sys.argv[1], '-t', 'query', target],
stdout=subprocess.PIPE)
return proc.communicate()[0]
@@ -110,7 +110,7 @@ class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
if target == '':
self.send_response(302)
- self.send_header('Location', '?' + sys.argv[1])
+ self.send_header('Location', '?' + sys.argv[2])
self.end_headers()
return
diff --git a/src/ninja.cc b/src/ninja.cc
index 8b4206c..ee76fb3 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -182,13 +182,14 @@ int CmdQuery(State* state, int argc, char* argv[]) {
return 0;
}
-int CmdBrowse(State* state, int argc, char* argv[]) {
+int CmdBrowse(State* state, const char* ninja_command,
+ int argc, char* argv[]) {
#ifndef WIN32
if (argc < 1) {
Error("expected a target to browse");
return 1;
}
- RunBrowsePython(state, argv[0]);
+ RunBrowsePython(state, ninja_command, argv[0]);
#else
Error("browse mode not yet supported on Windows");
#endif
@@ -343,6 +344,7 @@ int CmdClean(State* state,
} // anonymous namespace
int main(int argc, char** argv) {
+ const char* ninja_command = argv[0];
BuildConfig config;
const char* input_file = "build.ninja";
const char* working_dir = 0;
@@ -411,7 +413,7 @@ int main(int argc, char** argv) {
if (tool == "query")
return CmdQuery(&state, argc, argv);
if (tool == "browse")
- return CmdBrowse(&state, argc, argv);
+ return CmdBrowse(&state, ninja_command, argc, argv);
if (tool == "targets")
return CmdTargets(&state, argc, argv);
if (tool == "rules")