Procházet zdrojové kódy

Adding rust toolchain (#6977)

* adding rust toolchain package

* adding rust toolchain

* fixing rust package

* Update xmake.lua

* splitting rust and rustup-init in two packages (Lynix request)

* Update xmake.lua

* replacing rustup-init with rustup package

* Update xmake.lua

* Update xmake.lua

---------

Co-authored-by: Jérôme Leclercq <[email protected]>
kbz_8 před 3 měsíci
rodič
revize
4bc0e4e2b8
2 změnil soubory, kde provedl 69 přidání a 0 odebrání
  1. 22 0
      packages/r/rust/xmake.lua
  2. 47 0
      packages/r/rustup/xmake.lua

+ 22 - 0
packages/r/rust/xmake.lua

@@ -0,0 +1,22 @@
+package("rust")
+    set_kind("toolchain")
+    set_homepage("https://rust-lang.org")
+    set_description("Rust is a general-purpose programming language emphasizing performance, type safety, and concurrency.")
+
+    add_versions("1.86.0", "")
+
+    add_deps("rustup", {private = true})
+
+    on_install("@windows|x86", "@windows|x64", "@windows|arm64", "@msys", "@cygwin", "@bsd", "@linux", "@macosx", function (package)
+        local rustup = package:dep("rustup"):installdir()
+        local version = package:version():shortstr()
+        os.vrunv("rustup", {"install", version})
+        os.mv(path.join(rustup, ".rustup", "toolchains", version .. "-*", "*"), package:installdir())
+        package:addenv("RC", "bin/rustc" .. (is_host("windows") and ".exe" or ""))
+        package:mark_as_pathenv("RC")
+    end)
+
+    on_test(function (package)
+        os.vrun("cargo --version")
+        os.vrun("rustc --version")
+    end)

+ 47 - 0
packages/r/rustup/xmake.lua

@@ -0,0 +1,47 @@
+package("rustup")
+    set_kind("binary")
+    set_homepage("https://rustup.rs")
+    set_description("An installer for the systems programming language Rust")
+
+    if is_host("windows") then
+        if os.arch() == "x64" then
+            add_urls("https://static.rust-lang.org/rustup/archive/$(version)/x86_64-pc-windows-msvc/rustup-init.exe")
+
+            add_versions("1.28.1", "7b83039a1b9305b0c50f23b2e2f03319b8d7859b28106e49ba82c06d81289df6")
+        elseif os.arch() == "x86" then
+            add_urls("https://static.rust-lang.org/rustup/archive/$(version)/i686-pc-windows-msvc/rustup-init.exe")
+
+            add_versions("1.28.1", "494bbeb52bd102891be4e7e5adc74eeb1c532adfdc33d51ae1aa9fd2ff5f1048")
+        elseif os.arch() == "arm64" then
+            add_urls("https://static.rust-lang.org/rustup/archive/$(version)/aarch64-pc-windows-msvc/rustup-init.exe")
+
+            add_versions("1.28.1", "9054ad509637940709107920176f14cee334bc5cfe50bc0a24a3dc59b6f4d458")
+        end
+    else
+        add_urls("https://raw.githubusercontent.com/rust-lang/rustup/refs/tags/$(version)/rustup-init.sh")
+
+        add_versions("1.28.1", "b25b33de9e5678e976905db7f21b42a58fb124dd098b35a962f963734b790a9b")
+    end
+
+    if is_host("linux") then
+        add_extsources("apt::rustup")
+        add_extsources("pacman::rustup")
+    elseif is_host("macosx") then
+        add_extsources("brew::rustup")
+    end
+
+    on_install("@windows|x86", "@windows|x64", "@windows|arm64", "@msys", "@cygwin", "@bsd", "@linux", "@macosx", function (package)
+        local installdir = package:installdir()
+        local argv = {"--no-modify-path", "--profile=minimal", "--default-toolchain=none", "-y"}
+        local envs = {CARGO_HOME = path.join(installdir, ".cargo"), RUSTUP_HOME = path.join(installdir, ".rustup"), RUSTUP_INIT_SKIP_PATH_CHECK = "yes"}
+        os.vrunv(package:originfile(), argv, {envs = envs, shell = not is_host("windows")})
+        package:addenv("PATH", path.join(".cargo", "bin"))
+        package:setenv("CARGO_HOME", ".cargo")
+        package:setenv("RUSTUP_HOME", ".rustup")
+        package:mark_as_pathenv("CARGO_HOME")
+        package:mark_as_pathenv("RUSTUP_HOME")
+    end)
+
+    on_test(function (package)
+        os.vrunv("rustup", {"--version"})
+    end)