xmake.lua 2.8 KB

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