xmake.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package("libmem")
  2. set_homepage("https://github.com/rdbo/libmem")
  3. set_description("Cross-platform game hacking library for C, C++, Rust, and Python, supporting process/memory hacking, hooking, detouring, and DLL/SO injection.")
  4. set_license("AGPL-3.0")
  5. add_urls("https://github.com/rdbo/libmem/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/rdbo/libmem.git", {submodules = false})
  7. add_versions("5.1.0", "9f61b53ce86fd59afb13bc4f48db40e8c8dc156f56879b9e9929014924f95495")
  8. add_versions("5.0.5", "9693d38b17b000b06cd9fbaff72f4e0873d3cf219a6e99a20bb90cf98a7b562d")
  9. add_versions("5.0.4", "32b968fb2bd1e33ae854db3bd3fc9ce4374bd9e61ff420f365c52d5f7bbd85dd")
  10. add_versions("5.0.3", "75a190d1195c641c7d5d2c37ac79d8d1b5f18e43268d023454765a566d6f0d88")
  11. add_versions("5.0.2", "99adea3e86bd3b83985dce9076adda16968646ebd9d9316c9f57e6854aeeab9c")
  12. add_patches("5.1.0", "patches/5.1.0/fix-freebsd.diff", "98a454d2c71f8f7a63ed5714301ad5f51f92790e3debe5b35a16f14b83c34404")
  13. add_patches(">=5.0.5", "patches/5.0.5/fix-mingw.diff", "7239f459204975ce2efcf63529dcb09273028c4dc166d7cbacb5f5f0e70f93a9")
  14. add_deps("capstone", "keystone")
  15. if is_plat("windows", "mingw") then
  16. add_syslinks("user32", "psapi", "ntdll", "shell32", "ole32")
  17. if is_plat("mingw") then
  18. add_syslinks("uuid")
  19. end
  20. elseif is_plat("linux") then
  21. add_syslinks("dl", "m")
  22. elseif is_plat("bsd") then
  23. add_syslinks("dl", "kvm", "procstat", "elf", "m")
  24. end
  25. on_check("android", function(package)
  26. local ndk = package:toolchain("ndk")
  27. local ndk_sdkver = ndk:config("ndk_sdkver")
  28. assert(ndk_sdkver and tonumber(ndk_sdkver) >= 24, "package(libmem): need ndk api level >= 24 for android")
  29. end)
  30. on_load(function(package)
  31. if package:is_plat("windows") or package:config("shared") then
  32. package:add("defines", "LM_EXPORT")
  33. end
  34. end)
  35. on_install("windows", "linux|!arm64", "bsd", "mingw", "msys", "android", function (package)
  36. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  37. import("package.tools.xmake").install(package)
  38. end)
  39. on_test(function (package)
  40. assert(package:check_csnippets({test = [[
  41. #include <libmem/libmem.h>
  42. void test() {
  43. lm_thread_t resultThread;
  44. lm_bool_t result = LM_GetThread(&resultThread);
  45. }
  46. ]]}, {configs = {languages = "c11"}}))
  47. assert(package:check_cxxsnippets({test = [[
  48. #include <libmem/libmem.hpp>
  49. #include <vector>
  50. #include <optional>
  51. using namespace libmem;
  52. void test() {
  53. std::optional<Thread> currentThread = GetThread();
  54. std::optional<std::vector<Thread>> threads = EnumThreads();
  55. }
  56. ]]}, {configs = {languages = "c++17"}}))
  57. end)