xmake.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.8", "e797636aadf072c9b0851dba39b121e93c739d12d78398c91f12e8ed355d6a95")
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. add_configs("embed", {description = "Embed lua scripts.", default = true, type = "boolean"})
  11. add_patches("2.9.8", "patches/2.9.8/xmake-cli.patch", "8d1cc779a4ee6a6958c4e5d9dae2f8811210518a1a48f47c540c363053f6b10b")
  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_frameworks("CoreFoundation", "CoreServices")
  23. else
  24. add_syslinks("pthread", "dl", "m", "c")
  25. end
  26. add_defines("LUA_COMPAT_5_1", "LUA_COMPAT_5_2", "LUA_COMPAT_5_3")
  27. on_load(function (package)
  28. package:add("links", "xmake", "tbox", "sv")
  29. if package:debug() then
  30. package:add("defines", "__tb_debug__")
  31. end
  32. package:add("links", "lua-cjson", "lz4")
  33. package:add("links", "lua")
  34. package:add("includedirs", "include/lua")
  35. end)
  36. on_install("linux", "macosx", "windows", function (package)
  37. local configs = {
  38. onlylib = true,
  39. curses = false,
  40. embed = package:config("embed")}
  41. if package:is_plat("windows") then
  42. configs.pdcurses = false
  43. end
  44. os.cd("core")
  45. io.replace("xmake.lua", 'option("readline")', 'option("readline")\nset_default(false)', {plain = true})
  46. io.replace("xmake.lua", 'set_warnings("all", "error")', "", {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. if not package:config("embed") then
  53. os.cp("../xmake", package:installdir("share"))
  54. end
  55. end)
  56. on_test(function (package)
  57. assert(package:has_cfuncs("xm_engine_init", {includes = "xmake/xmake.h"}))
  58. end)