xmake.lua 3.5 KB

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