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.9", "e92505b83bc9776286eae719d58bcea7ff2577afe12cb5ccb279c81e7dbc702d")
  9. add_versions("v2.9.8", "e797636aadf072c9b0851dba39b121e93c739d12d78398c91f12e8ed355d6a95")
  10. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  11. add_configs("embed", {description = "Embed lua scripts.", default = true, type = "boolean"})
  12. add_patches("2.9.8", "patches/2.9.8/xmake-cli.patch", "8d1cc779a4ee6a6958c4e5d9dae2f8811210518a1a48f47c540c363053f6b10b")
  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")
  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 = {
  39. onlylib = true,
  40. curses = false,
  41. embed = package:config("embed")}
  42. if package:is_plat("windows") then
  43. configs.pdcurses = false
  44. end
  45. os.cd("core")
  46. io.replace("xmake.lua", 'option("readline")', 'option("readline")\nset_default(false)', {plain = true})
  47. io.replace("xmake.lua", 'set_warnings("all", "error")', "", {plain = true})
  48. io.replace("src/xmake/engine.c", 'sysarch = "arm64"', 'sysarch = "arm64";', {plain = true})
  49. io.replace("src/xmake/engine.c", 'sysarch = "arm"', 'sysarch = "arm";', {plain = true})
  50. io.replace("src/sv/sv/include/semver.h", [[#if defined(_MSC_VER)
  51. typedef __int8 int8_t;]], '#if defined(_MSC_VER) && (_MSC_VER < 1600)\ntypedef __int8 int8_t;', {plain = true})
  52. import("package.tools.xmake").install(package, configs)
  53. if not package:config("embed") then
  54. os.cp("../xmake", package:installdir("share"))
  55. end
  56. end)
  57. on_test(function (package)
  58. assert(package:has_cfuncs("xm_engine_init", {includes = "xmake/xmake.h"}))
  59. end)