xmake.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("luau")
  2. set_homepage("https://luau-lang.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/Roblox/luau.git")
  6. add_versions("0.538", "d3b566c258bee3bdccb655c034a11bfc48a586e3")
  7. add_configs("extern_c", { description = "Use extern C for all APIs.", default = false, type = "boolean" })
  8. add_configs("build_web", { description = "Build web module.", default = false, type = "boolean" })
  9. add_deps("cmake")
  10. on_install("linux", "windows", "mingw|x86_64", "macosx", function(package)
  11. local configs = {}
  12. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "RelWithDebInfo"))
  13. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  14. table.insert(configs, "-DLUAU_BUILD_TESTS=OFF")
  15. table.insert(configs, "-DLUAU_BUILD_WEB=" .. (package:config("build_web") and "ON" or "OFF"))
  16. table.insert(configs, "-DLUAU_EXTERN_C=" .. (package:config("extern_c") and "ON" or "OFF"))
  17. import("package.tools.cmake").install(package, configs, { buildir = "build" })
  18. os.trycp("VM/include/*.h", package:installdir("include"))
  19. os.trycp("Ast/include/*", package:installdir("include"))
  20. os.trycp("Common/include/*", package:installdir("include"))
  21. os.trycp("Compiler/include/*", package:installdir("include"))
  22. -- need to link with Ast last
  23. local libs = { "Luau.VM", "Luau.Compiler", "Luau.Ast" }
  24. for _, link in ipairs(libs) do
  25. package:add("links", link)
  26. end
  27. os.trycp("build/*.a", package:installdir("lib"))
  28. os.trycp("build/*.so", package:installdir("lib"))
  29. os.trycp("build/*.dylib", package:installdir("lib"))
  30. os.trycp("build/*.lib", package:installdir("lib"))
  31. os.trycp("build/*.dll", package:installdir("bin"))
  32. os.trycp("build/luau*", package:installdir("bin"))
  33. package:addenv("PATH", "bin")
  34. end)
  35. on_test(function(package)
  36. assert(package:check_cxxsnippets({ test = [[
  37. #include <lua.h>
  38. #include <luacode.h>
  39. #include <lualib.h>
  40. void test() {
  41. auto L = luaL_newstate();
  42. luaL_openlibs(L);
  43. lua_close(L);
  44. }
  45. ]]})
  46. )
  47. end)