xmake.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_install("@windows|x86", "@windows|x64", "@windows|arm64", "@msys", "@cygwin", "@bsd", "@linux", "@macosx", function (package)
  27. local installdir = package:installdir()
  28. local argv = {"--no-modify-path", "--profile=minimal", "--default-toolchain=none", "-y"}
  29. local envs = {CARGO_HOME = path.join(installdir, ".cargo"), RUSTUP_HOME = path.join(installdir, ".rustup"), RUSTUP_INIT_SKIP_PATH_CHECK = "yes"}
  30. os.vrunv(package:originfile(), argv, {envs = envs, shell = not is_host("windows")})
  31. package:addenv("PATH", path.join(".cargo", "bin"))
  32. package:setenv("CARGO_HOME", ".cargo")
  33. package:setenv("RUSTUP_HOME", ".rustup")
  34. package:mark_as_pathenv("CARGO_HOME")
  35. package:mark_as_pathenv("RUSTUP_HOME")
  36. end)
  37. on_test(function (package)
  38. os.vrunv("rustup", {"--version"})
  39. end)