From 8efb735f78a570278bc1d455cc63d781e8064d0e Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 8 Jun 2016 22:40:34 +0200 Subject: [PATCH] Mostly finished with cross compiling options popover (#238) --- src/debug_clang.cc | 26 ++++++++++++++++++++++++++ src/debug_clang.h | 2 ++ src/project.cc | 23 +++++++++++++++++++++-- src/project.h | 8 ++++++-- tests/lldb_test.cc | 2 ++ 5 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/debug_clang.cc b/src/debug_clang.cc index 6a079a1..4539cf7 100644 --- a/src/debug_clang.cc +++ b/src/debug_clang.cc @@ -7,6 +7,7 @@ #include #include "terminal.h" #include "filesystem.h" +#include "process.hpp" #include #include @@ -481,3 +482,28 @@ void Debug::Clang::write(const std::string &buffer) { process->PutSTDIN(buffer.c_str(), buffer.size()); } } + +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) { + stream.write(bytes, n); + }, [](const char *bytes, size_t n) {}, true); + process.write("platform list"); + process.close_stdin(); + if(process.get_exit_status()!=0) + return {}; + std::vector platform_list; + std::string line; + while(std::getline(stream, line)) { + if(line.find("host")==0 || line.find("remote-")==0) { + size_t pos; + if((pos=line.find(": "))!=std::string::npos) { + line.replace(pos, 2, "\n"); + platform_list.emplace_back(line); + } + } + } + + return platform_list; +} diff --git a/src/debug_clang.h b/src/debug_clang.h index c47a095..ad0e1b3 100644 --- a/src/debug_clang.h +++ b/src/debug_clang.h @@ -68,6 +68,8 @@ namespace Debug { void remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count); void write(const std::string &buffer); + + static std::vector get_platform_list(); private: std::unique_ptr debugger; diff --git a/src/project.cc b/src/project.cc index ddec12b..27f9ae5 100644 --- a/src/project.cc +++ b/src/project.cc @@ -155,8 +155,27 @@ void Project::Base::debug_start() { } Project::Clang::DebugOptionsPopover::DebugOptionsPopover() : Gtk::Popover() { - hbox.pack_start(test, true, true); - add(hbox); + auto platform_list=Debug::Clang::get_platform_list(); + for(auto &platform: platform_list) + platform_list_combo_box_text.append(platform); + if(platform_list_combo_box_text.get_model()->children().size()>0) + platform_list_combo_box_text.set_active(0); + url_entry.set_sensitive(false); + platform_list_combo_box_text.signal_changed().connect([this]() { + url_entry.set_sensitive(platform_list_combo_box_text.get_active_row_number()>0); + }); + + url_entry.set_placeholder_text("URL"); + + cross_compiling_vbox.pack_start(platform_list_combo_box_text, true, true); + cross_compiling_vbox.pack_end(url_entry, true, true); + + cross_compiling_frame.set_label("Cross Compiling"); + cross_compiling_frame.add(cross_compiling_vbox); + + vbox.pack_start(cross_compiling_frame, true, true); + vbox.pack_end(not_yet_implemented_label, true, true); + add(vbox); show_all(); set_visible(false); } diff --git a/src/project.h b/src/project.h index 925162b..3236a81 100644 --- a/src/project.h +++ b/src/project.h @@ -61,8 +61,12 @@ namespace Project { public: DebugOptionsPopover(); private: - Gtk::HBox hbox; - Gtk::Label test=Gtk::Label("Not yet implemented"); + Gtk::VBox vbox; + Gtk::Frame cross_compiling_frame; + Gtk::VBox cross_compiling_vbox; + Gtk::ComboBoxText platform_list_combo_box_text; + Gtk::Entry url_entry; + Gtk::Label not_yet_implemented_label=Gtk::Label("Not yet implemented"); }; static std::unordered_map debug_options_popovers; diff --git a/tests/lldb_test.cc b/tests/lldb_test.cc index 49d2332..9e5c5c0 100644 --- a/tests/lldb_test.cc +++ b/tests/lldb_test.cc @@ -68,4 +68,6 @@ int main() { } Debug::Clang::get().cancel(); + + g_assert_cmpuint(Debug::Clang::get_platform_list().size(), >, 0); }