Browse Source

Fixed Rust installation on MSYS2

pipelines/353213535
eidheim 4 years ago
parent
commit
b2aade877b
  1. 8
      src/filesystem.cpp
  2. 19
      src/notebook.cpp

8
src/filesystem.cpp

@ -325,7 +325,11 @@ const std::vector<boost::filesystem::path> &filesystem::get_executable_search_pa
if(!c_env)
return paths;
const std::string env = c_env;
#ifdef _WIN32
const char delimiter = ';';
#else
const char delimiter = ':';
#endif
size_t previous = 0;
size_t pos;
@ -346,7 +350,11 @@ const std::vector<boost::filesystem::path> &filesystem::get_executable_search_pa
boost::filesystem::path filesystem::find_executable(const std::string &executable_name) {
for(auto &path : get_executable_search_paths()) {
boost::system::error_code ec;
#ifdef _WIN32
auto executable_path = path / (executable_name + ".exe");
#else
auto executable_path = path / executable_name;
#endif
if(boost::filesystem::exists(executable_path, ec))
return executable_path;
}

19
src/notebook.cpp

@ -77,7 +77,12 @@ Notebook::Notebook() : Gtk::Paned(), notebooks(2) {
std::string env;
if(auto c_env = std::getenv("PATH"))
env = c_env;
Glib::setenv("PATH", !env.empty() ? env + ':' + cargo_bin.string() : cargo_bin.string());
#ifdef _WIN32
const char delimiter = ';';
#else
const char delimiter = ':';
#endif
Glib::setenv("PATH", !env.empty() ? env + delimiter + cargo_bin.string() : cargo_bin.string());
filesystem::rust_sysroot_path = {};
filesystem::rust_nightly_sysroot_path = {};
filesystem::executable_search_paths = {};
@ -619,8 +624,11 @@ void Notebook::install_rust() {
canceled = true;
});
boost::optional<int> exit_status;
#ifdef _WIN32
std::string command = "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | RUSTUP_HOME=$HOME/.rustup CARGO_HOME=$HOME/.cargo sh -s -- -y";
#else
std::string command = "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
#endif
Terminal::get().print("\e[2mRunning: " + command + "\e[m\n");
auto process = Terminal::get().async_process(command, "", [&exit_status](int exit_status_) {
exit_status = exit_status_;
@ -641,7 +649,12 @@ void Notebook::install_rust() {
if(auto c_env = std::getenv("PATH"))
env = c_env;
auto cargo_bin = filesystem::get_home_path() / ".cargo" / "bin";
Glib::setenv("PATH", !env.empty() ? env + ':' + cargo_bin.string() : cargo_bin.string());
#ifdef _WIN32
const char delimiter = ';';
#else
const char delimiter = ':';
#endif
Glib::setenv("PATH", !env.empty() ? env + delimiter + cargo_bin.string() : cargo_bin.string());
}
filesystem::rust_sysroot_path = {};
filesystem::rust_nightly_sysroot_path = {};

Loading…
Cancel
Save