23 #include "build/browse_py.h" 26 const char* input_file,
int argc,
char* argv[]) {
30 if (pipe(pipefd) < 0) {
31 perror(
"ninja: pipe");
37 perror(
"ninja: fork");
44 if (dup2(pipefd[0], 0) < 0) {
45 perror(
"ninja: dup2");
49 std::vector<const char *> command;
50 command.push_back(NINJA_PYTHON);
51 command.push_back(
"-");
52 command.push_back(
"--ninja-command");
53 command.push_back(ninja_command);
54 command.push_back(
"-f");
55 command.push_back(input_file);
56 for (
int i = 0; i < argc; i++) {
57 command.push_back(argv[i]);
59 command.push_back(NULL);
60 execvp(command[0], (
char**)&command[0]);
61 if (errno == ENOENT) {
62 printf(
"ninja: %s is required for the browse tool\n", NINJA_PYTHON);
64 perror(
"ninja: execvp");
72 ssize_t len = write(pipefd[1], kBrowsePy,
sizeof(kBrowsePy));
73 if (len < (ssize_t)
sizeof(kBrowsePy))
74 perror(
"ninja: write");
void RunBrowsePython(State *state, const char *ninja_command, const char *input_file, int argc, char *argv[])
Run in "browse" mode, which execs a Python webserver.
Global state (file status) for a single run.