xmake.lua 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package("libxmake")
  2. set_homepage("https://xmake.io")
  3. set_description("The c/c++ bindings of the xmake core engine")
  4. add_urls("https://github.com/xmake-io/xmake/releases/download/$(version)/xmake-$(version).tar.gz")
  5. add_urls("https://gitee.com/tboox/xmake.git",
  6. "https://github.com/xmake-io/xmake.git",
  7. "https://gitlab.com/tboox/xmake.git")
  8. add_versions("v2.5.9", "5b50e3f28956cabcaa153624c91781730387ceb7c056f3f9b5306b1c77460d8f")
  9. add_configs("readline", { description = "Enable readline library.", default = false, type = "boolean"})
  10. add_includedirs("include")
  11. if is_plat("windows") then
  12. add_ldflags("/export:malloc", "/export:free")
  13. add_syslinks("kernel32", "user32", "gdi32")
  14. add_syslinks("ws2_32", "advapi32", "shell32")
  15. elseif is_plat("android") then
  16. add_syslinks("m", "c")
  17. elseif is_plat("macosx") then
  18. add_ldflags("-all_load", "-pagezero_size 10000", "-image_base 100000000")
  19. elseif is_plat("msys") then
  20. add_ldflags("-static-libgcc", {force = true})
  21. add_syslinks("kernel32", "user32", "gdi32")
  22. add_syslinks("ws2_32", "advapi32", "shell32")
  23. else
  24. add_syslinks("pthread", "dl", "m", "c")
  25. end
  26. on_load(function (package)
  27. package:add("links", "xmake", "tbox", "sv", "lcurses")
  28. if package:is_plat("windows") then
  29. package:add("links", "pdcurses")
  30. else
  31. package:add("deps", "ncurses")
  32. end
  33. if package:config("readline") then
  34. package:add("links", "readline")
  35. end
  36. if package:debug() then
  37. package:add("defines", "__tb_debug__")
  38. end
  39. package:add("links", "lua-cjson")
  40. if not package:gitref() and package:version():le("2.5.9") then
  41. package:add("includedirs", "include/luajit")
  42. package:add("links", "luajit")
  43. else
  44. package:add("includedirs", "include/lua")
  45. package:add("links", "lua")
  46. end
  47. end)
  48. on_install("linux", "macosx", "windows", function (package)
  49. local configs = {"--onlylib=y"}
  50. if package:is_plat("windows") then
  51. table.insert(configs, "--pdcurses=" .. (package:config("curses") and "y" or "n"))
  52. else
  53. table.insert(configs, "--curses=" .. (package:config("curses") and "y" or "n"))
  54. end
  55. if not package:gitref() and package:version():le("2.5.9") then
  56. io.replace("core/src/luajit/xmake.lua", "set_default(false)", "", {plain = true})
  57. end
  58. table.insert(configs, "--readline=" .. (package:config("readline") and "y" or "n"))
  59. os.cd("core")
  60. import("package.tools.xmake").install(package, configs)
  61. os.cp("../xmake", package:installdir("share"))
  62. end)
  63. on_test(function (package)
  64. assert(package:has_cfuncs("xm_engine_init", {includes = "xmake/xmake.h"}))
  65. end)