在不安装Rust的情况下确定目标平台
TL;DR:在不安装Rust或 Cargo的情况下,如何确定Rust的目标平台三元组?
我想下载相应的预编译二进制程序文件。这些预编译二进制程序文件的命名与目标平台相关,例如 s4_aarch64-unknown-linux-gnu_v0.8.80、s4_armv7-unknown-linux-gnueabihf_v0.8.80 等。
目前,我所知的确定目标平台三元组的唯一方法,是使用 rustup 安装Rust,然后安装并运行 default-target。
对于资源受限的系统,无法安装Rust,因此我无法运行 default-target。
因此,我想在没有安装Rust的情况下确定 目标平台,以便选取要下载的正确二进制程序文件。
我希望能得到一个可以用典型的Unix shell脚本实现的解决方案。跨越所有平台可能很难做到,但也许有人只知道针对Linux、只针对Mac等的答案。那就太好了。
解决方案
The rustup install script at https://sh.rustup.rs has a mode that prints the target platform. Simply set RUSTUP_INIT_SH_PRINT=arch.
This shell snippet will set variable target to the current platform target.
target=$(
curl --silent --show-error --fail 'https://sh.rustup.rs' \
| RUSTUP_INIT_SH_PRINT=arch sh
)
Thanks @kmdreko for the suggestion!
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。