2
0

xmake.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package("easyhook")
  2. set_homepage("https://easyhook.github.io")
  3. set_description("EasyHook - The reinvention of Windows API Hooking")
  4. set_license("MIT")
  5. add_urls("https://github.com/EasyHook/EasyHook/archive/refs/tags/$(version).tar.gz", {version = function (version)
  6. return version:gsub("%+", ".")
  7. end})
  8. add_urls("https://github.com/EasyHook/EasyHook.git")
  9. add_versions("v2.7.7097+0", "d0a9f0026c2939234d6cb086a64234ad90ff5eb574fc09dd5d6e0b32e72221d1")
  10. add_patches("v2.7.7097+0", "patches/v2.7.7097+0/fix-build.patch", "b11b0dd74a224f23530ba1b8fe3c210d62f946868a67d0a07afba5501d572abb")
  11. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  12. add_syslinks("psapi", "Aux_ulib")
  13. on_install("windows|!arm*", function (package)
  14. import("package.tools.msbuild")
  15. -- Debundle
  16. os.rm("EasyHookDll/AUX_ULIB_x64.LIB", "EasyHookDll/AUX_ULIB_x86.LIB")
  17. io.replace("EasyHookDll/EasyHookDll.vcxproj", "Aux_ulib_x86.lib", "Aux_ulib.lib", {plain = true})
  18. io.replace("EasyHookDll/EasyHookDll.vcxproj", "Aux_ulib_x64.lib", "Aux_ulib.lib", {plain = true})
  19. os.cp("Public/easyhook.h", package:installdir("include"))
  20. local arch = package:is_arch("x64") and "x64" or "Win32"
  21. if not package:has_runtime("MT", "MTd") then
  22. -- Allow MD, MDd
  23. io.replace("EasyHookDll/EasyHookDll.vcxproj",
  24. "<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>", "<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>", {plain = true})
  25. io.replace("EasyHookDll/EasyHookDll.vcxproj",
  26. "<RuntimeLibrary>MultiThreaded</RuntimeLibrary>", "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>", {plain = true})
  27. end
  28. local mode = package:is_debug() and "netfx4-Debug" or "netfx4-Release"
  29. local configs = { "EasyHook.sln" }
  30. table.insert(configs, "/t:EasyHookDll")
  31. table.insert(configs, "/p:Configuration=" .. mode)
  32. table.insert(configs, "/p:Platform=" .. arch)
  33. table.insert(configs, "/p:BuildProjectReferences=false")
  34. msbuild.build(package, configs)
  35. os.cp("Build/*/*/**.lib", package:installdir("lib"))
  36. os.cp("Build/*/*/**.dll", package:installdir("bin"))
  37. end)
  38. on_test(function (package)
  39. assert(package:has_cfuncs("LhUpdateModuleInformation", {includes = "easyhook.h"}))
  40. end)