xmake.lua 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package("nng")
  2. set_homepage("https://github.com/nanomsg/nng")
  3. set_description("NNG, like its predecessors nanomsg (and to some extent ZeroMQ), is a lightweight, broker-less library, offering a simple API to solve common recurring messaging problems.")
  4. set_license("MIT")
  5. add_urls("https://github.com/nanomsg/nng/archive/refs/tags/$(version).zip",
  6. "https://github.com/nanomsg/nng.git")
  7. add_versions("v1.10.1", "ce209b0830c8dc69980cbd78aa39f4590a28799e7a00fd2b938a82cf740e7d9a")
  8. add_versions("v1.8.0", "48effcfd1acf31f6afcb1a92ecb4aa87f7993f5c54bf6587b0f4fb2606ce96d3")
  9. add_versions("v1.7.3", "72b39c63ba6467f6ee70c218c291240ff5b189569c3b84e8e0647f5d4d3888ea")
  10. add_versions("v1.5.2", "652ff3a2dbaeae194942205c369e9259e2b5cb5985d679d744cbfb95d1c807a3")
  11. add_versions("v1.4.0", "43674bb15d0f3810cf3602d2662cc91b6576b914492710244125e32b29f546b8")
  12. add_versions("v1.3.2", "2616110016c89ed3cbd458022ba41f4f545ab17f807546d2fdd0789b55d64471")
  13. -- default is false
  14. add_configs("NNG_ELIDE_DEPRECATED", {description = "Elide deprecated functionality.", default = false, type = "boolean"})
  15. add_configs("NNG_TRANSPORT_ZEROTIER", {description = "Enable ZeroTier transport (requires libzerotiercore).", default = false, type = "boolean"})
  16. add_configs("NNG_ENABLE_TLS", {description = "Enable TLS support.", default = false, type = "boolean"})
  17. -- default is true
  18. add_configs("NNG_ENABLE_STATS", {description = "Enable statistics.", default = true, type = "boolean"})
  19. add_configs("NNG_PROTO_BUS0", {description = "Enable BUSv0 protocol.", default = true, type = "boolean"})
  20. add_configs("NNG_PROTO_PAIR0", {description = "Enable PAIRv0 protocol.", default = true, type = "boolean"})
  21. add_configs("NNG_PROTO_PAIR1", {description = "Enable PAIRv1 protocol.", default = true, type = "boolean"})
  22. add_configs("NNG_PROTO_PUSH0", {description = "Enable PUSHv0 protocol.", default = true, type = "boolean"})
  23. add_configs("NNG_PROTO_PULL0", {description = "Enable PULLv0 protocol.", default = true, type = "boolean"})
  24. add_configs("NNG_PROTO_PUB0", {description = "Enable PUBv0 protocol.", default = true, type = "boolean"})
  25. add_configs("NNG_PROTO_SUB0", {description = "Enable SUBv0 protocol.", default = true, type = "boolean"})
  26. add_configs("NNG_PROTO_REQ0", {description = "Enable REQv0 protocol.", default = true, type = "boolean"})
  27. add_configs("NNG_PROTO_REP0", {description = "Enable REPv0 protocol.", default = true, type = "boolean"})
  28. add_configs("NNG_PROTO_RESPONDENT0", {description = "Enable RESPONDENTv0 protocol.", default = true, type = "boolean"})
  29. add_configs("NNG_PROTO_SURVEYOR0", {description = "Enable SURVEYORv0 protocol.", default = true, type = "boolean"})
  30. add_configs("NNG_ENABLE_HTTP", {description = "Enable HTTP API.", default = true, type = "boolean"})
  31. add_configs("NNG_TRANSPORT_INPROC", {description = "Enable inproc transport.", default = true, type = "boolean"})
  32. add_configs("NNG_TRANSPORT_IPC", {description = "Enable IPC transport.", default = true, type = "boolean"})
  33. add_configs("NNG_TRANSPORT_TCP", {description = "Enable TCP transport.", default = true, type = "boolean"})
  34. add_configs("NNG_TRANSPORT_TLS", {description = "Enable TLS transport.", default = true, type = "boolean"})
  35. add_configs("NNG_TRANSPORT_WS", {description = "Enable WebSocket transport.", default = true, type = "boolean"})
  36. add_configs("NNG_TRANSPORT_WSS", {description = "Enable WSS transport.", default = true, type = "boolean"})
  37. if is_plat("linux") then
  38. add_syslinks("pthread")
  39. elseif is_plat("windows") then
  40. add_syslinks("ws2_32", "advapi32")
  41. end
  42. on_load(function (package)
  43. if not package:config("shared") then
  44. package:add("defines", "NNG_STATIC_LIB")
  45. end
  46. if package:config("NNG_ENABLE_TLS") then
  47. package:add("deps", "mbedtls")
  48. end
  49. end)
  50. add_deps("cmake")
  51. on_install("windows", "linux", "macosx", "android", "iphoneos", "cross", function(package)
  52. local configs = {"-DNNG_TESTS=OFF", "-DNNG_ENABLE_NNGCAT=OFF"}
  53. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  54. for name, enabled in pairs(package:configs()) do
  55. if not package:extraconf("configs", name, "builtin") then
  56. table.insert(configs, "-D" .. name .. "=" .. (enabled and "ON" or "OFF"))
  57. end
  58. end
  59. import("package.tools.cmake").install(package, configs)
  60. end)
  61. on_test(function(package)
  62. assert(package:check_csnippets({test = [[
  63. #include <nng/nng.h>
  64. #include <nng/protocol/reqrep0/req.h>
  65. #include <nng/supplemental/util/platform.h>
  66. static void test() {
  67. nng_socket sock;
  68. int rv;
  69. nng_req0_open(&sock);
  70. nng_close(sock);
  71. }
  72. ]]}, {includes = "nng/nng.h"}))
  73. end)