xmake.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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://git.savannah.gnu.org/cgit/osip.git/snapshot/osip-$(version).tar.gz",
  6. "https://git.savannah.gnu.org/git/osip.git")
  7. add_versions("5.3.0", "593c9d61150b230f7e757b652d70d5fe336c84db7e4db190658f9ef1597d59ed")
  8. if is_plat("wasm") then
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. end
  11. if is_plat("windows") then
  12. add_syslinks("advapi32")
  13. else
  14. add_deps("autoconf", "automake", "libtool")
  15. end
  16. add_links("osip2", "osipparser2")
  17. on_install("windows", function(package)
  18. import("package.tools.msbuild")
  19. os.cp("include", package:installdir())
  20. -- rename *source* directory to *osip* directory
  21. local curdir = os.curdir()
  22. os.cd("..")
  23. os.mv(curdir, "osip")
  24. os.cd("osip")
  25. local arch = package:is_arch("x64") and "x64" or "Win32"
  26. if package:is_arch("arm64") then
  27. arch = "ARM64"
  28. io.replace("platform/vsnet/osip.sln", "|x64", "|ARM64", {plain = true})
  29. end
  30. local mode = package:debug() and "Debug" or "Release"
  31. local configs = { "osip.sln" }
  32. table.insert(configs, "/property:Configuration=" .. mode)
  33. table.insert(configs, "/property:Platform=" .. arch)
  34. os.cd("platform/vsnet")
  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 files = {
  48. "osip2.vcxproj",
  49. "osipparser2.vcxproj"
  50. }
  51. for _, vcxproj in ipairs(files) do
  52. if package:is_arch("arm64") then
  53. io.replace(vcxproj, "|x64", "|ARM64", {plain = true})
  54. io.replace(vcxproj, "<Platform>x64", "<Platform>ARM64", {plain = true})
  55. end
  56. if not package:has_runtime("MT", "MTd") then
  57. -- Allow MD, MDd
  58. io.replace(vcxproj, "MultiThreaded", "MultiThreadedDLL", {plain = true})
  59. io.replace(vcxproj, "MultiThreadedDebug", "MultiThreadedDebugDLL", {plain = true})
  60. end
  61. if package:config("shared") then
  62. -- Pass .def file
  63. io.replace(vcxproj, "</ClCompile>",
  64. "</ClCompile><Link><ModuleDefinitionFile>$(ProjectDir)/$(TargetName).def</ModuleDefinitionFile></Link>", {plain = true})
  65. -- Allow build shared lib
  66. io.replace(vcxproj, "StaticLibrary", "DynamicLibrary", {plain = true})
  67. end
  68. -- Allow use another Win SDK
  69. io.replace(vcxproj, "<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>", "", {plain = true})
  70. end
  71. msbuild.build(package, configs)
  72. os.cp("**.lib", package:installdir("lib"))
  73. if package:config("shared") then
  74. os.cp("**.dll", package:installdir("bin"))
  75. end
  76. end)
  77. on_install("linux", "macosx", "bsd", "android@linux,macosx", "iphoneos", "cross", "wasm", function (package)
  78. local configs = {"--disable-trace"}
  79. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  80. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  81. if not package:debug() then
  82. table.insert(configs, "--disable-debug")
  83. end
  84. if package:is_plat("android") then
  85. table.insert(configs, "--enable-pthread=force")
  86. end
  87. import("package.tools.autoconf").install(package, configs)
  88. end)
  89. on_test(function (package)
  90. assert(package:has_cfuncs("osip_cond_signal", {includes = "osip2/osip_condv.h"}))
  91. end)