xmake.lua 4.7 KB

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