Browse Source

Cross compiling: platform spesific fixes

merge-requests/365/head
eidheim 10 years ago
parent
commit
eba80e9a79
  1. 19
      src/config.cc
  2. 1
      src/config.h
  3. 8
      src/debug_clang.cc
  4. 4
      src/project.cc
  5. 6
      src/project.h
  6. 19
      tests/stubs/config.cc

19
src/config.cc

@ -97,11 +97,15 @@ void Config::retrieve_config() {
terminal.history_size=cfg.get<int>("terminal.history_size"); terminal.history_size=cfg.get<int>("terminal.history_size");
terminal.font=cfg.get<std::string>("terminal.font"); terminal.font=cfg.get<std::string>("terminal.font");
terminal.clang_format_command="clang-format"; terminal.clang_format_command="clang-format";
terminal.lldb_command="lldb";
#ifdef __linux #ifdef __linux
if(terminal.clang_format_command=="clang-format" && if(terminal.clang_format_command=="clang-format" &&
!boost::filesystem::exists("/usr/bin/clang-format") && !boost::filesystem::exists("/usr/local/bin/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"; terminal.clang_format_command="/usr/bin/clang-format-3.8";
else if(boost::filesystem::exists("/usr/bin/clang-format-3.7")) else if(boost::filesystem::exists("/usr/bin/clang-format-3.7"))
terminal.clang_format_command="/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")) else if(boost::filesystem::exists("/usr/bin/clang-format-3.5"))
terminal.clang_format_command="/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 #endif
} }

1
src/config.h

@ -25,6 +25,7 @@ public:
class Terminal { class Terminal {
public: public:
std::string clang_format_command; std::string clang_format_command;
std::string lldb_command;
int history_size; int history_size;
std::string font; std::string font;

8
src/debug_clang.cc

@ -8,6 +8,7 @@
#include "terminal.h" #include "terminal.h"
#include "filesystem.h" #include "filesystem.h"
#include "process.hpp" #include "process.hpp"
#include "config.h"
#include <lldb/API/SBTarget.h> #include <lldb/API/SBTarget.h>
#include <lldb/API/SBProcess.h> #include <lldb/API/SBProcess.h>
@ -486,13 +487,16 @@ void Debug::Clang::write(const std::string &buffer) {
std::vector<std::string> Debug::Clang::get_platform_list() { std::vector<std::string> Debug::Clang::get_platform_list() {
//Could not find a way to do this through liblldb //Could not find a way to do this through liblldb
std::stringstream stream; 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); stream.write(bytes, n);
}, [](const char *bytes, size_t n) {}, true); }, [](const char *bytes, size_t n) {}, true);
process.write("platform list"); process.write("platform list");
process.close_stdin(); 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 {}; return {};
}
std::vector<std::string> platform_list; std::vector<std::string> platform_list;
std::string line; std::string line;
while(std::getline(stream, line)) { while(std::getline(stream, line)) {

4
src/project.cc

@ -18,7 +18,9 @@ std::atomic<bool> Project::compiling(false);
std::atomic<bool> Project::debugging(false); std::atomic<bool> Project::debugging(false);
std::pair<boost::filesystem::path, std::pair<int, int> > Project::debug_stop; std::pair<boost::filesystem::path, std::pair<int, int> > Project::debug_stop;
std::unique_ptr<Project::Base> Project::current; std::unique_ptr<Project::Base> Project::current;
#ifdef JUCI_ENABLE_DEBUG
std::unordered_map<std::string, Project::Clang::DebugOptionsPopover> Project::Clang::debug_options_popovers; std::unordered_map<std::string, Project::Clang::DebugOptionsPopover> Project::Clang::debug_options_popovers;
#endif
Gtk::Label &Project::debug_status_label() { Gtk::Label &Project::debug_status_label() {
static Gtk::Label label; static Gtk::Label label;
@ -154,6 +156,7 @@ void Project::Base::debug_start() {
Info::get().print("Could not find a supported project"); Info::get().print("Could not find a supported project");
} }
#ifdef JUCI_ENABLE_DEBUG
Project::Clang::DebugOptionsPopover::DebugOptionsPopover() : Gtk::Popover() { Project::Clang::DebugOptionsPopover::DebugOptionsPopover() : Gtk::Popover() {
auto platform_list=Debug::Clang::get_platform_list(); auto platform_list=Debug::Clang::get_platform_list();
for(auto &platform: platform_list) for(auto &platform: platform_list)
@ -181,6 +184,7 @@ Project::Clang::DebugOptionsPopover::DebugOptionsPopover() : Gtk::Popover() {
show_all(); show_all();
set_visible(false); set_visible(false);
} }
#endif
std::pair<std::string, std::string> Project::Clang::get_run_arguments() { std::pair<std::string, std::string> Project::Clang::get_run_arguments() {
auto build_path=build->get_default_path(); auto build_path=build->get_default_path();

6
src/project.h

@ -57,6 +57,7 @@ namespace Project {
}; };
class Clang : public Base { class Clang : public Base {
#ifdef JUCI_ENABLE_DEBUG
class DebugOptionsPopover : public Gtk::Popover { class DebugOptionsPopover : public Gtk::Popover {
public: public:
DebugOptionsPopover(); DebugOptionsPopover();
@ -69,6 +70,7 @@ namespace Project {
Gtk::Label not_yet_implemented_label; Gtk::Label not_yet_implemented_label;
}; };
static std::unordered_map<std::string, DebugOptionsPopover> debug_options_popovers; static std::unordered_map<std::string, DebugOptionsPopover> debug_options_popovers;
#endif
Dispatcher dispatcher; Dispatcher dispatcher;
public: public:
@ -80,7 +82,7 @@ namespace Project {
void compile_and_run() override; void compile_and_run() override;
std::mutex debug_start_mutex; std::mutex debug_start_mutex;
#ifdef JUCI_ENABLE_DEBUG #ifdef JUCI_ENABLE_DEBUG
std::pair<std::string, std::string> debug_get_run_arguments() override; std::pair<std::string, std::string> debug_get_run_arguments() override;
Gtk::Popover *debug_get_options_popover() override; Gtk::Popover *debug_get_options_popover() override;
void debug_start() override; void debug_start() override;
@ -98,7 +100,7 @@ namespace Project {
bool debug_is_running() override; bool debug_is_running() override;
void debug_write(const std::string &buffer) override; void debug_write(const std::string &buffer) override;
void debug_cancel() override; void debug_cancel() override;
#endif #endif
}; };
class Markdown : public Base { class Markdown : public Base {

19
tests/stubs/config.cc

@ -1,3 +1,20 @@
#include "config.h" #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
}

Loading…
Cancel
Save