xmake.lua 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.9.2", "1f617b6a4568c7eb3e8ab0f3a67c16989245adc547e3a7d1fd861acb308fb5b2")
  9. add_versions("v2.9.1", "a31dbef8c303aea1268068b4b1ac1aec142ac4124c7cb7d9c7eeb57c414f8d15")
  10. add_versions("v2.8.9", "5f793c393346ef80e47f083ade4d3c2fdfc448658a7917fda35ccd7bd2b911b8")
  11. add_versions("v2.7.9", "9b42d8634833f4885b05b89429dd60044dca99232f6096320b8d857fb33d2aef")
  12. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  13. add_includedirs("include")
  14. if is_plat("windows") then
  15. add_ldflags("/export:malloc", "/export:free", "/export:memmove")
  16. add_syslinks("kernel32", "user32", "gdi32")
  17. add_syslinks("ws2_32", "advapi32", "shell32")
  18. add_ldflags("/LTCG")
  19. add_shflags("/LTCG")
  20. elseif is_plat("android") then
  21. add_syslinks("m", "c")
  22. elseif is_plat("macosx") then
  23. add_frameworks("CoreFoundation", "CoreServices")
  24. else
  25. add_syslinks("pthread", "dl", "m", "c")
  26. end
  27. add_defines("LUA_COMPAT_5_1", "LUA_COMPAT_5_2", "LUA_COMPAT_5_3")
  28. on_load(function (package)
  29. package:add("links", "xmake", "tbox", "sv", "lcurses")
  30. if not package:is_plat("windows") then
  31. package:add("deps", "ncurses")
  32. end
  33. if package:debug() then
  34. package:add("defines", "__tb_debug__")
  35. end
  36. package:add("links", "lua-cjson", "lz4")
  37. package:add("links", "lua")
  38. package:add("includedirs", "include/lua")
  39. end)
  40. on_install("linux", "macosx", "windows", function (package)
  41. local configs = {"--onlylib=y"}
  42. os.cd("core")
  43. io.replace("xmake.lua", 'set_warnings("all", "error")', "", {plain = true})
  44. io.replace("xmake.lua", [[option("pdcurses")
  45. set_default(true)
  46. ]], 'option("pdcurses")\nset_default(false)', {plain = true})
  47. io.replace("src/xmake/engine.c", 'sysarch = "arm64"', 'sysarch = "arm64";', {plain = true})
  48. io.replace("src/xmake/engine.c", 'sysarch = "arm"', 'sysarch = "arm";', {plain = true})
  49. io.replace("src/sv/sv/include/semver.h", [[#if defined(_MSC_VER)
  50. typedef __int8 int8_t;]], '#if defined(_MSC_VER) && (_MSC_VER < 1600)\ntypedef __int8 int8_t;', {plain = true})
  51. import("package.tools.xmake").install(package, configs)
  52. os.cp("../xmake", package:installdir("share"))
  53. if package:is_plat("linux", "macosx") and package:has_cfuncs("readline", {links = "readline", includes = "readline/readline.h"}) then
  54. package:add("syslinks", "readline")
  55. end
  56. end)
  57. on_test(function (package)
  58. assert(package:has_cfuncs("xm_engine_init", {includes = "xmake/xmake.h"}))
  59. end)