|
|
|
@ -4,6 +4,18 @@ |
|
|
|
#include "logging.h" |
|
|
|
#include "logging.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Terminal::Config::Config() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Terminal::Config::Config(Terminal::Config& original) { |
|
|
|
|
|
|
|
for (auto it = 0; original.compile_commands().size(); ++it) { |
|
|
|
|
|
|
|
InsertCompileCommand(original.compile_commands().at(it)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Terminal::Config::InsertCompileCommand(std::string command){ |
|
|
|
|
|
|
|
compile_commands_.push_back(command); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Terminal::View::View(){ |
|
|
|
Terminal::View::View(){ |
|
|
|
scrolledwindow_.add(textview_); |
|
|
|
scrolledwindow_.add(textview_); |
|
|
|
scrolledwindow_.set_size_request(-1,150); |
|
|
|
scrolledwindow_.set_size_request(-1,150); |
|
|
|
@ -28,11 +40,18 @@ void Terminal::Controller::Compile(){ |
|
|
|
INFO("Terminal: Compile"); |
|
|
|
INFO("Terminal: Compile"); |
|
|
|
Terminal().get_buffer()->set_text(""); |
|
|
|
Terminal().get_buffer()->set_text(""); |
|
|
|
DEBUG("Terminal: Compile: running cmake command"); |
|
|
|
DEBUG("Terminal: Compile: running cmake command"); |
|
|
|
ExecuteCommand("cmake .", "r"); |
|
|
|
std::vector<std::string> commands = config().compile_commands(); |
|
|
|
if (ExistInConsole(cmake_sucsess)){ |
|
|
|
for (auto it = 0; it < commands.size(); ++it) { |
|
|
|
DEBUG("Terminal: Compile: running make command"); |
|
|
|
ExecuteCommand(commands.at(it), "r"); |
|
|
|
ExecuteCommand("make", "r"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// ExecuteCommand("rm -rf ./.build", "r");
|
|
|
|
|
|
|
|
// ExecuteCommand("mkdir ./.build", "r");
|
|
|
|
|
|
|
|
// ExecuteCommand("cmake -B./build -H.", "r");
|
|
|
|
|
|
|
|
// if (ExistInConsole(cmake_sucsess)){
|
|
|
|
|
|
|
|
// DEBUG("Terminal: Compile: running make command");
|
|
|
|
|
|
|
|
// ExecuteCommand("cd ./.build/; make", "r");
|
|
|
|
|
|
|
|
// }
|
|
|
|
PrintMessage("\n"); |
|
|
|
PrintMessage("\n"); |
|
|
|
DEBUG("Terminal: Compile: compile done"); |
|
|
|
DEBUG("Terminal: Compile: compile done"); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -42,7 +61,7 @@ void Terminal::Controller::Run(std::string executable) { |
|
|
|
PrintMessage("juCi++ execute: " + executable + "\n"); |
|
|
|
PrintMessage("juCi++ execute: " + executable + "\n"); |
|
|
|
DEBUG("Terminal: Compile: running run command: "); |
|
|
|
DEBUG("Terminal: Compile: running run command: "); |
|
|
|
DEBUG_VAR(executable); |
|
|
|
DEBUG_VAR(executable); |
|
|
|
ExecuteCommand("./"+executable, "r"); |
|
|
|
ExecuteCommand("cd ./build/; ./"+executable, "r"); |
|
|
|
PrintMessage("\n"); |
|
|
|
PrintMessage("\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -66,16 +85,18 @@ void Terminal::Controller::ExecuteCommand(std::string command, std::string mode) |
|
|
|
INFO("Terminal: ExecuteCommand"); |
|
|
|
INFO("Terminal: ExecuteCommand"); |
|
|
|
command = folder_command_+command; |
|
|
|
command = folder_command_+command; |
|
|
|
DEBUG("Terminal: PrintMessage: Running command"); |
|
|
|
DEBUG("Terminal: PrintMessage: Running command"); |
|
|
|
DEBUG_VAR(command); |
|
|
|
FILE* p = NULL; |
|
|
|
FILE* p = popen(command.c_str(), mode.c_str()); |
|
|
|
p = popen(command.c_str(), mode.c_str()); |
|
|
|
|
|
|
|
std::cout << "KJØRTE FINT!" << std::endl; |
|
|
|
if (p == NULL) { |
|
|
|
if (p == NULL) { |
|
|
|
PrintMessage("juCi++ ERROR: Failed to run command" + command + "\n"); |
|
|
|
PrintMessage("juCi++ ERROR: Failed to run command" + command + "\n"); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
|
|
|
|
std::cout << "SKRIVER UT KOMMANDO RESULAT" << std::endl; |
|
|
|
char buffer[1028]; |
|
|
|
char buffer[1028]; |
|
|
|
while (fgets(buffer, 1028, p) != NULL) { |
|
|
|
while (fgets(buffer, 1028, p) != NULL) { |
|
|
|
PrintMessage(buffer); |
|
|
|
PrintMessage(buffer); |
|
|
|
} |
|
|
|
} |
|
|
|
pclose(p);
|
|
|
|
pclose(p);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|