xmake.lua 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package("usrsctp")
  2. set_homepage("https://github.com/sctplab/usrsctp")
  3. set_description("A portable SCTP userland stack")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/sctplab/usrsctp/archive/refs/tags/$(version).tar.gz", {version = function (version)
  6. return version:gsub("%+", ".")
  7. end})
  8. add_urls("https://github.com/sctplab/usrsctp.git")
  9. add_versions("0.9.5+0", "260107caf318650a57a8caa593550e39bca6943e93f970c80d6c17e59d62cd92")
  10. if not is_plat("bsd") then
  11. add_patches("0.9.5+0", "https://github.com/sctplab/usrsctp/commit/e984d7f3c1b13d0b0582497b385c93f0e8d89fb3.diff", "59c5e71379ca7e9d9849d6347cd0537ec626e6f4cbcdaa53be8f8ec828bbc419")
  12. end
  13. add_patches("0.9.5+0", "https://github.com/sctplab/usrsctp/commit/b56b4300b9ad1c0eb447b7b76a0a3f40b30716be.diff", "8d6d81d449d571284a45e9ba2beb5a206453c012f182366d89f5e5faea572d13")
  14. add_configs("invariants", {description = "Add runtime checks", default = false, type = "boolean"})
  15. add_configs("inet", {description = "Support IPv4", default = true, type = "boolean"})
  16. add_configs("inet6", {description = "Support IPv6", default = true, type = "boolean"})
  17. add_configs("sanitizer_memory", {description = "Compile with memory sanitizer", default = false, type = "boolean"})
  18. add_deps("cmake")
  19. if is_plat("windows", "mingw") then
  20. add_syslinks("ws2_32", "iphlpapi")
  21. elseif is_plat("linux", "bsd") then
  22. add_syslinks("pthread")
  23. end
  24. if on_check then
  25. on_check("android", function (package)
  26. local ndk = package:toolchain("ndk")
  27. local ndk_sdkver = ndk:config("ndk_sdkver")
  28. assert(ndk_sdkver and tonumber(ndk_sdkver) > 23, "package(usrsctp): need ndk api level > 23")
  29. end)
  30. end
  31. on_install("!wasm", function (package)
  32. local configs = {"-Dsctp_werror=0", "-Dsctp_build_programs=0"}
  33. if package:is_debug() then
  34. table.insert(configs, "-DCMAKE_BUILD_TYPE=Debug")
  35. table.insert(configs, "-Dsctp_debug=1")
  36. else
  37. table.insert(configs, "-DCMAKE_BUILD_TYPE=Release")
  38. table.insert(configs, "-Dsctp_debug=0")
  39. end
  40. table.insert(configs, "-Dsctp_build_shared_lib=" .. (package:config("shared") and "1" or "0"))
  41. table.insert(configs, "-Dsctp_sanitizer_address=" .. (package:config("asan") and "1" or "0"))
  42. for name, enabled in pairs(package:configs()) do
  43. if not package:extraconf("configs", name, "builtin") then
  44. table.insert(configs, "-Dsctp_" .. name .. "=" .. (enabled and "1" or "0"))
  45. end
  46. end
  47. if package:is_plat("windows") and package:config("shared") then
  48. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=1")
  49. end
  50. if package:is_plat("bsd") then
  51. io.replace("usrsctplib/netinet/sctp_os_userspace.h", "ip6protosw.h", "ip6_var.h", {plain = true})
  52. end
  53. import("package.tools.cmake").install(package, configs)
  54. end)
  55. on_test(function (package)
  56. assert(package:has_cfuncs("usrsctp_init", {includes = "usrsctp.h"}))
  57. end)