From 5cde6622b51be72d26e40c424c1a73b07db56cbd Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Thu, 19 Jun 2025 14:56:13 +0800 Subject: [PATCH] Support `rustup` on Windows [GitHub #218] --- src/recipe/lang/Rust/rustup.c | 37 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/recipe/lang/Rust/rustup.c b/src/recipe/lang/Rust/rustup.c index 74fd3c0..96a90ed 100644 --- a/src/recipe/lang/Rust/rustup.c +++ b/src/recipe/lang/Rust/rustup.c @@ -1,9 +1,9 @@ /** ------------------------------------------------------------ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------- - * File Authors : Aoran Zeng - * Contributors : Yangmoooo - * | Mikachu2333 + * File Authors : Aoran Zeng + * Contributors : Yangmoooo + * | Mikachu2333 * | * Created On : <2024-10-02> * Last Modified : <2025-06-19> @@ -19,16 +19,16 @@ static SourceProvider_t pl_rust_binary_upstream = * @update 2025-06-17 */ static Source_t pl_rust_rustup_sources[] = { - {&pl_rust_binary_upstream, "https://static.rust-lang.org"}, - {&MirrorZ, "https://mirrors.cernet.edu.cn/rustup"}, - {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/rustup"}, - {&Ustc, "https://mirrors.ustc.edu.cn/rust-static"}, - {&Nju, "https://mirror.nju.edu.cn/rustup"}, - {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/rust-static"}, - {&Zju, "https://mirrors.zju.edu.cn/rustup"}, - {&Iscas, "https://mirror.iscas.ac.cn/rustup"}, - {&Ali, "https://mirrors.aliyun.com/rustup"}, - {&RsProxyCN, "https://rsproxy.cn"}}; + {&pl_rust_binary_upstream, "https://static.rust-lang.org"}, + {&MirrorZ, "https://mirrors.cernet.edu.cn/rustup"}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/rustup"}, + {&Ustc, "https://mirrors.ustc.edu.cn/rust-static"}, + {&Nju, "https://mirror.nju.edu.cn/rustup"}, + {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/rust-static"}, + {&Zju, "https://mirrors.zju.edu.cn/rustup"}, + {&Iscas, "https://mirror.iscas.ac.cn/rustup"}, + {&Ali, "https://mirrors.aliyun.com/rustup"}, + {&RsProxyCN, "https://rsproxy.cn"}}; def_sources_n(pl_rust_rustup); @@ -52,6 +52,16 @@ pl_rust_rustup_setsrc (char *option) { chsrc_yield_source_and_confirm (pl_rust_rustup); +#ifdef XY_On_Windows + + char *cmd1 = xy_strjoin (3, "setx RUSTUP_DIST_SERVER \"", source.url, "\""); + char *cmd2 = xy_strjoin (3, "setx RUSTUP_UPDATE_ROOT \"", source.url, "/rustup\""); + + char *cmd = xy_strjoin (3, cmd1, " & ", cmd2); + chsrc_run (cmd, RunOpt_Dont_Notify_On_Success|RunOpt_No_Last_New_Line); + +#else + char *w1 = xy_strjoin (3, "export RUSTUP_DIST_SERVER=\"", source.url, "\"\n"); char *w2 = xy_strjoin (3, "export RUSTUP_UPDATE_ROOT=\"", source.url, "/rustup\"\n"); @@ -82,6 +92,7 @@ pl_rust_rustup_setsrc (char *option) chsrc_backup (fishrc); chsrc_append_to_file (w, fishrc); } +#endif chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source);