23 #include "build/browse_py.h"
28 const char* input_file,
int argc,
char* argv[]) {
32 if (pipe(pipefd) < 0) {
33 perror(
"ninja: pipe");
39 perror(
"ninja: fork");
46 if (dup2(pipefd[0], 0) < 0) {
47 perror(
"ninja: dup2");
51 std::vector<const char *> command;
52 command.push_back(NINJA_PYTHON);
53 command.push_back(
"-");
54 command.push_back(
"--ninja-command");
55 command.push_back(ninja_command);
56 command.push_back(
"-f");
57 command.push_back(input_file);
58 for (
int i = 0; i < argc; i++) {
59 command.push_back(argv[i]);
61 command.push_back(NULL);
62 execvp(command[0],
const_cast<char**
>(&command[0]));
63 if (errno == ENOENT) {
64 printf(
"ninja: %s is required for the browse tool\n", NINJA_PYTHON);
66 perror(
"ninja: execvp");
78 auto kBrowsePyLength =
sizeof(kBrowsePy) - 1;
79 ssize_t len = write(pipefd[1], kBrowsePy, kBrowsePyLength);
80 if (len < (ssize_t)kBrowsePyLength)
81 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.