xmake.lua 3.4 KB

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