xmake.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package("libpeconv")
  2. set_homepage("https://hasherezade.github.io/libpeconv")
  3. set_description("A library to load, manipulate, dump PE files. See also: https://github.com/hasherezade/libpeconv_tpl")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/hasherezade/libpeconv.git")
  6. add_versions("2023.05.31", "709a9b40fa6420c6cd7aa1145b0ff1a154858358")
  7. add_deps("cmake")
  8. if is_plat("windows", "mingw") then
  9. add_syslinks("kernel32", "ntdll")
  10. end
  11. on_install("windows", "mingw", function (package)
  12. local configs = {"-DPECONV_BUILD_TESTING=OFF"}
  13. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  14. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  15. io.replace("libpeconv/CMakeLists.txt", "/MT", "", {plain = true})
  16. io.replace("CMakeLists.txt", "add_subdirectory ( run_pe )", "", {plain = true})
  17. io.replace("CMakeLists.txt", "add_dependencies ( run_pe libpeconv )", "", {plain = true})
  18. import("package.tools.cmake").install(package, configs)
  19. end)
  20. on_test(function (package)
  21. assert(package:check_cxxsnippets({test = [[
  22. void test() {
  23. size_t size = 0;
  24. BYTE* my_pe = peconv::load_pe_executable(NULL, size);
  25. if (my_pe) {
  26. peconv::set_main_module_in_peb((HMODULE)my_pe);
  27. }
  28. }
  29. ]]}, {includes = {"peconv.h"}}))
  30. end)