Browse Source

portaudio: add libasound syslink (#5297)

* portaudio: add libasound syslink

libportaudio.a would have link error when not linked to libasound

* add deps alsa-lib

* patch cmake

* patch android r27 cmake

---------

Co-authored-by: star9029 <[email protected]>
Centauria 11 months ago
parent
commit
4243afb5af
1 changed files with 33 additions and 2 deletions
  1. 33 2
      packages/p/portaudio/xmake.lua

+ 33 - 2
packages/p/portaudio/xmake.lua

@@ -4,6 +4,7 @@ package("portaudio")
 
 
     add_urls("https://github.com/PortAudio/portaudio.git")
     add_urls("https://github.com/PortAudio/portaudio.git")
 
 
+    add_versions("2024.08.25", "3beece1baedab8acd7084d028df781efacaf31c4")
     add_versions("2023.08.05", "95a5c4ba645e01b32f70458f8ddcd92edd62f982")
     add_versions("2023.08.05", "95a5c4ba645e01b32f70458f8ddcd92edd62f982")
 
 
     add_configs("skeleton", {description = "Use skeleton host API", default = false, type = "boolean"})
     add_configs("skeleton", {description = "Use skeleton host API", default = false, type = "boolean"})
@@ -15,6 +16,7 @@ package("portaudio")
         add_configs("wdmks", {description = "Enable support for WDMKS", default = true, type = "boolean"})
         add_configs("wdmks", {description = "Enable support for WDMKS", default = true, type = "boolean"})
         add_configs("wdmks_devcie_info", {description = "Use WDM/KS API for device info", default = true, type = "boolean"})
         add_configs("wdmks_devcie_info", {description = "Use WDM/KS API for device info", default = true, type = "boolean"})
     elseif is_plat("linux") then
     elseif is_plat("linux") then
+        add_configs("alsa", {description = "Enable support for ALSA", default = true, type = "boolean"})
         add_configs("alsa_dynamic", {description = "Enable dynamically loading libasound with dlopen using PaAlsa_SetLibraryPathName", default = false, type = "boolean"})
         add_configs("alsa_dynamic", {description = "Enable dynamically loading libasound with dlopen using PaAlsa_SetLibraryPathName", default = false, type = "boolean"})
     end
     end
 
 
@@ -28,8 +30,36 @@ package("portaudio")
 
 
     add_deps("cmake")
     add_deps("cmake")
 
 
-    on_install("windows", "linux", "macosx", "bsd", "mingw", "msys", "android", "wasm", "cross", function (package)
-        local configs = {"-DPA_BUILD_TESTS=OFF", "-DPA_BUILD_EXAMPLES=OFF"}
+    on_load(function (package)
+        if package:config("alsa") then
+            package:add("deps", "alsa-lib")
+            package:add("defines", "PA_USE_ALSA=1")
+        end
+        if package:config("asio") then
+            package:add("defines", "PA_USE_ASIO=1")
+        end
+        if package:config("direct_sound") then
+            package:add("defines", "PA_USE_DS=1")
+        end
+        if package:config("wmme") then
+            package:add("defines", "PA_USE_WMME=1")
+        end
+        if package:config("wasapi") then
+            package:add("defines", "PA_USE_WASAPI=1")
+        end
+        if package:config("wdmks") then
+            package:add("defines", "PA_USE_WDMKS=1")
+        end
+    end)
+
+    on_install("!iphoneos", function (package)
+        io.replace("CMakeLists.txt", [["${ALSA_LIBRARIES}"]], "ALSA::ALSA", {plain = true})
+
+        local configs = {
+            "-DPA_BUILD_TESTS=OFF",
+            "-DPA_BUILD_EXAMPLES=OFF",
+            "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW",
+        }
         if package:is_debug() then
         if package:is_debug() then
             table.insert(configs, "-DCMAKE_BUILD_TYPE=Debug")
             table.insert(configs, "-DCMAKE_BUILD_TYPE=Debug")
             table.insert(configs, "-DPA_ENABLE_DEBUG_OUTPUT=ON")
             table.insert(configs, "-DPA_ENABLE_DEBUG_OUTPUT=ON")
@@ -48,6 +78,7 @@ package("portaudio")
             table.insert(configs, "-DPA_USE_WDMKS=" .. (package:config("wdmks") and "ON" or "OFF"))
             table.insert(configs, "-DPA_USE_WDMKS=" .. (package:config("wdmks") and "ON" or "OFF"))
             table.insert(configs, "-DPA_USE_WDMKS_DEVICE_INFO=" .. (package:config("wdmks_devcie_info") and "ON" or "OFF"))
             table.insert(configs, "-DPA_USE_WDMKS_DEVICE_INFO=" .. (package:config("wdmks_devcie_info") and "ON" or "OFF"))
         elseif package:is_plat("linux") then
         elseif package:is_plat("linux") then
+            table.insert(configs, "-DPA_USE_ALSA=" .. (package:config("alsa") and "ON" or "OFF"))
             table.insert(configs, "-DPA_ALSA_DYNAMIC=" .. (package:config("alsa_dynamic") and "ON" or "OFF"))
             table.insert(configs, "-DPA_ALSA_DYNAMIC=" .. (package:config("alsa_dynamic") and "ON" or "OFF"))
         end
         end
         import("package.tools.cmake").install(package, configs)
         import("package.tools.cmake").install(package, configs)