xmake.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package("rcmp")
  2. set_homepage("https://github.com/Smertig/rcmp")
  3. set_description("C++17, multi-architecture cross-platform hooking library with clean API.")
  4. set_license("MIT")
  5. add_urls("https://github.com/Smertig/rcmp/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/Smertig/rcmp.git")
  7. add_versions("v0.2.2", "accbf1d2c72b169857900ce816ca3c1718c63c9f67ded413613c236455a331d5")
  8. add_deps("cmake")
  9. add_deps("nmd")
  10. on_install("linux", "windows", function (package)
  11. local configs = {}
  12. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  13. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  14. os.rm("external/nmd")
  15. import("package.tools.cmake").install(package, configs, {packagedeps = "nmd", buildir = "build"})
  16. local version = package:version()
  17. if version then
  18. package:add("defines", "RCMP_VERSION_MAJOR=" .. version:major())
  19. package:add("defines", "RCMP_VERSION_MINOR=" .. version:minor())
  20. package:add("defines", "RCMP_VERSION_PATCH=" .. version:patch())
  21. end
  22. os.cp("include", package:installdir())
  23. os.trycp("build/**.a", package:installdir("lib"))
  24. os.trycp("build/**.so", package:installdir("lib"))
  25. os.trycp("build/**.dll", package:installdir("bin"))
  26. os.trycp("build/**.lib", package:installdir("lib"))
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test = [[
  30. int bar(float arg) {
  31. return static_cast<int>(arg) + 5;
  32. }
  33. void test() {
  34. rcmp::hook_function<&bar>([](auto original_bar, float arg) {
  35. return original_bar(2 * arg) + 1;
  36. });
  37. }
  38. ]]}, {configs = {languages = "c++17"}, includes = {"rcmp.hpp"}}))
  39. end)