Browse Source

Moved project configs to Config::project

merge-requests/365/head
eidheim 10 years ago
parent
commit
1f6661aa56
  1. 10
      src/cmake.cc
  2. 14
      src/config.cc
  3. 11
      src/config.h
  4. 6
      src/project.cc
  5. 6
      src/window.cc

10
src/cmake.cc

@ -36,7 +36,7 @@ CMake::CMake(const boost::filesystem::path &path) {
}
boost::filesystem::path CMake::get_default_build_path(const boost::filesystem::path &project_path) {
boost::filesystem::path default_build_path=Config::get().terminal.default_build_path;
boost::filesystem::path default_build_path=Config::get().project.default_build_path;
const std::string path_variable_project_directory_name="<project_directory_name>";
size_t pos=0;
@ -56,7 +56,7 @@ boost::filesystem::path CMake::get_default_build_path(const boost::filesystem::p
}
boost::filesystem::path CMake::get_debug_build_path(const boost::filesystem::path &project_path) {
boost::filesystem::path debug_build_path=Config::get().terminal.debug_build_path;
boost::filesystem::path debug_build_path=Config::get().project.debug_build_path;
const std::string path_variable_project_directory_name="<project_directory_name>";
size_t pos=0;
@ -72,7 +72,7 @@ boost::filesystem::path CMake::get_debug_build_path(const boost::filesystem::pat
const std::string path_variable_default_build_path="<default_build_path>";
pos=0;
debug_build_path_string=debug_build_path.string();
auto default_build_path=Config::get().terminal.default_build_path;
auto default_build_path=Config::get().project.default_build_path;
while((pos=debug_build_path_string.find(path_variable_default_build_path, pos))!=std::string::npos) {
debug_build_path_string.replace(pos, path_variable_default_build_path.size(), default_build_path);
pos+=default_build_path.size();
@ -112,7 +112,7 @@ bool CMake::create_default_build(const boost::filesystem::path &project_path, bo
auto compile_commands_path=default_build_path/"compile_commands.json";
Dialog::Message message("Creating/updating default build");
auto exit_status=Terminal::get().process(Config::get().terminal.cmake_command+" "+
auto exit_status=Terminal::get().process(Config::get().project.cmake_command+" "+
filesystem::escape_argument(project_path)+" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON", default_build_path);
message.hide();
if(exit_status==EXIT_SUCCESS) {
@ -162,7 +162,7 @@ bool CMake::create_debug_build(const boost::filesystem::path &project_path) {
std::unique_ptr<Dialog::Message> message;
message=std::unique_ptr<Dialog::Message>(new Dialog::Message("Creating/updating debug build"));
auto exit_status=Terminal::get().process(Config::get().terminal.cmake_command+" "+
auto exit_status=Terminal::get().process(Config::get().project.cmake_command+" "+
filesystem::escape_argument(project_path)+" -DCMAKE_BUILD_TYPE=Debug", debug_build_path);
if(message)
message->hide();

14
src/config.cc

@ -84,15 +84,15 @@ void Config::retrieve_config() {
window.theme_variant=cfg.get<std::string>("gtk_theme.variant");
window.version = cfg.get<std::string>("version");
window.default_size = {cfg.get<int>("default_window_size.width"), cfg.get<int>("default_window_size.height")};
window.save_on_compile_or_run=cfg.get<bool>("project.save_on_compile_or_run");
terminal.default_build_path=cfg.get<std::string>("project.default_build_path");
terminal.debug_build_path=cfg.get<std::string>("project.debug_build_path");
terminal.make_command=cfg.get<std::string>("project.make_command");
terminal.cmake_command=cfg.get<std::string>("project.cmake_command");
terminal.history_size=cfg.get<int>("terminal_history_size");
project.save_on_compile_or_run=cfg.get<bool>("project.save_on_compile_or_run");
project.default_build_path=cfg.get<std::string>("project.default_build_path");
project.debug_build_path=cfg.get<std::string>("project.debug_build_path");
project.make_command=cfg.get<std::string>("project.make_command");
project.cmake_command=cfg.get<std::string>("project.cmake_command");
terminal.clang_format_command=cfg.get<std::string>("project.clang_format_command", "clang-format");
terminal.history_size=cfg.get<int>("terminal_history_size");
terminal.clang_format_command="clang-format";
#ifdef __linux
if(terminal.clang_format_command=="clang-format" &&
!boost::filesystem::exists("/usr/bin/clang-format") && !boost::filesystem::exists("/usr/local/bin/clang-format")) {

11
src/config.h

@ -20,17 +20,21 @@ public:
std::string theme_variant;
std::string version;
std::pair<int, int> default_size;
bool save_on_compile_or_run;
};
class Terminal {
public:
std::string clang_format_command;
int history_size;
};
class Project {
public:
std::string default_build_path;
std::string debug_build_path;
std::string cmake_command;
std::string make_command;
std::string clang_format_command;
int history_size;
bool save_on_compile_or_run;
};
class Source {
@ -74,6 +78,7 @@ public:
Menu menu;
Window window;
Terminal terminal;
Project project;
Source source;
const boost::filesystem::path& juci_home_path() const { return home; }

6
src/project.cc

@ -141,7 +141,7 @@ void Project::Clang::compile() {
return;
compiling=true;
Terminal::get().print("Compiling project "+cmake->project_path.string()+"\n");
Terminal::get().async_process(Config::get().terminal.make_command, default_build_path, [this](int exit_status) {
Terminal::get().async_process(Config::get().project.make_command, default_build_path, [this](int exit_status) {
compiling=false;
});
}
@ -178,7 +178,7 @@ void Project::Clang::compile_and_run() {
compiling=true;
Terminal::get().print("Compiling and running "+arguments+"\n");
Terminal::get().async_process(Config::get().terminal.make_command, default_build_path, [this, arguments, default_build_path](int exit_status){
Terminal::get().async_process(Config::get().project.make_command, default_build_path, [this, arguments, default_build_path](int exit_status){
compiling=false;
if(exit_status==EXIT_SUCCESS) {
Terminal::get().async_process(arguments, default_build_path, [this, arguments](int exit_status){
@ -266,7 +266,7 @@ void Project::Clang::debug_start() {
debugging=true;
Terminal::get().print("Compiling and debugging "+run_arguments+"\n");
Terminal::get().async_process(Config::get().terminal.make_command, debug_build_path, [this, breakpoints, run_arguments, debug_build_path](int exit_status){
Terminal::get().async_process(Config::get().project.make_command, debug_build_path, [this, breakpoints, run_arguments, debug_build_path](int exit_status){
if(exit_status!=EXIT_SUCCESS)
debugging=false;
else {

6
src/window.cc

@ -534,7 +534,7 @@ void Window::set_menu_actions() {
if(Project::compiling || Project::debugging)
return;
if(Config::get().window.save_on_compile_or_run)
if(Config::get().project.save_on_compile_or_run)
notebook.save_project_files();
project_language=Project::get_language();
@ -544,7 +544,7 @@ void Window::set_menu_actions() {
if(Project::compiling || Project::debugging)
return;
if(Config::get().window.save_on_compile_or_run)
if(Config::get().project.save_on_compile_or_run)
notebook.save_project_files();
project_language=Project::get_language();
@ -619,7 +619,7 @@ void Window::set_menu_actions() {
return;
}
if(Config::get().window.save_on_compile_or_run)
if(Config::get().project.save_on_compile_or_run)
notebook.save_project_files();
project_language=Project::get_language();

Loading…
Cancel
Save