Pass the path to the ninja binary in to the Python script.
Confusingly, in some places the variables were already in place
to do this, but they were accidentally used for something else
entirely.
#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];
// 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");
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_
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]
if target == '':
self.send_response(302)
- self.send_header('Location', '?' + sys.argv[1])
+ self.send_header('Location', '?' + sys.argv[2])
self.end_headers()
return
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
} // 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;
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")