Browse Source

fixed bug in compile

merge-requests/365/head
oyvang 11 years ago
parent
commit
51eda4318d
  1. 8
      juci/config.cc
  2. 6
      juci/config.json
  3. 10
      juci/terminal.cc
  4. 1
      juci/window.cc

8
juci/config.cc

@ -31,10 +31,14 @@ void MainConfig::GenerateSource() {
void MainConfig::GenerateTerminalCommands() { void MainConfig::GenerateTerminalCommands() {
boost::property_tree::ptree source_json = cfg_.get_child("project"); boost::property_tree::ptree source_json = cfg_.get_child("project");
boost::property_tree::ptree commands_json = source_json.get_child("compile_commands"); boost::property_tree::ptree compile_commands_json = source_json.get_child("compile_commands");
for (auto &i : commands_json) { boost::property_tree::ptree run_commands_json = source_json.get_child("run_commands");
for (auto &i : compile_commands_json) {
terminal_cfg_.InsertCompileCommand(i.second.get_value<std::string>()); terminal_cfg_.InsertCompileCommand(i.second.get_value<std::string>());
} }
for (auto &i : run_commands_json) {
terminal_cfg_.SetRunCommand(i.second.get_value<std::string>());
}
} }
void MainConfig::GenerateKeybindings() { void MainConfig::GenerateKeybindings() {

6
juci/config.json

@ -57,10 +57,12 @@
] ]
}, },
"project": { "project": {
"run_commands": [
"./.build/"
],
"compile_commands": [ "compile_commands": [
"rm -rf ./.build", "rm -rf ./.build",
"mkdir build", "mkdir ./.build",
"cmake -B./.build -H.", "cmake -B./.build -H.",
"cd ./.build/; make" "cd ./.build/; make"
] ]

10
juci/terminal.cc

@ -6,7 +6,8 @@
Terminal::Config::Config() { Terminal::Config::Config() {
} }
Terminal::Config::Config(Terminal::Config& original) { Terminal::Config::Config(Terminal::Config& original) :
run_command_(original.run_command_){
for (auto it = 0; it<original.compile_commands().size(); ++it) { for (auto it = 0; it<original.compile_commands().size(); ++it) {
InsertCompileCommand(original.compile_commands().at(it)); InsertCompileCommand(original.compile_commands().at(it));
} }
@ -16,6 +17,10 @@ void Terminal::Config::InsertCompileCommand(std::string command){
compile_commands_.push_back(command); compile_commands_.push_back(command);
} }
void Terminal::Config::SetRunCommand(std::string command){
run_command_ = 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);
@ -55,7 +60,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("cd"+config().run_command() + "; ./"+executable, "r"); ExecuteCommand("cd "+config().run_command() + "; ./"+executable, "r");
PrintMessage("\n"); PrintMessage("\n");
} }
@ -80,6 +85,7 @@ void Terminal::Controller::ExecuteCommand(std::string command, std::string mode)
command = folder_command_+command; command = folder_command_+command;
DEBUG("Terminal: PrintMessage: Running command"); DEBUG("Terminal: PrintMessage: Running command");
FILE* p = NULL; FILE* p = NULL;
std::cout << command << std::endl;
p = popen(command.c_str(), mode.c_str()); p = popen(command.c_str(), mode.c_str());
std::cout << "KJØRTE FINT!" << std::endl; std::cout << "KJØRTE FINT!" << std::endl;
if (p == NULL) { if (p == NULL) {

1
juci/window.cc

@ -122,7 +122,6 @@ void Window::OnWindowHide() {
void Window::OnFileOpenFolder() { void Window::OnFileOpenFolder() {
Gtk::FileChooserDialog dialog("Please choose a folder", Gtk::FileChooserDialog dialog("Please choose a folder",
Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
dialog.set_transient_for(*this); dialog.set_transient_for(*this);
//Add response buttons the the dialog: //Add response buttons the the dialog:
dialog.add_button("_Cancel", Gtk::RESPONSE_CANCEL); dialog.add_button("_Cancel", Gtk::RESPONSE_CANCEL);

Loading…
Cancel
Save