xmake.lua 5.1 KB

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