diff --git a/src/config.cc b/src/config.cc index b3aa217..6c469c0 100644 --- a/src/config.cc +++ b/src/config.cc @@ -97,11 +97,15 @@ void Config::retrieve_config() { terminal.history_size=cfg.get("terminal.history_size"); terminal.font=cfg.get("terminal.font"); + terminal.clang_format_command="clang-format"; + terminal.lldb_command="lldb"; #ifdef __linux if(terminal.clang_format_command=="clang-format" && !boost::filesystem::exists("/usr/bin/clang-format") && !boost::filesystem::exists("/usr/local/bin/clang-format")) { - if(boost::filesystem::exists("/usr/bin/clang-format-3.8")) + if(boost::filesystem::exists("/usr/bin/clang-format-3.9")) + terminal.clang_format_command="/usr/bin/clang-format-3.9"; + else if(boost::filesystem::exists("/usr/bin/clang-format-3.8")) terminal.clang_format_command="/usr/bin/clang-format-3.8"; else if(boost::filesystem::exists("/usr/bin/clang-format-3.7")) terminal.clang_format_command="/usr/bin/clang-format-3.7"; @@ -110,6 +114,19 @@ void Config::retrieve_config() { else if(boost::filesystem::exists("/usr/bin/clang-format-3.5")) terminal.clang_format_command="/usr/bin/clang-format-3.5"; } + if(terminal.lldb_command=="lldb" && + !boost::filesystem::exists("/usr/bin/lldb") && !boost::filesystem::exists("/usr/local/bin/lldb")) { + if(boost::filesystem::exists("/usr/bin/lldb-3.9")) + terminal.lldb_command="/usr/bin/lldb-3.9"; + else if(boost::filesystem::exists("/usr/bin/lldb-3.8")) + terminal.lldb_command="/usr/bin/lldb-3.8"; + else if(boost::filesystem::exists("/usr/bin/lldb-3.7")) + terminal.lldb_command="/usr/bin/lldb-3.7"; + else if(boost::filesystem::exists("/usr/bin/lldb-3.6")) + terminal.lldb_command="/usr/bin/lldb-3.6"; + else if(boost::filesystem::exists("/usr/bin/lldb-3.5")) + terminal.lldb_command="/usr/bin/lldb-3.5"; + } #endif } diff --git a/src/config.h b/src/config.h index 60d318e..1c1ba0a 100644 --- a/src/config.h +++ b/src/config.h @@ -25,6 +25,7 @@ public: class Terminal { public: std::string clang_format_command; + std::string lldb_command; int history_size; std::string font; diff --git a/src/debug_clang.cc b/src/debug_clang.cc index 4539cf7..7580ebb 100644 --- a/src/debug_clang.cc +++ b/src/debug_clang.cc @@ -8,6 +8,7 @@ #include "terminal.h" #include "filesystem.h" #include "process.hpp" +#include "config.h" #include #include @@ -486,13 +487,16 @@ void Debug::Clang::write(const std::string &buffer) { std::vector Debug::Clang::get_platform_list() { //Could not find a way to do this through liblldb std::stringstream stream; - Process process("lldb", "", [&stream](const char *bytes, size_t n) { + Process process(Config::get().terminal.lldb_command, "", [&stream](const char *bytes, size_t n) { stream.write(bytes, n); }, [](const char *bytes, size_t n) {}, true); process.write("platform list"); process.close_stdin(); - if(process.get_exit_status()!=0) + auto exit_status=process.get_exit_status(); + if(exit_status!=0) { + Terminal::get().print("Error (debug): "+Config::get().terminal.lldb_command+" returned "+std::to_string(exit_status)+'\n'); return {}; + } std::vector platform_list; std::string line; while(std::getline(stream, line)) { diff --git a/src/project.cc b/src/project.cc index c0890e9..e3d06fb 100644 --- a/src/project.cc +++ b/src/project.cc @@ -18,7 +18,9 @@ std::atomic Project::compiling(false); std::atomic Project::debugging(false); std::pair > Project::debug_stop; std::unique_ptr Project::current; +#ifdef JUCI_ENABLE_DEBUG std::unordered_map Project::Clang::debug_options_popovers; +#endif Gtk::Label &Project::debug_status_label() { static Gtk::Label label; @@ -154,6 +156,7 @@ void Project::Base::debug_start() { Info::get().print("Could not find a supported project"); } +#ifdef JUCI_ENABLE_DEBUG Project::Clang::DebugOptionsPopover::DebugOptionsPopover() : Gtk::Popover() { auto platform_list=Debug::Clang::get_platform_list(); for(auto &platform: platform_list) @@ -181,6 +184,7 @@ Project::Clang::DebugOptionsPopover::DebugOptionsPopover() : Gtk::Popover() { show_all(); set_visible(false); } +#endif std::pair Project::Clang::get_run_arguments() { auto build_path=build->get_default_path(); diff --git a/src/project.h b/src/project.h index 65081bc..ea7c411 100644 --- a/src/project.h +++ b/src/project.h @@ -57,6 +57,7 @@ namespace Project { }; class Clang : public Base { +#ifdef JUCI_ENABLE_DEBUG class DebugOptionsPopover : public Gtk::Popover { public: DebugOptionsPopover(); @@ -69,6 +70,7 @@ namespace Project { Gtk::Label not_yet_implemented_label; }; static std::unordered_map debug_options_popovers; +#endif Dispatcher dispatcher; public: @@ -80,7 +82,7 @@ namespace Project { void compile_and_run() override; std::mutex debug_start_mutex; - #ifdef JUCI_ENABLE_DEBUG +#ifdef JUCI_ENABLE_DEBUG std::pair debug_get_run_arguments() override; Gtk::Popover *debug_get_options_popover() override; void debug_start() override; @@ -98,7 +100,7 @@ namespace Project { bool debug_is_running() override; void debug_write(const std::string &buffer) override; void debug_cancel() override; - #endif +#endif }; class Markdown : public Base { diff --git a/tests/stubs/config.cc b/tests/stubs/config.cc index a84fe7a..12fd49c 100644 --- a/tests/stubs/config.cc +++ b/tests/stubs/config.cc @@ -1,3 +1,20 @@ #include "config.h" -Config::Config() {} +Config::Config() { + terminal.lldb_command="lldb"; +#ifdef __linux + if(terminal.lldb_command=="lldb" && + !boost::filesystem::exists("/usr/bin/lldb") && !boost::filesystem::exists("/usr/local/bin/lldb")) { + if(boost::filesystem::exists("/usr/bin/lldb-3.9")) + terminal.lldb_command="/usr/bin/lldb-3.9"; + else if(boost::filesystem::exists("/usr/bin/lldb-3.8")) + terminal.lldb_command="/usr/bin/lldb-3.8"; + else if(boost::filesystem::exists("/usr/bin/lldb-3.7")) + terminal.lldb_command="/usr/bin/lldb-3.7"; + else if(boost::filesystem::exists("/usr/bin/lldb-3.6")) + terminal.lldb_command="/usr/bin/lldb-3.6"; + else if(boost::filesystem::exists("/usr/bin/lldb-3.5")) + terminal.lldb_command="/usr/bin/lldb-3.5"; + } +#endif +}