xmake.lua 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package("muslcc")
  2. set_kind("toolchain")
  3. set_homepage("https://musl.cc/")
  4. set_description("static cross- and native- musl-based toolchains.")
  5. if is_host("windows") then
  6. if is_arch("arm64") then
  7. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/aarch64-linux-musl-cross.win.zip")
  8. add_versions("20210202", "1fa7226fb2317fa8dd1571f2a8964e8e4bb973479ec18e35e04b6b0606ff2eba")
  9. elseif is_arch("arm.*") then
  10. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/arm-linux-musleabi-cross.win.zip")
  11. add_versions("20210202", "87061cdc288b6a74b3414bb70ce91da524c126199548cf4b86ae40e074988291")
  12. elseif is_arch("x86", "i386") then
  13. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/i686-linux-musl-cross.win.zip")
  14. add_versions("20210202", "5f2903646a4bdd45d6dadfa65652a3bfe4191eab2e5b0ae1dd9b2e6ccf87f629")
  15. else
  16. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/x86_64-linux-musl-cross.win.zip")
  17. add_versions("20210202", "3a13f8bb3694b26ffbe3fe97d45db6cabadb662161cd5fc9cc80fc0adfb02091")
  18. end
  19. elseif is_host("linux") then
  20. if is_arch("arm64") then
  21. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/aarch64-linux-musl-cross.linux.tgz")
  22. add_versions("20210202", "7e237ecd528d31cb3eadc48a95f4779467f588a89444c43276c77cdfe93787de")
  23. elseif is_arch("arm.*") then
  24. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/arm-linux-musleabi-cross.linux.tgz")
  25. add_versions("20210202", "4e03e69f30eacf6bb573999b5a20c59e320720ed02edccfebfa6f89a9e76b445")
  26. elseif is_arch("x86", "i386") then
  27. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/i686-linux-musl-cross.linux.tgz")
  28. add_versions("20210202", "411e98b50c2f965ec0c7d752896151dc2068060e583f0eb245f2c86556d749c3")
  29. else
  30. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/x86_64-linux-musl-cross.linux.tgz")
  31. add_versions("20210202", "37ef7b69d4c4a20bb2c5e7e01ec7c60c1ac7de2c33b029eaa6c0d8b9e1869c6b")
  32. end
  33. elseif is_host("macosx") then
  34. if is_arch("arm64") then
  35. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/aarch64-linux-musl-cross.mac.tgz")
  36. add_versions("20210202", "5b3e91ebc430428578fa2a443256aca866e61da886d5f645eee9725485877389")
  37. elseif is_arch("arm.*") then
  38. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/arm-linux-musleabi-cross.mac.tgz")
  39. add_versions("20210202", "a177df3f847181c0c7f2b34b9bd7725b4c556c11a347aa0ae36e09ebf23fb480")
  40. elseif is_arch("x86", "i386") then
  41. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/i686-linux-musl-cross.mac.tgz")
  42. add_versions("20210202", "12cd8be154c122f6957ce21a9a5ff2d55a8bd660707b17fb3248578ac955ba25")
  43. else
  44. set_urls("https://github.com/xmake-mirror/musl.cc/releases/download/$(version)/x86_64-linux-musl-cross.mac.tgz")
  45. add_versions("20210202", "09e63d9ec8d2e21643750b9543fb138e59c8e255e5a0ae86bc099368addead89")
  46. end
  47. end
  48. if is_host("macosx") then
  49. -- fix missing libisl.22.dylib
  50. add_deps("libisl 0.22", {host = true, configs = {shared = true}})
  51. end
  52. on_install("@windows", "@msys", "@linux", "@macosx", function (package)
  53. os.tryrm("usr") -- remove soft link
  54. -- fix missing libisl.22.dylib
  55. if is_host("macosx") then
  56. local function patchbin(bin_name)
  57. local cross
  58. if package:is_targetarch("arm64") then
  59. cross = "aarch64-linux-musl-"
  60. elseif package:is_targetarch("arm.*") then
  61. cross = "arm-linux-musleabi-"
  62. elseif package:is_targetarch("x86", "i386") then
  63. cross = "i686-linux-musl-"
  64. else
  65. cross = "x86_64-linux-musl-"
  66. end
  67. local binfile = path.join("bin", cross .. bin_name)
  68. local binfile_raw = binfile .. "-raw"
  69. os.mv(binfile, binfile_raw)
  70. io.writefile(binfile, ([[
  71. #!/usr/bin/env bash
  72. export DYLD_LIBRARY_PATH="%s"
  73. "%s" "$@"]]):format(package:dep("libisl"):installdir("lib"),
  74. path.join(package:installdir(), binfile_raw)))
  75. os.vrunv("chmod", {"777", binfile})
  76. end
  77. patchbin("gcc")
  78. patchbin("g++")
  79. end
  80. os.vcp("*", package:installdir())
  81. end)
  82. on_test(function (package)
  83. local gcc
  84. if package:is_targetarch("arm64") then
  85. gcc = "aarch64-linux-musl-gcc"
  86. elseif package:is_targetarch("arm.*") then
  87. gcc = "arm-linux-musleabi-gcc"
  88. elseif package:is_targetarch("x86", "i386") then
  89. gcc = "i686-linux-musl-gcc"
  90. else
  91. gcc = "x86_64-linux-musl-gcc"
  92. end
  93. if gcc and is_host("windows") then
  94. gcc = gcc .. ".exe"
  95. end
  96. local file = os.tmpfile() .. ".c"
  97. io.writefile(file, "int main(int argc, char** argv) {return 0;}")
  98. os.vrunv(gcc, {"-c", file})
  99. end)