xmake.lua 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package("resiprocate")
  2. set_homepage("https://resiprocate.org/Main_Page")
  3. set_description("C++ implementation of SIP, ICE, TURN and related protocols.")
  4. set_license("VSL-1.0")
  5. add_urls("https://github.com/resiprocate/resiprocate/archive/refs/tags/resiprocate-$(version).tar.gz",
  6. "https://github.com/resiprocate/resiprocate.git")
  7. add_versions("1.12.0", "aa8906082e4221bffbfab3210df68a6ba1f57ba1532d89ea4572b4fa9877914f")
  8. if is_plat("windows") then
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. end
  11. if is_plat("macosx", "iphoneos", "bsd") then
  12. add_deps("pkg-config")
  13. end
  14. if not is_plat("windows") then
  15. add_deps("autotools")
  16. add_deps("openssl", "c-ares")
  17. add_links("resip", "dum", "rutil", "resipares")
  18. end
  19. if is_plat("windows") then
  20. add_syslinks("ws2_32", "advapi32")
  21. elseif is_plat("linux", "bsd") then
  22. add_syslinks("pthread")
  23. end
  24. on_load("windows", function(package)
  25. package:add("defines", "WIN32")
  26. end)
  27. on_install("windows", function(package)
  28. import("package.tools.msbuild")
  29. local arch = package:is_arch("x64") and "x64" or "Win32"
  30. if package:is_arch("arm64") then
  31. arch = "ARM64"
  32. io.replace("reSIProcate_15_0.sln", "|x64", "|ARM64", {plain = true})
  33. end
  34. local mode = package:is_debug() and "Debug" or "Release"
  35. local configs = { "reSIProcate_15_0.sln" }
  36. table.insert(configs, "/t:resiprocate;dum;rutil")
  37. table.insert(configs, "/p:Configuration=" .. mode)
  38. table.insert(configs, "/p:Platform=" .. arch)
  39. for _, vcxproj in ipairs(os.files("**.vcxproj")) do
  40. if package:is_arch("arm64") then
  41. io.replace(vcxproj, "|x64", "|ARM64", {plain = true})
  42. io.replace(vcxproj, "<Platform>x64", "<Platform>ARM64", {plain = true})
  43. end
  44. if package:has_runtime("MT", "MTd") then
  45. -- Allow MT, MTd
  46. io.replace(vcxproj, "<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>", "<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>", {plain = true})
  47. io.replace(vcxproj, "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>", "<RuntimeLibrary>MultiThreaded</RuntimeLibrary>", {plain = true})
  48. end
  49. -- Allow use another Win SDK
  50. io.replace(vcxproj, "<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>", "", {plain = true})
  51. end
  52. -- std::binary_function requires #include <functional>
  53. io.replace("rutil/dns/RRCache.hxx", "#include <memory>", "#include <memory>\n#include <functional>", {plain = true})
  54. msbuild.build(package, configs)
  55. os.cp("rutil/**.hxx", package:installdir("include/rutil"), {rootdir = "rutil"})
  56. os.cp("rutil/**.h", package:installdir("include/rutil"), {rootdir = "rutil"})
  57. os.cp("resip/**.hxx", package:installdir("include/resip"), {rootdir = "resip"})
  58. os.cp("resip/**.h", package:installdir("include/resip"), {rootdir = "resip"})
  59. os.cp("*/*/resiprocate.lib", package:installdir("lib"))
  60. os.cp("*/*/dum.lib", package:installdir("lib"))
  61. os.cp("*/*/ares.lib", package:installdir("lib"))
  62. os.cp("*/*/rutil.lib", package:installdir("lib"))
  63. end)
  64. on_install("linux", "macosx", "bsd", "iphoneos", "cross", function(package)
  65. local configs = {}
  66. if package:is_plat("bsd") then
  67. -- std::auto_ptr requires _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR std::binary_function requires _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
  68. table.insert(configs, "CXXFLAGS=-D_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION")
  69. -- std::binary_function requires #include <functional>
  70. io.replace("rutil/dns/RRCache.hxx", "#include <memory>", "#include <memory>\n#include <functional>", {plain = true})
  71. end
  72. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  73. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  74. if package:is_debug() then
  75. table.insert(configs, "--enable-debug")
  76. end
  77. import("package.tools.autoconf").install(package, configs)
  78. end)
  79. on_test(function (package)
  80. assert(package:check_cxxsnippets({test = [[
  81. #include <rutil/Socket.hxx>
  82. #include <rutil/Data.hxx>
  83. #include <rutil/TransportType.hxx>
  84. #include <resip/stack/Tuple.hxx>
  85. void test() {
  86. resip::Tuple v4tuple(resip::Data::Empty,2000,resip::IpVersion::V4,resip::TransportType::UDP,resip::Data::Empty);
  87. auto p = v4tuple.getPort();
  88. }
  89. ]]}, {configs = {languages = "c++11"}}))
  90. end)