xmake.lua 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package("portaudio")
  2. set_homepage("http://www.portaudio.com")
  3. set_description("PortAudio is a cross-platform, open-source C language library for real-time audio input and output.")
  4. add_urls("https://github.com/PortAudio/portaudio.git")
  5. add_versions("2024.08.25", "3beece1baedab8acd7084d028df781efacaf31c4")
  6. add_versions("2023.08.05", "95a5c4ba645e01b32f70458f8ddcd92edd62f982")
  7. add_configs("skeleton", {description = "Use skeleton host API", default = false, type = "boolean"})
  8. add_configs("asio", {description = "Enable support for ASIO", default = false, type = "boolean"})
  9. if is_plat("windows") then
  10. add_configs("direct_sound", {description = "Enable support for DirectSound", default = true, type = "boolean"})
  11. add_configs("wmme", {description = "Enable support for WMME", default = true, type = "boolean"})
  12. add_configs("wasapi", {description = "Enable support for WASAPI", default = true, type = "boolean"})
  13. add_configs("wdmks", {description = "Enable support for WDMKS", default = true, type = "boolean"})
  14. add_configs("wdmks_devcie_info", {description = "Use WDM/KS API for device info", default = true, type = "boolean"})
  15. elseif is_plat("linux") then
  16. add_configs("alsa", {description = "Enable support for ALSA", default = true, type = "boolean"})
  17. add_configs("alsa_dynamic", {description = "Enable dynamically loading libasound with dlopen using PaAlsa_SetLibraryPathName", default = false, type = "boolean"})
  18. end
  19. if is_plat("windows", "mingw") then
  20. add_syslinks("user32", "winmm", "advapi32", "ole32", "setupapi")
  21. elseif is_plat("macosx") then
  22. add_frameworks("CoreFoundation", "CoreAudio", "AudioToolbox", "AudioUnit", "CoreServices")
  23. elseif is_plat("linux", "bsd") then
  24. add_syslinks("pthread")
  25. end
  26. add_deps("cmake")
  27. on_load(function (package)
  28. if package:config("alsa") then
  29. package:add("deps", "alsa-lib")
  30. package:add("defines", "PA_USE_ALSA=1")
  31. end
  32. if package:config("asio") then
  33. package:add("defines", "PA_USE_ASIO=1")
  34. end
  35. if package:config("direct_sound") then
  36. package:add("defines", "PA_USE_DS=1")
  37. end
  38. if package:config("wmme") then
  39. package:add("defines", "PA_USE_WMME=1")
  40. end
  41. if package:config("wasapi") then
  42. package:add("defines", "PA_USE_WASAPI=1")
  43. end
  44. if package:config("wdmks") then
  45. package:add("defines", "PA_USE_WDMKS=1")
  46. end
  47. end)
  48. on_install("!iphoneos", function (package)
  49. io.replace("CMakeLists.txt", [["${ALSA_LIBRARIES}"]], "ALSA::ALSA", {plain = true})
  50. local configs = {
  51. "-DPA_BUILD_TESTS=OFF",
  52. "-DPA_BUILD_EXAMPLES=OFF",
  53. "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW",
  54. }
  55. if package:is_debug() then
  56. table.insert(configs, "-DCMAKE_BUILD_TYPE=Debug")
  57. table.insert(configs, "-DPA_ENABLE_DEBUG_OUTPUT=ON")
  58. else
  59. table.insert(configs, "-DCMAKE_BUILD_TYPE=Release")
  60. table.insert(configs, "-DPA_ENABLE_DEBUG_OUTPUT=OFF")
  61. end
  62. table.insert(configs, "-DPA_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  63. table.insert(configs, "-DPA_USE_SKELETON=" .. (package:config("skeleton") and "ON" or "OFF"))
  64. table.insert(configs, "-DPA_USE_ASIO=" .. (package:config("asio") and "ON" or "OFF"))
  65. if package:is_plat("windows") then
  66. table.insert(configs, "-DPA_DLL_LINK_WITH_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  67. table.insert(configs, "-DPA_USE_DS=" .. (package:config("direct_sound") and "ON" or "OFF"))
  68. table.insert(configs, "-DPA_USE_WMME=" .. (package:config("wmme") and "ON" or "OFF"))
  69. table.insert(configs, "-DPA_USE_WASAPI=" .. (package:config("wasapi") and "ON" or "OFF"))
  70. table.insert(configs, "-DPA_USE_WDMKS=" .. (package:config("wdmks") and "ON" or "OFF"))
  71. table.insert(configs, "-DPA_USE_WDMKS_DEVICE_INFO=" .. (package:config("wdmks_devcie_info") and "ON" or "OFF"))
  72. elseif package:is_plat("linux") then
  73. table.insert(configs, "-DPA_USE_ALSA=" .. (package:config("alsa") and "ON" or "OFF"))
  74. table.insert(configs, "-DPA_ALSA_DYNAMIC=" .. (package:config("alsa_dynamic") and "ON" or "OFF"))
  75. end
  76. import("package.tools.cmake").install(package, configs)
  77. end)
  78. on_test(function (package)
  79. assert(package:has_cfuncs("Pa_Initialize", {includes = "portaudio.h"}))
  80. end)