xmake.lua 2.7 KB

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