|
|
@ -14,6 +14,7 @@ |
|
|
|
#include <nlohmann/json.hpp> |
|
|
|
#include <nlohmann/json.hpp> |
|
|
|
#include <fstream> |
|
|
|
#include <fstream> |
|
|
|
#include <future> |
|
|
|
#include <future> |
|
|
|
|
|
|
|
#include <mutex> |
|
|
|
|
|
|
|
|
|
|
|
using std::string; |
|
|
|
using std::string; |
|
|
|
using namespace fmt; |
|
|
|
using namespace fmt; |
|
|
@ -32,13 +33,15 @@ Builder::Builder(GUI &g, GameEngine &engine) |
|
|
|
config["build_cmd"].template get_to<string>(build_cmd); |
|
|
|
config["build_cmd"].template get_to<string>(build_cmd); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FILE *start_command(string &build_cmd) { |
|
|
|
FILE *Builder::start_command(string &build_cmd) { |
|
|
|
|
|
|
|
std::lock_guard<std::mutex> lock(fsm_mutex); |
|
|
|
FILE *build_out = popen(build_cmd.c_str(), "r"); |
|
|
|
FILE *build_out = popen(build_cmd.c_str(), "r"); |
|
|
|
dbc::check(build_out != nullptr, "Failed to run command."); |
|
|
|
dbc::check(build_out != nullptr, "Failed to run command."); |
|
|
|
return build_out; |
|
|
|
return build_out; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string read_line(FILE *build_out, bool &done_out) { |
|
|
|
string Builder::read_line(FILE *build_out, bool &done_out) { |
|
|
|
|
|
|
|
std::lock_guard<std::mutex> lock(fsm_mutex); |
|
|
|
char buffer[BUF_MAX]; |
|
|
|
char buffer[BUF_MAX]; |
|
|
|
char *res = fgets(buffer, BUF_MAX, build_out); |
|
|
|
char *res = fgets(buffer, BUF_MAX, build_out); |
|
|
|
done_out = res == nullptr; |
|
|
|
done_out = res == nullptr; |
|
|
|