xmake.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package("lief")
  2. set_homepage("https://lief.quarkslab.com")
  3. set_description("Library to Instrument Executable Formats.")
  4. set_license("Apache-2.0")
  5. set_urls("https://github.com/lief-project/LIEF/archive/$(version).tar.gz",
  6. "https://github.com/lief-project/LIEF.git")
  7. add_versions("0.10.1", "6f30c98a559f137e08b25bcbb376c0259914b33c307b8b901e01ca952241d00a")
  8. add_versions("0.11.5", "6d6d57304a56850958e4ce54f3da2ea2b9eb856ccbab61c6cde9cba15d7c9da5")
  9. add_versions("0.14.0", "400804e38cb5ce8d15fb52a4db6345f02da7b2e5cb773665712283001482b808")
  10. add_versions("0.14.1", "92916dcb3178353d863aef4f409186889983c56e025b774741d5316a72ec3a7d")
  11. add_deps("cmake")
  12. add_configs("elf", {description = "Enable ELF module.", default = true, type = "boolean"})
  13. add_configs("pe", {description = "Enable PE module.", default = true, type = "boolean"})
  14. add_configs("macho", {description = "Enable MachO module.", default = true, type = "boolean"})
  15. add_configs("dex", {description = "Enable Dex module.", default = false, type = "boolean"})
  16. add_configs("vdex", {description = "Enable Vdex module.", default = false, type = "boolean"})
  17. add_configs("oat", {description = "Enable Oat module.", default = false, type = "boolean"})
  18. add_configs("art", {description = "Enable Art module.", default = false, type = "boolean"})
  19. if is_plat("windows") then
  20. add_syslinks("advapi32")
  21. end
  22. on_install("macosx", "linux", "windows", function (package)
  23. local configs = {"-DLIEF_PYTHON_API=OFF", "-DLIEF_DOC=OFF", "-DLIEF_TESTS=OFF", "-DLIEF_EXAMPLES=OFF", "-DLIEF_INSTALL_PYTHON=OFF"}
  24. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  25. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  26. for name, enabled in pairs(package:configs()) do
  27. if not package:extraconf("configs", name, "builtin") then
  28. table.insert(configs, "-DLIEF_" .. name:upper() .. "=" .. (enabled and "ON" or "OFF"))
  29. end
  30. end
  31. import("package.tools.cmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. local parse_entry
  35. if package:config("elf") then
  36. parse_entry = "elf_parse"
  37. elseif package:config("pe") then
  38. parse_entry = "pe_parse"
  39. elseif package:config("macho") then
  40. parse_entry = "macho_parse"
  41. end
  42. if parse_entry then
  43. assert(package:check_cxxsnippets({test = [[
  44. #include <LIEF/LIEF.h>
  45. void test() {
  46. ]] .. parse_entry .. [[("");
  47. }
  48. ]]}, {configs = {languages = "c"}}))
  49. end
  50. end)