ソースを参照

exosip: add windows platform (#6971)

* exosip: add windows platform

* fixup

* try fix iphoneos

* drop iphoneos & bsd

* Try fix Mac OS X x86_64

* Try support shared Windows build

* fixing

* fixing

* try fixup

* Try fixup

* undo `on_check`

* redo

* fixup

* try fixup

* fixup

* re

* Update xmake.lua

* Try return `iphoneos`

* Update xmake.lua

* Undo
Saikari 3 ヶ月 前
コミット
efcf382f55
2 ファイル変更171 行追加22 行削除
  1. 54 0
      packages/e/exosip/port/exosip2.def
  2. 117 22
      packages/e/exosip/xmake.lua

+ 54 - 0
packages/e/exosip/port/exosip2.def

@@ -0,0 +1,54 @@
+LIBRARY "eXosip2.dll"
+
+
+EXPORTS
+     eXosip_init     @1
+     eXosip_quit     @2
+     eXosip_set_option     @3
+     eXosip_lock     @4
+     eXosip_unlock     @5
+     eXosip_listen_addr     @6
+     eXosip_set_socket     @7
+     eXosip_set_user_agent     @8
+     eXosip_masquerade_contact     @9
+     eXosip_add_authentication_info     @10
+     eXosip_clear_authentication_info     @11
+     eXosip_default_action     @12
+     eXosip_automatic_action     @13
+     eXosip_generate_random     @14
+     eXosip_hexa_generate_random     @15
+     eXosip_byte_generate_random     @16
+     eXosip_event_free     @17
+     eXosip_event_wait     @18
+     eXosip_event_get     @19
+     eXosip_insubscription_build_answer     @20
+     eXosip_insubscription_send_answer     @21
+     eXosip_insubscription_build_request     @22
+     eXosip_insubscription_build_notify     @23
+     eXosip_insubscription_send_request     @24
+     eXosip_register_build_initial_register     @25
+     eXosip_register_build_initial_register_withqvalue     @26
+     eXosip_register_build_register     @27
+     eXosip_register_send_register     @28
+     eXosip_register_remove     @29
+     eXosip_message_build_request     @30
+     eXosip_message_send_request     @31
+     eXosip_message_build_answer     @32
+     eXosip_message_send_answer     @33
+     eXosip_build_publish     @34
+     eXosip_publish     @35
+     eXosip_options_build_request     @36
+     eXosip_options_send_request     @37
+     eXosip_options_build_answer     @38
+     eXosip_options_send_answer     @39
+     eXosip_transport_set     @40
+     eXosip_guess_localip     @41
+     eXosip_get_remote_sdp     @42
+     eXosip_get_local_sdp     @43
+     eXosip_get_remote_sdp_from_tid     @44
+     eXosip_get_local_sdp_from_tid     @45
+     eXosip_get_sdp_info     @46
+     eXosip_get_audio_connection     @47
+     eXosip_get_audio_media     @48
+     eXosip_get_video_connection     @49
+     eXosip_get_video_media     @50

+ 117 - 22
packages/e/exosip/xmake.lua

@@ -3,37 +3,132 @@ package("exosip")
     set_description("eXosip is a library that hides the complexity of using the SIP protocol for mutlimedia session establishement")
     set_license("GPL-2.0")
 
-    add_urls("https://git.savannah.nongnu.org/cgit/exosip.git/snapshot/exosip-$(version).tar.gz",
-             "git://git.savannah.gnu.org/exosip.git")
+    add_urls("https://www.antisip.com/download/exosip2/libexosip2-$(version).tar.gz", {alias = "mirror"})
+    add_urls("https://git.savannah.nongnu.org/cgit/exosip.git/snapshot/exosip-$(version).tar.gz", {alias = "archive"})
+    add_urls("git://git.savannah.gnu.org/exosip.git", {alias = "github"})
 
-    add_versions("5.3.0", "66c2b2ddcfdc8807054fa31f72a6068ef66d98bedd9aedb25b9031718b9906a2")
+    add_versions("mirror:5.3.0", "5b7823986431ea5cedc9f095d6964ace966f093b2ae7d0b08404788bfcebc9c2")
+    add_versions("archive:5.3.0", "66c2b2ddcfdc8807054fa31f72a6068ef66d98bedd9aedb25b9031718b9906a2")
+    add_versions("github:5.3.0", "7b0983106eaf7f9bad227922e8905bcf0a7b4f59")
+    
+    if is_plat("windows") then
+        add_resources("5.3.0", "nameser_header", "https://raw.githubusercontent.com/c-ares/c-ares/refs/tags/curl-7_20_0/nameser.h", "8acc1a774896c0d02180b355bcb67dba4935a10e5ef54f4290600ae61bb9aa3d")
+    end
+
+    if not is_plat("windows") then
+        add_deps("autotools", "pkg-config")
+    end
+    add_deps("osip", "c-ares", "openssl3")
 
-    add_deps("autoconf", "m4", "libtool", "automake", "osip", "openssl3")
-    add_links("eXosip2", "osip2", "osipparser2")
+    if is_plat("windows") then
+        add_links("eXosip")
+    else
+        add_links("eXosip2", "osip2", "osipparser2")
+    end
 
-    if is_plat("macosx") then
+    if is_plat("windows") then
+        add_syslinks("dnsapi")
+    elseif is_plat("macosx") then
         add_syslinks("resolv")
-        add_frameworks("CoreFoundation")    
-        add_deps("pkg-config")
-    elseif is_plat("linux") then
+        add_frameworks("CoreFoundation", "CoreServices", "Security")
+    elseif is_plat("bsd", "linux") then
         add_syslinks("pthread", "resolv")
     end
 
-    on_check("macosx", function (package)
-        assert(package:check_cxxsnippets({test = [[
-            #include "TargetConditionals.h"
-            #include <CoreFoundation/CoreFoundation.h>
-            #include <CoreServices/CoreServices.h>
-            #include <Security/Security.h>
-            void test() {
-                SInt32 osx_version = 0;
-                OSErr res = Gestalt(gestaltSystemVersion, &osx_version);
-            }
-        ]]}))
+    on_install("windows", function(package)
+        import("package.tools.msbuild")
+        os.cp("include", package:installdir())
+        local headerdir = package:resourcedir("nameser_header")
+        os.cp(path.join(headerdir, "../nameser.h"), "include/nameser.h")
+        os.cp(path.join(package:scriptdir(), "port", "exosip2.def"), "platform/vsnet/eXosip2.def")
+        local arch = package:is_arch("x64") and "x64" or "Win32"
+        if package:is_arch("arm64") then
+            arch = "ARM64"
+            io.replace("platform/vsnet/eXosip.sln", "|x64", "|ARM64", {plain = true})
+        end
+        local mode = package:is_debug() and "Debug" or "Release"
+        local configs = { "eXosip.sln" }
+        table.insert(configs, "/t:eXosip")
+        table.insert(configs, "/p:Configuration=" .. mode)
+        table.insert(configs, "/p:Platform=" .. arch)
+        table.insert(configs, "/p:BuildProjectReferences=false")
+        local include_paths = {}
+        local lib_paths = {}
+        local libs = {"dnsapi.lib"}
+        for _, dep in ipairs({"osip", "c-ares", "openssl3"}) do
+            local packagedep = package:dep(dep)
+            if packagedep then
+                local fetchinfo = packagedep:fetch()
+                if fetchinfo then
+                    for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
+                        table.insert(include_paths, includedir)
+                    end
+                    for _, linkdir in ipairs(fetchinfo.linkdirs) do
+                        table.insert(lib_paths, linkdir)
+                    end
+                    for _, syslink in ipairs(fetchinfo.syslinks) do
+                        table.insert(libs, syslink .. ".lib")
+                    end
+                    for _, link in ipairs(fetchinfo.libfiles) do
+                        -- Exclude ossl-modules/legacy.lib
+                        if not link:lower():match("legacy.dll") then
+                            table.insert(libs, link)
+                        end
+                    end
+                end
+            end
+        end
+        os.cd("platform/vsnet")    
+        io.replace("eXosip.vcxproj",
+            "<AdditionalIncludeDirectories>.-</AdditionalIncludeDirectories>",
+            "<AdditionalIncludeDirectories>" .. table.concat(include_paths, ";") .. "</AdditionalIncludeDirectories>")
+        io.replace("eXosip.vcxproj", [[<AdditionalIncludeDirectories>]], [[<AdditionalIncludeDirectories>..\..\..\source\include;]], {plain = true})
+        if package:is_arch("arm64") then
+            io.replace("eXosip.vcxproj", "|x64", "|ARM64", {plain = true})
+            io.replace("eXosip.vcxproj", "<Platform>x64", "<Platform>ARM64", {plain = true})
+        end
+        if not package:has_runtime("MT", "MTd") then
+            -- Allow MD, MDd
+            io.replace("eXosip.vcxproj", "MultiThreadedDebug", "MultiThreadedDebugDLL", {plain = true})
+            io.replace("eXosip.vcxproj", "MultiThreaded", "MultiThreadedDLL", {plain = true})
+        end
+        if package:config("shared") then
+            -- Pass .def file
+            io.replace("eXosip.vcxproj", [[</ClCompile>]],
+                [[</ClCompile><Link><ModuleDefinitionFile>$(ProjectDir)/eXosip2.def</ModuleDefinitionFile></Link>]], {plain = true})
+            io.replace("eXosip.vcxproj", [[</Link>]],
+                [[<AdditionalLibraryDirectories>]] .. table.concat(lib_paths, ";") .. [[</AdditionalLibraryDirectories><AdditionalDependencies>]] .. table.concat(libs, ";") .. [[</AdditionalDependencies></Link>]], {plain = true})
+            -- Allow build shared lib
+            io.replace("eXosip.vcxproj", "StaticLibrary", "DynamicLibrary", {plain = true})
+        end
+        -- Allow use another Win SDK
+        io.replace("eXosip.vcxproj", "<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>", "", {plain = true})
+        -- Use *source* dir
+        io.replace("eXosip.vcxproj", [[<ClCompile Include="..\..\..\exosip\]], [[<ClCompile Include="..\..\..\source\]], {plain = true})
+        io.replace("eXosip.vcxproj", [[<ClInclude Include="..\..\..\exosip\]], [[<ClInclude Include="..\..\..\source\]], {plain = true})
+        -- Do not use ProjectReference
+        io.replace("eXosip.vcxproj", "<ProjectReference.-</ProjectReference>", "")
+        msbuild.build(package, configs)
+        os.cp("**.lib", package:installdir("lib"))
+        if package:config("shared") then
+            os.cp("**.dll", package:installdir("bin"))
+        end
     end)
 
-    on_install("macosx", "linux", function (package)
-        local configs = {"--disable-trace", "--enable-pthread=force"}
+    on_install("linux", "macosx", "android@linux,macosx", "cross", "wasm", function (package)
+        if package:is_plat("macosx") then
+            io.replace("src/Makefile.am",
+                "libeXosip2_la_LDFLAGS = -version-info $(LIBEXOSIP_SO_VERSION) -no-undefined",
+                "libeXosip2_la_LDFLAGS = -version-info $(LIBEXOSIP_SO_VERSION) -no-undefined\nlibeXosip2_la_LDFLAGS += -framework CoreFoundation -framework CoreServices -framework Security", {plain = true})
+        end
+        if package:is_plat("android") then
+            local ndkver = tonumber(package:toolchain("ndk"):config("ndkver"))
+            if ndkver > 22 then
+                io.replace("src/eXutils.c", [[#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || __APPLE__ || defined(ANDROID)) && !_GNU_SOURCE]],
+                        [[#elif 1]], {plain = true})
+            end
+        end
+        local configs = {"--disable-trace", "--enable-pthread=force", "--enable-tools=no"}
         table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
         table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
         if not package:debug() then