aboutsummaryrefslogtreecommitdiff
path: root/backend/ninja/Ninja.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2017-12-09 17:27:08 +0100
committerdec05eba <dec05eba@protonmail.com>2017-12-09 17:28:43 +0100
commit2ed7d0b09caa872e44e2eb09b09b2387e93f9b34 (patch)
tree2abb2aeab1cdb679a79f82ef686b0ecbba1ae281 /backend/ninja/Ninja.cpp
parente7384a7672e4449bc194ca3ec66cdd4fcc63801e (diff)
Add project compilation after ninja file is created
Diffstat (limited to 'backend/ninja/Ninja.cpp')
-rw-r--r--backend/ninja/Ninja.cpp18
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