xmake.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_versions("v2.7.1", "e44085090641547d8814afcc345d641d8ce1e38b6e05fee7375fc88150c0803d")
  10. add_configs("readline", { description = "Enable readline library.", default = false, type = "boolean"})
  11. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  12. add_includedirs("include")
  13. if is_plat("windows") then
  14. add_ldflags("/export:malloc", "/export:free", "/export:memmove")
  15. add_syslinks("kernel32", "user32", "gdi32")
  16. add_syslinks("ws2_32", "advapi32", "shell32")
  17. add_ldflags("/LTCG")
  18. add_shflags("/LTCG")
  19. elseif is_plat("android") then
  20. add_syslinks("m", "c")
  21. elseif is_plat("macosx") then
  22. add_ldflags("-all_load", "-pagezero_size 10000", "-image_base 100000000")
  23. add_frameworks("CoreFoundation", "CoreServices")
  24. else
  25. add_syslinks("pthread", "dl", "m", "c")
  26. end
  27. on_load(function (package)
  28. package:add("links", "xmake", "tbox", "sv", "lcurses")
  29. if package:is_plat("windows") then
  30. package:add("links", "pdcurses")
  31. else
  32. package:add("deps", "ncurses")
  33. end
  34. if package:config("readline") then
  35. package:add("links", "readline")
  36. end
  37. if package:debug() then
  38. package:add("defines", "__tb_debug__")
  39. end
  40. package:add("links", "lua-cjson", "lz4")
  41. if not package:gitref() and package:version():le("2.5.9") then
  42. package:add("includedirs", "include/luajit")
  43. package:add("links", "luajit")
  44. else
  45. package:add("includedirs", "include/lua")
  46. package:add("links", "lua")
  47. end
  48. end)
  49. on_install("linux", "macosx", "windows", function (package)
  50. local configs = {"--onlylib=y"}
  51. if package:is_plat("windows") then
  52. table.insert(configs, "--pdcurses=" .. (package:config("curses") and "y" or "n"))
  53. else
  54. table.insert(configs, "--curses=" .. (package:config("curses") and "y" or "n"))
  55. end
  56. if not package:gitref() and package:version():le("2.5.9") then
  57. io.replace("core/src/luajit/xmake.lua", "set_default(false)", "", {plain = true})
  58. end
  59. table.insert(configs, "--readline=" .. (package:config("readline") and "y" or "n"))
  60. os.cd("core")
  61. io.replace("xmake.lua", 'set_warnings("all", "error")', "", {plain = true})
  62. import("package.tools.xmake").install(package, configs)
  63. os.cp("../xmake", package:installdir("share"))
  64. end)
  65. on_test(function (package)
  66. assert(package:has_cfuncs("xm_engine_init", {includes = "xmake/xmake.h"}))
  67. end)