From b2aade877b50bbe11616f0518345514f78c1712f Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 9 Jul 2021 14:57:52 +0200 Subject: [PATCH] Fixed Rust installation on MSYS2 --- src/filesystem.cpp | 8 ++++++++ src/notebook.cpp | 19 ++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 8255643..5dcc6c6 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -325,7 +325,11 @@ const std::vector &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 &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; } diff --git a/src/notebook.cpp b/src/notebook.cpp index 51cdeb6..b4aa127 100644 --- a/src/notebook.cpp +++ b/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 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 = {};