xmake.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package("steam-audio")
  2. set_homepage("https://valvesoftware.github.io/steam-audio/")
  3. set_description("Valve's steam audio library")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/ValveSoftware/steam-audio/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/ValveSoftware/steam-audio.git")
  7. add_versions("v4.6.1", "9965993d9df46d0585bd1dcb0acd3c5ae031656c75c87bbd49429db37757b65d")
  8. add_versions("v4.6.0", "b81479bf8fc55c3bbd49c1f9eb1356d7ff7a3a5efc553ba6653ed41715aaf368")
  9. add_configs("fft", {description = "Choice fft library", default = "pffft", type = "string", values = {"ipp", "ffts", "pffft"}})
  10. add_configs("mkl", {description = "Enable Intel MKL support for linear algebra operations.", default = false, type = "boolean"})
  11. add_configs("embree", {description = "Enable Intel Embree support for ray tracing.", default = false, type = "boolean"})
  12. add_configs("radeonrays", {description = "Enable AMD Radeon Rays support for GPU-accelerated ray tracing.", default = false, type = "boolean"})
  13. add_configs("trueaudio_next", {description = "Enable AMD TrueAudio Next support for GPU-accelerated convolution.", default = false, type = "boolean", readonly = true})
  14. add_configs("abi", {description = "Apply some unsafe patch for linux and macos build, maybe abi break", default = true, type = "boolean"})
  15. add_deps("cmake")
  16. add_deps("libmysofa", "flatbuffers")
  17. if is_plat("windows") then
  18. add_syslinks("delayimp")
  19. elseif is_plat("linux") then
  20. add_syslinks("m", "dl", "pthread")
  21. elseif is_plat("android") then
  22. add_syslinks("log", "android")
  23. end
  24. on_load(function (package)
  25. package:add("deps", package:config("fft"))
  26. if package:config("mkl") then
  27. package:add("deps", "mkl")
  28. end
  29. if package:config("embree") then
  30. package:add("deps", "ispc", "embree")
  31. end
  32. if package:config("radeonrays") then
  33. package:add("deps", "python 3.x", {kind = "binary"})
  34. package:add("deps", "radeonrays")
  35. end
  36. if package:is_cross() then
  37. package:add("deps", "flatbuffers~host", {kind = "binary", private = true})
  38. end
  39. end)
  40. on_install("!bsd and !mingw and !cross", function (package)
  41. os.cd("core")
  42. import("patch")(package)
  43. local configs = {
  44. "-DSTEAMAUDIO_BUILD_TESTS=OFF",
  45. "-DSTEAMAUDIO_BUILD_BENCHMARKS=OFF",
  46. "-DSTEAMAUDIO_BUILD_SAMPLES=OFF",
  47. "-DSTEAMAUDIO_BUILD_ITESTS=OFF",
  48. "-DSTEAMAUDIO_BUILD_DOCS=OFF",
  49. }
  50. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  51. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  52. local fft = package:config("fft")
  53. table.insert(configs, "-DSTEAMAUDIO_ENABLE_IPP=" .. (fft == "ipp" and "ON" or "OFF"))
  54. table.insert(configs, "-DSTEAMAUDIO_ENABLE_FFTS=" .. (fft == "ffts" and "ON" or "OFF"))
  55. table.insert(configs, "-DSTEAMAUDIO_ENABLE_MKL=" .. (package:config("mkl") and "ON" or "OFF"))
  56. table.insert(configs, "-DSTEAMAUDIO_ENABLE_EMBREE=" .. (package:config("embree") and "ON" or "OFF"))
  57. table.insert(configs, "-DSTEAMAUDIO_ENABLE_RADEONRAYS=" .. (package:config("radeonrays") and "ON" or "OFF"))
  58. table.insert(configs, "-DSTEAMAUDIO_ENABLE_TRUEAUDIONEXT=" .. (package:config("trueaudio_next") and "ON" or "OFF"))
  59. import("package.tools.cmake").install(package, configs)
  60. os.mv(package:installdir("lib/*.dll"), package:installdir("bin"))
  61. if package:is_plat("windows") and package:config("shared") then
  62. local phonon_h = path.join(package:installdir("include"), "phonon.h")
  63. io.replace(phonon_h, "#define IPLAPI\n#endif", "#define IPLAPI __declspec(dllimport)\n#endif", {plain = true})
  64. end
  65. end)
  66. on_test(function (package)
  67. assert(package:check_cxxsnippets({test = [[
  68. void test() {
  69. IPLContextSettings contextSettings{};
  70. contextSettings.version = STEAMAUDIO_VERSION;
  71. IPLContext context = nullptr;
  72. iplContextCreate(&contextSettings, &context);
  73. }
  74. ]]}, {configs = {languages = "c++14"}, includes = "phonon.h"}))
  75. end)