xmake.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package("osip")
  2. set_homepage("https://savannah.gnu.org/projects/osip")
  3. set_description("oSIP is an LGPL implementation of SIP. It is used mostly with eXosip2 stack (GPL) which provides simpler API for User-Agent implementation.")
  4. set_license("LGPL")
  5. add_urls("https://www.antisip.com/download/exosip2/libosip2-$(version).tar.gz", {alias = "mirror"})
  6. add_urls("https://git.savannah.gnu.org/cgit/osip.git/snapshot/osip-$(version).tar.gz", {alias = "archive"})
  7. add_urls("https://git.savannah.gnu.org/git/osip.git", {alias = "github"})
  8. add_versions("mirror:5.3.0", "f4725916c22cf514969efb15c3c207233d64739383f7d42956038b78f6cae8c8")
  9. add_versions("archive:5.3.0", "593c9d61150b230f7e757b652d70d5fe336c84db7e4db190658f9ef1597d59ed")
  10. add_versions("github:5.3.0", "63846b845929236dbd4d9e51cbd256baf84b8dad")
  11. if is_plat("wasm") then
  12. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  13. end
  14. if is_plat("windows") then
  15. add_syslinks("advapi32")
  16. else
  17. add_deps("autoconf", "automake", "libtool")
  18. end
  19. add_links("osip2", "osipparser2")
  20. on_install("windows", function(package)
  21. import("package.tools.msbuild")
  22. os.cp("include", package:installdir())
  23. local arch = package:is_arch("x64") and "x64" or "Win32"
  24. if package:is_arch("arm64") then
  25. arch = "ARM64"
  26. io.replace("platform/vsnet/osip.sln", "|x64", "|ARM64", {plain = true})
  27. end
  28. local mode = package:is_debug() and "Debug" or "Release"
  29. local configs = { "osip.sln" }
  30. table.insert(configs, "/p:Configuration=" .. mode)
  31. table.insert(configs, "/p:Platform=" .. arch)
  32. os.cd("platform/vsnet")
  33. -- Use *source* folder instead of *osip* folder
  34. io.replace("osip2.vcxproj", [[<ProjectReference Include="..\..\..\osip\platform\vsnet\osipparser2.vcxproj">]], [[<ProjectReference Include="..\..\..\source\platform\vsnet\osipparser2.vcxproj">]], {plain = true})
  35. -- Add external symbols into .def file for .DLL library
  36. local osip2_def_content = io.readfile("osip2.def")
  37. io.writefile("osip2.def", osip2_def_content .. [[
  38. osip_transaction_set_naptr_record @138
  39. ]])
  40. local osipparser2_def_content = io.readfile("osipparser2.def")
  41. io.writefile("osipparser2.def", osipparser2_def_content .. [[
  42. osip_realloc @417
  43. osip_strcasestr @418
  44. __osip_uri_escape_userinfo @419
  45. osip_list_clone @420
  46. ]])
  47. local vcxprojs = { "osip2.vcxproj", "osipparser2.vcxproj" }
  48. for _, vcxproj in ipairs(vcxprojs) do
  49. if package:is_arch("arm64") then
  50. io.replace(vcxproj, "|x64", "|ARM64", {plain = true})
  51. io.replace(vcxproj, "<Platform>x64", "<Platform>ARM64", {plain = true})
  52. end
  53. if not package:has_runtime("MT", "MTd") then
  54. -- Allow MD, MDd
  55. io.replace(vcxproj, "MultiThreadedDebug", "MultiThreadedDebugDLL", {plain = true})
  56. io.replace(vcxproj, "MultiThreaded", "MultiThreadedDLL", {plain = true})
  57. end
  58. if package:config("shared") then
  59. -- Pass .def file
  60. io.replace(vcxproj, "</ClCompile>",
  61. "</ClCompile><Link><ModuleDefinitionFile>$(ProjectDir)/$(TargetName).def</ModuleDefinitionFile></Link>", {plain = true})
  62. -- Allow build shared lib
  63. io.replace(vcxproj, "StaticLibrary", "DynamicLibrary", {plain = true})
  64. end
  65. -- Allow use another Win SDK
  66. io.replace(vcxproj, "<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>", "", {plain = true})
  67. -- Use *source* folder instead of *osip* folder
  68. io.replace(vcxproj, [[<AdditionalIncludeDirectories>..\..\..\osip\include;]], [[<AdditionalIncludeDirectories>..\..\..\source\include;]], {plain = true})
  69. io.replace(vcxproj, [[<ClCompile Include="..\..\..\osip\]], [[<ClCompile Include="..\..\..\source\]], {plain = true})
  70. io.replace(vcxproj, [[<ClInclude Include="..\..\..\osip\]], [[<ClInclude Include="..\..\..\source\]], {plain = true})
  71. end
  72. msbuild.build(package, configs)
  73. os.cp("**.lib", package:installdir("lib"))
  74. if package:config("shared") then
  75. os.cp("**.dll", package:installdir("bin"))
  76. end
  77. end)
  78. on_install("linux", "macosx", "bsd", "android@linux,macosx", "iphoneos", "cross", "wasm", function (package)
  79. local configs = {"--disable-trace"}
  80. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  81. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  82. if not package:debug() then
  83. table.insert(configs, "--disable-debug")
  84. end
  85. if package:is_plat("android") then
  86. table.insert(configs, "--enable-pthread=force")
  87. end
  88. import("package.tools.autoconf").install(package, configs)
  89. end)
  90. on_test(function (package)
  91. assert(package:has_cfuncs("osip_cond_signal", {includes = "osip2/osip_condv.h"}))
  92. end)