2
0

xmake.lua 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package("luau")
  2. set_homepage("https://www.luau.org/")
  3. set_description("A fast, small, safe, gradually typed embeddable scripting language derived from Lua.")
  4. set_license("MIT")
  5. add_urls("https://github.com/luau-lang/luau/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/luau-lang/luau.git")
  7. add_versions("696", "95e5727b50547fd6021ef98234bd8b04410b7198d78d05e0faddee9c52b3602f")
  8. add_versions("0.695", "15280abccdd81171236ee9f139dfd2189d2f5db10f6e50b9bf91148dae94591b")
  9. add_versions("0.693", "8843dc7d0a961b289c7e71121ca12db7f2ee41b17d428c59f088789fda9632bf")
  10. add_versions("0.691", "ac4d630d475b352f96ddc511773640a69f146e30f465922e8ce406bd9294df4c")
  11. add_versions("0.689", "d03c79ee496b732c72f405283ffec07185050ed993347e45a0c4a1518c8cb886")
  12. add_versions("0.686", "34dd6a83e71a02f684707b7041674779c03961858a8ecefdd74cad36afc31177")
  13. add_versions("0.683", "a2c7aaf906d625e43ca468792acf8e47a9cbd1d4352623b5e62d2a4011faa15c")
  14. add_versions("0.643", "069702be7646917728ffcddcc72dae0c4191b95dfe455c8611cc5ad943878d3d")
  15. add_versions("0.642", "cc7954979d2b1f6a138a9b0cb0f2d27e3c11d109594379551bc290c0461965ba")
  16. add_versions("0.640", "63ada3e4c8c17e5aff8964b16951bfd1b567329dd81c11ae1144b6e95f354762")
  17. add_versions("0.638", "87ea29188f0d788e3b8649a063cda6b1e1804a648f425f4d0e65ec8449f2d171")
  18. add_versions("0.624", "6d5ce40a7dc0e17da51cc143d2ee1ab32727583c315938f5a69d13ef93ae574d")
  19. add_versions("0.623", "5a72f9e5b996c5ec44ee2c7bd9448d2b2e5061bdf7d057de7490f92fb3003f40")
  20. add_versions("0.538", "8a1240e02a7daacf1e5cff249040a3298c013157fc496c66adce6dcb21cc30be")
  21. add_configs("extern_c", { description = "Use extern C for all APIs.", default = false, type = "boolean" })
  22. add_configs("build_web", { description = "Build web module.", default = false, type = "boolean" })
  23. add_deps("cmake")
  24. on_install(function(package)
  25. io.replace("extern/isocline/src/completers.c", "__finddata64_t", "_finddatai64_t", {plain = true})
  26. local configs = {"-DLUAU_BUILD_TESTS=OFF", "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"}
  27. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "RelWithDebInfo"))
  28. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  29. table.insert(configs, "-DLUAU_BUILD_WEB=" .. ((package:is_plat("wasm") or package:config("build_web")) and "ON" or "OFF"))
  30. table.insert(configs, "-DLUAU_EXTERN_C=" .. (package:config("extern_c") and "ON" or "OFF"))
  31. if package:is_plat("bsd") then
  32. io.replace("CMakeLists.txt", [[if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin|iOS")]], [[if(TRUE)]], {plain = true})
  33. end
  34. if package:is_plat("wasm") then
  35. import("package.tools.cmake").build(package, configs, { target = "Luau.Web", builddir = "build" })
  36. else
  37. import("package.tools.cmake").build(package, configs, { builddir = "build" })
  38. end
  39. local cmake_file = io.readfile("CMakeLists.txt")
  40. local links = {}
  41. for library_name, library_type in cmake_file:gmatch("add_library%(([%a|%.]+) (%w+)") do
  42. library_type = library_type:lower()
  43. if library_name:startswith("Luau.") and (library_type == "static" or library_type == "interface") then
  44. if library_name:endswith(".lib") then
  45. library_name = library_name:sub(1, -5)
  46. end
  47. if library_type == "static" then
  48. table.insert(links, library_name)
  49. end
  50. local include_dir = library_name:sub(6)
  51. include_dir = include_dir:gsub("%..*", "")
  52. os.trycp(include_dir .. "/include/*", package:installdir("include"))
  53. end
  54. end
  55. -- we have to link in reverse order
  56. for i = #links, 1, -1 do
  57. local link = links[i]
  58. package:add("links", link)
  59. end
  60. os.trycp("build/**.a", package:installdir("lib"))
  61. os.trycp("build/**.so", package:installdir("lib"))
  62. os.trycp("build/**.dylib", package:installdir("lib"))
  63. os.trycp("build/**.lib", package:installdir("lib"))
  64. os.trycp("build/**.dll", package:installdir("bin"))
  65. os.trycp("build/luau*", package:installdir("bin"))
  66. package:addenv("PATH", "bin")
  67. end)
  68. on_test(function(package)
  69. if package:config("extern_c") then
  70. assert(package:check_cxxsnippets({ test = [[
  71. extern "C" {
  72. #include <lua.h>
  73. #include <luacode.h>
  74. #include <lualib.h>
  75. }
  76. void test() {
  77. lua_State* L = luaL_newstate();
  78. luaL_openlibs(L);
  79. lua_close(L);
  80. }
  81. ]]}, {configs = {languages = "cxx11"}}))
  82. else
  83. assert(package:check_cxxsnippets({ test = [[
  84. #include <lua.h>
  85. #include <luacode.h>
  86. #include <lualib.h>
  87. void test() {
  88. lua_State* L = luaL_newstate();
  89. luaL_openlibs(L);
  90. lua_close(L);
  91. }
  92. ]]}, {configs = {languages = "cxx11"}}))
  93. end
  94. assert(package:check_cxxsnippets({ test = [[
  95. #include <Luau/Common.h>
  96. void test() {
  97. Luau::FValue<int> v("test", 42, true);
  98. }
  99. ]]}, {configs = {languages = "cxx11"}}))
  100. end)