diff options
Diffstat (limited to 'backend/ninja/Ninja.cpp')
-rw-r--r-- | backend/ninja/Ninja.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 683fb67..73a6dc3 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -42,7 +42,7 @@ namespace backend int exitCode; }; - Result<ExecResult> exec(const char *cmd) + Result<ExecResult> exec(const char *cmd, bool print = false) { char buffer[128]; string result; @@ -53,7 +53,11 @@ namespace backend while(!feof(pipe)) { if(fgets(buffer, 128, pipe)) + { result += buffer; + if(print) + printf("%s", buffer); + } } ExecResult execResult; @@ -258,4 +262,16 @@ namespace backend printf("Created ninja build file: %s\n", savePath); return Result<bool>::Ok(true); } + + Result<bool> Ninja::build(const char *buildFilePath) + { + string command = "ninja -C '"; + command += buildFilePath; + command += "'"; + Result<ExecResult> execResult = exec(command.c_str(), true); + if(execResult.isOk()) + return Result<bool>::Ok(true); + else + return Result<bool>::Err(execResult.getErrMsg()); + } }
\ No newline at end of file |