xmake.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package("librats")
  2. set_homepage("https://github.com/DEgITx/librats")
  3. set_description("High-performance, lightweight p2p native library for big networks")
  4. set_license("MIT")
  5. set_urls("https://github.com/DEgITx/librats/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/DEgITx/librats.git")
  7. add_versions("0.3.1", "6a368a5d17a3ee9b97825ed6ee8df2ef46d7dde1c27937ce78c2b90a32b49148")
  8. add_versions("0.3.0", "01e7e323e75ef7ef3b93a3025c7c2f31e37a42ebe414ec707cd500e054754e4b")
  9. add_versions("0.2.1", "32cc19dde006a54efdf642f54053d3506cb78815ca5b2db5c4d2c30104d33fc8")
  10. add_versions("0.1.5", "6e026e66c8a339f383a15ad1243d48acea601d91e584e146b8472cfc17709946")
  11. if is_plat("windows") then
  12. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  13. end
  14. if is_plat("windows", "mingw") then
  15. add_syslinks("ws2_32", "iphlpapi", "bcrypt")
  16. elseif is_plat("linux", "bsd") then
  17. add_syslinks("pthread")
  18. end
  19. add_deps("cmake")
  20. if on_check then
  21. on_check("android", function (package)
  22. local ndk = package:toolchain("ndk")
  23. local ndk_sdkver = ndk:config("ndk_sdkver")
  24. assert(ndk_sdkver and tonumber(ndk_sdkver) > 21, "package(librats) require ndk api level > 21")
  25. end)
  26. end
  27. on_install("windows|!arm*", "linux", "macosx", "cross", function (package)
  28. local file = io.open("CMakeLists.txt", "a")
  29. file:write([[
  30. include(GNUInstallDirs)
  31. install(TARGETS rats)
  32. install(DIRECTORY src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
  33. ]])
  34. file:close()
  35. local configs = {"-DBUILD_TESTS=OFF"}
  36. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  37. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  38. import("package.tools.cmake").install(package, configs)
  39. end)
  40. on_test(function (package)
  41. assert(package:check_cxxsnippets({test = [[
  42. #include <librats.h>
  43. void test() {
  44. // Create client with automatic NAT traversal
  45. librats::NatTraversalConfig nat_config;
  46. nat_config.enable_ice = true;
  47. nat_config.enable_turn_relay = true;
  48. librats::RatsClient client(8080, 10, nat_config);
  49. }
  50. ]]}, {configs = {languages = "c++17"}}))
  51. end)