Skip to content

Commit

Permalink
portaudio: add libasound syslink (#5297)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
Centauria and star-hengxing authored Sep 21, 2024
1 parent be13935 commit 4243afb
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions packages/p/portaudio/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package("portaudio")

add_urls("https://github.com/PortAudio/portaudio.git")

add_versions("2024.08.25", "3beece1baedab8acd7084d028df781efacaf31c4")
add_versions("2023.08.05", "95a5c4ba645e01b32f70458f8ddcd92edd62f982")

add_configs("skeleton", {description = "Use skeleton host API", default = false, type = "boolean"})
Expand All @@ -15,6 +16,7 @@ package("portaudio")
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"})
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"})
end

Expand All @@ -28,8 +30,36 @@ package("portaudio")

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
table.insert(configs, "-DCMAKE_BUILD_TYPE=Debug")
table.insert(configs, "-DPA_ENABLE_DEBUG_OUTPUT=ON")
Expand All @@ -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_DEVICE_INFO=" .. (package:config("wdmks_devcie_info") and "ON" or "OFF"))
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"))
end
import("package.tools.cmake").install(package, configs)
Expand Down

0 comments on commit 4243afb

Please sign in to comment.