xmake.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package("libhat")
  2. set_homepage("https://github.com/BasedInc/libhat")
  3. set_description("A high-performance, modern, C++20 library designed around game hacking")
  4. set_license("MIT")
  5. add_urls("https://github.com/BasedInc/libhat/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/BasedInc/libhat.git")
  7. add_versions("v0.9.0", "b1e9e16e804d9f9bec7ccc4df4b8a1cdd281b6ec0c1377244ab28a7944a3e13a")
  8. add_versions("v0.7.0", "09c080be938d6e8901f1af8da74a66dc9d424393e071e1ada5ae13d86c2c9c9b")
  9. add_versions("v0.6.0", "9e25b898277d0bc248e1860ef11acd2dcd860d7fcdadb04d038588c60a850a4f")
  10. add_versions("v0.5.0", "d68a1913bfed2eaa087ea2d8c19ac82c9301839df1bc1beea97b22b532e48adc")
  11. add_configs("sse", {description = "Enable SSE 4.1 scanning", default = false, type = "boolean"})
  12. add_configs("avx", {description = "Enable AVX512 scanning", default = false, type = "boolean"})
  13. add_configs("hint", {description = "Enables support for the x86_64 scan hint, requires a small (less than 1KB) data table", default = false, type = "boolean"})
  14. if is_plat("macosx") then
  15. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  16. end
  17. add_deps("cmake")
  18. on_check("windows", function (package)
  19. local msvc = package:toolchain("msvc")
  20. local vs = msvc:config("vs")
  21. if vs and tonumber(vs) < 2022 then
  22. raise("package(libhat): MSVC 2019 and earlier are not supported.")
  23. end
  24. end)
  25. on_check("android", function (package)
  26. local ndk = package:toolchain("ndk"):config("ndkver")
  27. assert(ndk and tonumber(ndk) > 22, "package(libhat) require ndk version > 22")
  28. end)
  29. on_install("!bsd and !wasm", function (package)
  30. if os.exists("include/libhat/compressed_pair.hpp") then
  31. io.replace("include/libhat/compressed_pair.hpp", [[#include "defines.hpp"]], [[#include "defines.hpp"
  32. #include <cstddef>]], {plain = true})
  33. end
  34. if os.exists("include/libhat/strconv.hpp") then
  35. io.replace("include/libhat/strconv.hpp", [[#include "result.hpp"]], [[#include "result.hpp"
  36. #include <cstdint>]], {plain = true})
  37. end
  38. io.replace("CMakeLists.txt", "/clang:-Werror", "", {plain = true})
  39. io.replace("CMakeLists.txt", "-Werror", "", {plain = true})
  40. local configs = {"-DLIBHAT_TESTING=OFF", "-DLIBHAT_TESTING_ASAN=OFF", "-DLIBHAT_TESTING_SDE=OFF", "-DLIBHAT_EXAMPLES=OFF"}
  41. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  42. table.insert(configs, "-DLIBHAT_SHARED_C_LIB=" .. (package:config("shared") and "ON" or "OFF"))
  43. table.insert(configs, "-DLIBHAT_STATIC_C_LIB=" .. (package:config("shared") and "OFF" or "ON"))
  44. table.insert(configs, "-DLIBHAT_DISABLE_SSE=" .. (package:config("sse") and "OFF" or "ON"))
  45. table.insert(configs, "-DLIBHAT_DISABLE_AVX512=" .. (package:config("avx") and "OFF" or "ON"))
  46. table.insert(configs, "-DLIBHAT_HINT_X86_64=" .. (package:config("hint") and "ON" or "OFF"))
  47. io.replace("CMakeLists.txt", [[install(TARGETS libhat]], [[install(TARGETS libhat_c
  48. EXPORT libhat_c-targets RUNTIME DESTINATION "bin" ARCHIVE DESTINATION "lib" LIBRARY DESTINATION "lib")
  49. install(TARGETS libhat]], {plain = true})
  50. import("package.tools.cmake").install(package, configs)
  51. os.cp("include", package:installdir())
  52. end)
  53. on_test(function (package)
  54. assert(package:check_cxxsnippets({test = [[
  55. #include <libhat/signature.hpp>
  56. void test() {
  57. auto sig = hat::parse_signature("01 02 03 04 05 06 07 08 09").value();
  58. }
  59. ]]}, {configs = {languages = "c++20"}}))
  60. end)