xmake.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package("rustup")
  2. set_kind("binary")
  3. set_homepage("https://rustup.rs")
  4. set_description("An installer for the systems programming language Rust")
  5. if is_host("windows") then
  6. if os.arch() == "x64" then
  7. add_urls("https://static.rust-lang.org/rustup/archive/$(version)/x86_64-pc-windows-msvc/rustup-init.exe")
  8. add_versions("1.28.1", "7b83039a1b9305b0c50f23b2e2f03319b8d7859b28106e49ba82c06d81289df6")
  9. elseif os.arch() == "x86" then
  10. add_urls("https://static.rust-lang.org/rustup/archive/$(version)/i686-pc-windows-msvc/rustup-init.exe")
  11. add_versions("1.28.1", "494bbeb52bd102891be4e7e5adc74eeb1c532adfdc33d51ae1aa9fd2ff5f1048")
  12. elseif os.arch() == "arm64" then
  13. add_urls("https://static.rust-lang.org/rustup/archive/$(version)/aarch64-pc-windows-msvc/rustup-init.exe")
  14. add_versions("1.28.1", "9054ad509637940709107920176f14cee334bc5cfe50bc0a24a3dc59b6f4d458")
  15. end
  16. else
  17. add_urls("https://raw.githubusercontent.com/rust-lang/rustup/refs/tags/$(version)/rustup-init.sh")
  18. add_versions("1.28.1", "b25b33de9e5678e976905db7f21b42a58fb124dd098b35a962f963734b790a9b")
  19. end
  20. if is_host("linux") then
  21. add_extsources("apt::rustup")
  22. add_extsources("pacman::rustup")
  23. elseif is_host("macosx") then
  24. add_extsources("brew::rustup")
  25. end
  26. on_load(function (package)
  27. package:addenv("PATH", path.join(".cargo", "bin"))
  28. package:setenv("CARGO_HOME", ".cargo")
  29. package:setenv("RUSTUP_HOME", ".rustup")
  30. package:mark_as_pathenv("CARGO_HOME")
  31. package:mark_as_pathenv("RUSTUP_HOME")
  32. end)
  33. on_install("@windows|x86", "@windows|x64", "@windows|arm64", "@msys", "@cygwin", "@bsd", "@linux", "@macosx", function (package)
  34. local installdir = package:installdir()
  35. local argv = {"--no-modify-path", "--no-update-default-toolchain", "--profile=minimal", "--default-toolchain=none", "-y"}
  36. local envs = {CARGO_HOME = path.join(installdir, ".cargo"), RUSTUP_HOME = path.join(installdir, ".rustup"), RUSTUP_INIT_SKIP_PATH_CHECK = "yes", RUSTUP_VERSION = package:version():shortstr()}
  37. os.vrunv(package:originfile(), argv, {envs = envs, shell = not is_host("windows")})
  38. os.vrunv(path.join(installdir, ".cargo", "bin", "rustup" .. (is_host("windows") and ".exe" or "")), {"set", "auto-self-update", "disable"}, {envs = envs})
  39. end)
  40. on_test(function (package)
  41. os.vrunv("rustup", {"--version"})
  42. end)