-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrust.cmd
More file actions
executable file
·69 lines (58 loc) · 2.22 KB
/
rust.cmd
File metadata and controls
executable file
·69 lines (58 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
::/*#! 2> /dev/null #
@ 2>/dev/null # 2>nul & echo off & goto BOF #
export SIREUM_HOME=$(cd -P "$(dirname "$0")/../.." && pwd -P) #
exec "${SIREUM_HOME}/bin/sireum" slang run "$0" "$@" #
:BOF
setlocal
set SIREUM_HOME=%~dp0..\..
"%SIREUM_HOME%\bin\sireum.bat" slang run %0 %*
exit /B %errorlevel%
::!#*/
// #Sireum
import org.sireum._
var version: String = "1.95.0"
Os.cliArgs match {
case ISZ(v) => version = v
case _ =>
}
val homeBin: Os.Path = Os.slashDir.up.canon
val (homeBinPlatform, rustupInitUrl): (Os.Path, String) = Os.kind match {
case Os.Kind.Mac =>
val isArm: B = ops.StringOps(proc"uname -m".runCheck().out).trim == "arm64"
val arch: String = if (isArm) "aarch64" else "x86_64"
(homeBin / "mac", s"https://static.rust-lang.org/rustup/dist/$arch-apple-darwin/rustup-init")
case Os.Kind.Linux =>
(homeBin / "linux", "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init")
case Os.Kind.LinuxArm =>
(homeBin / "linux" / "arm", "https://static.rust-lang.org/rustup/dist/aarch64-unknown-linux-gnu/rustup-init")
case Os.Kind.Win =>
(homeBin / "win",
if (Os.isWinArm) "https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe"
else "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe")
case Os.Kind.Unsupported => halt("Unsupported platform")
}
val rustDir: Os.Path = homeBinPlatform / "rust"
val ver = rustDir / "VER"
if (ver.exists && ver.read == version) {
Os.exit(0)
}
println(s"Installing Rust $version ...")
val rustupInit: Os.Path = rustDir / (if (Os.isWin) "rustup-init.exe" else "rustup-init")
rustDir.removeAll()
rustDir.mkdirAll()
println(s"Downloading ${rustupInit.name} ...")
rustupInit.downloadFrom(rustupInitUrl)
rustupInit.chmod("+x")
println()
proc"$rustupInit --default-toolchain=$version -y".env(ISZ(
"CARGO_HOME" ~> (rustDir / "cargo").string,
"RUSTUP_HOME" ~> (rustDir / "rustup").string)
).console.runCheck()
val rustupDir = Os.home / ".rustup"
val cargoDir = Os.home / ".cargo"
rustupDir.removeAll()
cargoDir.removeAll()
rustupDir.mklink(rustDir / "rustup")
cargoDir.mklink(rustDir / "cargo")
ver.writeOver(version)
println()