xmake.lua 2.6 KB

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