xmake.lua 4.5 KB

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