Browse Source

Mostly finished with cross compiling options popover (#238)

merge-requests/365/head
eidheim 10 years ago
parent
commit
8efb735f78
  1. 26
      src/debug_clang.cc
  2. 2
      src/debug_clang.h
  3. 23
      src/project.cc
  4. 8
      src/project.h
  5. 2
      tests/lldb_test.cc

26
src/debug_clang.cc

@ -7,6 +7,7 @@
#include <iostream> #include <iostream>
#include "terminal.h" #include "terminal.h"
#include "filesystem.h" #include "filesystem.h"
#include "process.hpp"
#include <lldb/API/SBTarget.h> #include <lldb/API/SBTarget.h>
#include <lldb/API/SBProcess.h> #include <lldb/API/SBProcess.h>
@ -481,3 +482,28 @@ void Debug::Clang::write(const std::string &buffer) {
process->PutSTDIN(buffer.c_str(), buffer.size()); process->PutSTDIN(buffer.c_str(), buffer.size());
} }
} }
std::vector<std::string> 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<std::string> 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;
}

2
src/debug_clang.h

@ -69,6 +69,8 @@ namespace Debug {
void write(const std::string &buffer); void write(const std::string &buffer);
static std::vector<std::string> get_platform_list();
private: private:
std::unique_ptr<lldb::SBDebugger> debugger; std::unique_ptr<lldb::SBDebugger> debugger;
std::unique_ptr<lldb::SBListener> listener; std::unique_ptr<lldb::SBListener> listener;

23
src/project.cc

@ -155,8 +155,27 @@ void Project::Base::debug_start() {
} }
Project::Clang::DebugOptionsPopover::DebugOptionsPopover() : Gtk::Popover() { Project::Clang::DebugOptionsPopover::DebugOptionsPopover() : Gtk::Popover() {
hbox.pack_start(test, true, true); auto platform_list=Debug::Clang::get_platform_list();
add(hbox); 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(); show_all();
set_visible(false); set_visible(false);
} }

8
src/project.h

@ -61,8 +61,12 @@ namespace Project {
public: public:
DebugOptionsPopover(); DebugOptionsPopover();
private: private:
Gtk::HBox hbox; Gtk::VBox vbox;
Gtk::Label test=Gtk::Label("Not yet implemented"); 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<std::string, DebugOptionsPopover> debug_options_popovers; static std::unordered_map<std::string, DebugOptionsPopover> debug_options_popovers;

2
tests/lldb_test.cc

@ -68,4 +68,6 @@ int main() {
} }
Debug::Clang::get().cancel(); Debug::Clang::get().cancel();
g_assert_cmpuint(Debug::Clang::get_platform_list().size(), >, 0);
} }

Loading…
Cancel
Save