xmake.lua 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("fadec")
  2. set_homepage("https://aengelke.net/fadec.html")
  3. set_description("A fast and lightweight decoder for x86 and x86-64 and encoder for x86-64.")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/aengelke/fadec.git")
  6. add_versions("2025.08.21", "3994d89500985491b1a7ccc17827a22058b3de49")
  7. add_configs("arch", {description = "Support only 32-bit x86, 64-bit x86 or both", default = "both", type = "string", values = {"both", "only32", "only64"}})
  8. add_configs("undoc", {description = "Include undocumented instructions", default = false, type = "boolean"})
  9. add_configs("decode", {description = "Include support for decoding", default = true, type = "boolean"})
  10. add_configs("encode", {description = "Include support for encoding", default = false, type = "boolean"})
  11. add_configs("encode2", {description = "Include support for new encoding API", default = false, type = "boolean"})
  12. add_deps("cmake", "python 3.x", {kind = "binary"})
  13. on_install(function (package)
  14. assert(package:config("decode") or package:config("encode") or package:config("encode2"),
  15. "at least one of 'decode', 'encode' or 'encode2' must be enabled")
  16. local configs = {}
  17. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  18. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  19. if package:config("shared") and package:is_plat("windows") then
  20. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  21. end
  22. table.insert(configs, "-DFADEC_ARCHMODE=" .. package:config("arch"))
  23. table.insert(configs, "-DFADEC_UNDOC=" .. (package:config("undoc") and "ON" or "OFF"))
  24. table.insert(configs, "-DFADEC_DECODE=" .. (package:config("decode") and "ON" or "OFF"))
  25. table.insert(configs, "-DFADEC_ENCODE=" .. (package:config("encode") and "ON" or "OFF"))
  26. table.insert(configs, "-DFADEC_ENCODE2=" .. (package:config("encode2") and "ON" or "OFF"))
  27. import("package.tools.cmake").install(package, configs)
  28. end)
  29. on_test(function (package)
  30. if package:config("decode") then
  31. assert(package:has_cfuncs("fd_decode", {includes = "fadec.h"}))
  32. end
  33. if package:config("encode") then
  34. assert(package:check_csnippets({test = [[
  35. void test() {
  36. int failed = 0;
  37. uint8_t buf[64];
  38. uint8_t* cur = buf;
  39. // xor eax, eax
  40. failed |= fe_enc64(&cur, FE_XOR32rr, FE_AX, FE_AX);
  41. }
  42. ]]}, {configs = {languages = "c11"}, includes = "fadec-enc.h"}))
  43. end
  44. if package:config("encode2") then
  45. assert(package:has_cfuncs("fe64_XOR32rr", {includes = "fadec-enc2.h"}))
  46. end
  47. end)