xmake.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package("kotlin-native")
  2. set_kind("toolchain")
  3. set_homepage("https://kotlinlang.org")
  4. set_description("The Kotlin Programming Language. ")
  5. if is_host("windows") then
  6. if os.arch() == "x64" then
  7. add_urls("https://github.com/JetBrains/kotlin/releases/download/v$(version)/kotlin-native-prebuilt-windows-x86_64-$(version).zip")
  8. add_versions("2.1.21", "03301473bb9e68dadfdd265857a2a5913a147e700e345d32db73e0a21a2ffbfa")
  9. add_versions("2.1.10", "966f2a18c90bd3dcaf199f40750f78cfd2c260f912868ab34ffe37d9cc84e81a")
  10. end
  11. elseif is_host("macosx") then
  12. if os.arch() == "x86_64" then
  13. add_urls("https://github.com/JetBrains/kotlin/releases/download/v$(version)/kotlin-native-prebuilt-macos-x86_64-$(version).tar.gz")
  14. add_versions("2.1.21", "fc6b5979ec322be803bfac549661aaf0f8f7342aa3bd09008d471fff2757bbdf")
  15. add_versions("2.1.10", "d7aebac0b5c4bf5adf7b76eac0b9c0cf79bee2e350c03ca93ef24c3cfadbe5cb")
  16. elseif os.arch() == "arm64" then
  17. add_urls("https://github.com/JetBrains/kotlin/releases/download/v$(version)/kotlin-native-prebuilt-macos-aarch64-$(version).tar.gz")
  18. add_versions("2.1.21", "8df16175b962bc4264a5c3b32cb042d91458babbd093c0f36194dc4645f5fe2e")
  19. add_versions("2.1.10", "b0ae655517c63add979462ac6668f3b1c00159d3fbf312dcb2e5752755facb3c")
  20. end
  21. elseif is_host("linux") then
  22. if os.arch() == "x86_64" then
  23. add_urls("https://github.com/JetBrains/kotlin/releases/download/v$(version)/kotlin-native-prebuilt-linux-x86_64-$(version).tar.gz")
  24. add_versions("2.1.21", "42fb88529b4039b6ac1961a137ccb1c79fc80315947f3ec31b56834c7ce20d0b")
  25. add_versions("2.1.10", "bacff7df4425b090dba67653f1408f534009bbbab2b1bdc75584ed6b3a4db0fd")
  26. end
  27. end
  28. add_deps("openjdk")
  29. on_install("@macosx", "@linux|x86_64", "@windows|x64", "@msys|x86_64", function (package)
  30. os.cp("*", package:installdir())
  31. local openjdk = package:dep("openjdk")
  32. local java_home
  33. if not openjdk:is_system() then
  34. java_home = openjdk:installdir()
  35. end
  36. if java_home then
  37. package:setenv("JAVA_HOME", java_home)
  38. end
  39. end)
  40. on_test(function (package)
  41. io.writefile("hello.kt", [[
  42. fun main() {
  43. println("Hello, World!")
  44. }
  45. ]])
  46. local suffix = ""
  47. local suffix2 = ".kexe"
  48. if is_host("windows") then
  49. suffix = ".bat"
  50. suffix2 = ".exe"
  51. end
  52. os.vrunv("kotlinc-native" .. suffix, {"./hello.kt", "-o", "hello"})
  53. os.vrun("./hello" .. suffix2)
  54. end)