xmake.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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("2024.09.06", "e4841b678c14a2e735e59354aa1b0f6755339cab")
  7. add_versions("2023.05.31", "709a9b40fa6420c6cd7aa1145b0ff1a154858358")
  8. add_configs("unicode", {description = "Enable Unicode support.", default = false, type = "boolean"})
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. add_syslinks("kernel32", "ntdll")
  11. add_deps("cmake")
  12. on_install("windows|x64", "windows|x86", "mingw", "msys", function (package)
  13. if package:config("unicode") then
  14. package:add("defines", "UNICODE", "_UNICODE")
  15. end
  16. local configs = {"-DPECONV_BUILD_TESTING=OFF"}
  17. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  18. table.insert(configs, "-DPECONV_UNICODE=" .. (package:config("unicode") and "ON" or "OFF"))
  19. io.replace("run_pe/CMakeLists.txt", "/MT", "", {plain = true})
  20. io.replace("libpeconv/CMakeLists.txt", "/MT", "", {plain = true})
  21. if package:is_plat("windows") then
  22. os.mkdir(path.join(package:buildir(), "run_pe/pdb"))
  23. os.mkdir(path.join(package:buildir(), "libpeconv/pdb"))
  24. end
  25. import("package.tools.cmake").install(package, configs)
  26. os.trycp(path.join(package:buildir(), "run_pe/pdb/run_pe.pdb"), package:installdir("bin"))
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test = [[
  30. void test() {
  31. size_t size = 0;
  32. BYTE* my_pe = peconv::load_pe_executable(NULL, size);
  33. if (my_pe) {
  34. peconv::set_main_module_in_peb((HMODULE)my_pe);
  35. }
  36. }
  37. ]]}, {includes = {"peconv.h"}}))
  38. end)