xmake.lua 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. if is_plat("windows", "macosx") then
  9. add_patches("v2.3.3", path.join(os.scriptdir(), "patches", "find-intl.patch"), "dafdb8f11957ed2f396832fe3b63933e8a32b96d8c836166b2fefacf3f918a9d")
  10. end
  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. end
  21. add_configs("readline", {description = "Compile support for sound file output", default = false, type = "boolean"})
  22. add_configs("threads", {description = "Enable multi-threading support (such as parallel voice synthesis)", default = true, type = "boolean"})
  23. add_configs("openmp", {description = "Enable OpenMP support (parallelization of soundfont decoding, vectorization of voice mixing, etc.)", default = false, type = "boolean"})
  24. if is_plat("macosx") then
  25. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  26. end
  27. add_deps("cmake")
  28. add_deps("glib")
  29. add_deps("libiconv")
  30. if is_plat("windows") then
  31. add_deps("libintl")
  32. add_deps("pkgconf")
  33. add_syslinks("ws2_32")
  34. elseif is_plat("linux") then
  35. add_deps("pkg-config")
  36. else
  37. add_deps("libintl")
  38. add_deps("pkg-config")
  39. end
  40. on_load(function (package)
  41. local configdeps = {
  42. dbus = "dbus",
  43. libsndfile = "libsndfile",
  44. openmp = "openmp",
  45. readline = "readline",
  46. sdl2 = "libsdl"
  47. }
  48. for config, info in pairs(configdeps) do
  49. if package:config(config) then
  50. package:add("deps", info)
  51. end
  52. end
  53. if package:config("opensles") then
  54. package:add("links", "OpenSLES")
  55. end
  56. end)
  57. on_install("windows", "linux", "macosx", function (package)
  58. local configs = {}
  59. local configopts = {
  60. "aufile", "dbus", "jack", "libsndfile", "opensles", "network", "sdl2", "readline", "pulseaudio", "threads", "openmp"
  61. }
  62. for _, config in ipairs(configopts) do
  63. table.insert(configs, "-Denable-" .. config .. "=" .. (package:config(config) and "ON" or "OFF"))
  64. end
  65. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  66. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  67. import("package.tools.cmake").install(package)
  68. if package:is_plat("macosx") then
  69. local headersdir = package:installdir("Library/Frameworks/FluidSynth.framework/Headers")
  70. os.cp(path.join(headersdir, "**.h"), package:installdir("include"), {rootdir = headersdir})
  71. os.cp(path.join(package:installdir("Library/Frameworks/FluidSynth.framework"), "FluidSynth"),
  72. path.join(package:installdir("lib"), "libFluidSynth.dylib"))
  73. end
  74. end)
  75. on_test(function (package)
  76. assert(package:check_cxxsnippets({test = [[
  77. void test() {
  78. fluid_settings_t* settings = new_fluid_settings();
  79. fluid_synth_t* synth = new_fluid_synth(settings);
  80. delete_fluid_synth(synth);
  81. delete_fluid_settings(settings);
  82. }
  83. ]]}, {includes = "fluidsynth.h"}))
  84. end)