xmake.lua 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package("fluidsynth")
  2. set_homepage("https://www.fluidsynth.org/")
  3. set_description("FluidSynth is a real-time software synthesizer based on the SoundFont 2 specifications and has reached widespread distribution.")
  4. set_license("LGPL-2.1")
  5. add_urls("https://github.com/FluidSynth/fluidsynth/archive/refs/tags/$(version).zip",
  6. "https://github.com/FluidSynth/fluidsynth.git")
  7. add_versions("v2.3.3", "0ab6f1aae1c7652b9249de2d98070313f3083046fddd673277556f1cca65568e")
  8. add_versions("v2.3.5", "3cdaa24777f11fbc6da506d7f7b41fef31822006f83886dcf6e758a9941cae40")
  9. add_patches("v2.3.3", path.join(os.scriptdir(), "patches", "2.3.3", "find-intl.patch"), "0c80989cce85b8e69409498e3a5d1df41c1ce29bf11261bcb441fdbf08c42f85")
  10. add_patches("v2.3.5", path.join(os.scriptdir(), "patches", "2.3.5", "find-intl.patch"), "b71c50191e3799e93606b2cf79e61098bdf52d681bd3e758103d2c43c192bfc5")
  11. add_configs("aufile", {description = "Compile support for sound file output", default = true, type = "boolean"})
  12. add_configs("dbus", {description = "Compile DBUS support", default = not is_plat("windows"), type = "boolean"})
  13. add_configs("jack", {description = "Compile JACK support", default = false, type = "boolean"})
  14. add_configs("libsndfile", {description = "Compile libsndfile support", default = true, type = "boolean"})
  15. add_configs("opensles", {description = "compile OpenSLES support", default = false, type = "boolean"})
  16. add_configs("network", {description = "Enable network support (requires BSD or WIN sockets)", default = false, type = "boolean"})
  17. add_configs("sdl2", {description = "Compile SDL2 audio support ", default = false, type = "boolean"})
  18. if is_plat("linux") then
  19. add_configs("pulseaudio", {description = "Compile PulseAudio support", default = false, type = "boolean"})
  20. add_configs("systemd", {description = "Compile systemd support", default = true, type = "boolean"})
  21. end
  22. add_configs("readline", {description = "Compile support for sound file output", default = false, type = "boolean"})
  23. add_configs("threads", {description = "Enable multi-threading support (such as parallel voice synthesis)", default = true, type = "boolean"})
  24. add_configs("openmp", {description = "Enable OpenMP support (parallelization of soundfont decoding, vectorization of voice mixing, etc.)", default = false, type = "boolean"})
  25. if is_plat("macosx") then
  26. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  27. end
  28. add_deps("cmake")
  29. add_deps("glib")
  30. if is_plat("windows") then
  31. add_deps("libiconv")
  32. add_deps("pkgconf")
  33. add_syslinks("ws2_32")
  34. elseif is_plat("linux") then
  35. add_deps("libiconv")
  36. add_deps("pkg-config")
  37. elseif is_plat("macosx") then
  38. add_deps("libiconv", {system = true})
  39. add_deps("libintl")
  40. add_deps("pkg-config")
  41. end
  42. on_load(function (package)
  43. local configdeps = {
  44. dbus = "dbus",
  45. libsndfile = "libsndfile",
  46. openmp = "openmp",
  47. readline = "readline",
  48. sdl2 = "libsdl2"
  49. }
  50. for config, info in pairs(configdeps) do
  51. if package:config(config) then
  52. package:add("deps", info)
  53. end
  54. end
  55. if package:config("opensles") then
  56. package:add("links", "OpenSLES")
  57. end
  58. end)
  59. on_install("windows", "linux", "macosx", function (package)
  60. local configs = {}
  61. local configopts = {
  62. "aufile", "dbus", "jack", "libsndfile", "opensles", "network", "sdl2", "readline", "pulseaudio", "systemd", "threads", "openmp"
  63. }
  64. for _, config in ipairs(configopts) do
  65. table.insert(configs, "-Denable-" .. config .. "=" .. (package:config(config) and "ON" or "OFF"))
  66. end
  67. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  68. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  69. import("package.tools.cmake").install(package)
  70. if package:is_plat("macosx") then
  71. local headersdir = package:installdir("Library/Frameworks/FluidSynth.framework/Headers")
  72. os.cp(path.join(headersdir, "**.h"), package:installdir("include"), {rootdir = headersdir})
  73. os.cp(path.join(package:installdir("Library/Frameworks/FluidSynth.framework"), "FluidSynth"),
  74. path.join(package:installdir("lib"), "libFluidSynth.dylib"))
  75. end
  76. end)
  77. on_test(function (package)
  78. assert(package:check_cxxsnippets({test = [[
  79. void test() {
  80. fluid_settings_t* settings = new_fluid_settings();
  81. fluid_synth_t* synth = new_fluid_synth(settings);
  82. delete_fluid_synth(synth);
  83. delete_fluid_settings(settings);
  84. }
  85. ]]}, {includes = "fluidsynth.h"}))
  86. end)