xmake.lua 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package("soxr")
  2. set_homepage("https://sourceforge.net/projects/soxr")
  3. set_description("The SoX Resampler library libsoxr performs fast, high-quality one-dimensional sample rate conversion.")
  4. set_license("LGPL-2.1")
  5. add_urls("https://downloads.sourceforge.net/project/soxr/soxr-$(version)-Source.tar.xz",
  6. "https://deac-fra.dl.sourceforge.net/project/soxr/soxr-$(version)-Source.tar.xz",
  7. "https://deac-riga.dl.sourceforge.net/project/soxr/soxr-$(version)-Source.tar.xz", {alias = "sourceforge"})
  8. add_urls("https://sourceforge.net/code-snapshots/git/s/so/soxr/code.git/soxr-code-$(version).zip", {alias = "snapshot", version = function (version)
  9. local versions = {
  10. ["0.1.3"] = "945b592b70470e29f917f4de89b4281fbbd540c0"
  11. }
  12. return versions[tostring(version)]
  13. end})
  14. add_versions("snapshot:0.1.3", "b797a5d23078be234e520af1041b5e11b49864696d56f0d0b022a0349d1e8d1b")
  15. add_versions("sourceforge:0.1.3", "b111c15fdc8c029989330ff559184198c161100a59312f5dc19ddeb9b5a15889")
  16. add_configs("openmp", {description = "Include OpenMP threading.", default = false, type = "boolean"})
  17. add_configs("lsr", {description = "Include a `libsamplerate'-like interface.", default = true, type = "boolean"})
  18. if is_plat("mingw") and is_subhost("macosx") then
  19. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  20. end
  21. add_deps("cmake")
  22. if is_plat("linux", "bsd") then
  23. add_syslinks("m")
  24. end
  25. on_load(function (package)
  26. if package:config("openmp") then
  27. package:add("deps", "openmp")
  28. end
  29. if package:is_plat("windows") and package:config("shared") then
  30. package:add("defines", "SOXR_DLL")
  31. end
  32. if package:is_plat("mingw") and not package:config("shared") then
  33. package:add("defines", "SOXR_DLL")
  34. package:add("defines", "soxr_EXPORTS")
  35. if package:config("lsr") then
  36. package:add("defines", "soxr_lsr_EXPORTS")
  37. end
  38. end
  39. end)
  40. on_install(function (package)
  41. local configs = {
  42. "-DBUILD_TESTS=OFF", "-DBUILD_EXAMPLES=OFF"
  43. }
  44. -- support for ndk >= r27 https://github.com/android/ndk/issues/2032
  45. table.insert(configs, "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW")
  46. -- Disable SIMD based resample engines for Apple Silicon and iOS ARMv8 architecture
  47. if package:is_plat("macosx", "iphoneos") and package:is_arch("arm.*") then
  48. table.insert(configs, "-DWITH_CR32S=OFF")
  49. table.insert(configs, "-DWITH_CR64S=OFF")
  50. end
  51. table.insert(configs, "-DWITH_OPENMP=" .. (package:config("openmp") and "ON" or "OFF"))
  52. table.insert(configs, "-DWITH_LSR_BINDINGS=" .. (package:config("lsr") and "ON" or "OFF"))
  53. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  54. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  55. import("package.tools.cmake").install(package, configs)
  56. end)
  57. on_test(function (package)
  58. assert(package:check_csnippets({test = [[
  59. #include <soxr.h>
  60. #include <stdio.h>
  61. void test() {
  62. printf("soxr version: %s\n", soxr_version());
  63. }
  64. ]]}, {configs = {languages = "c11"}}))
  65. if package:config("lsr") then
  66. assert(package:check_csnippets({test = [[
  67. #include <soxr-lsr.h>
  68. #include <stdio.h>
  69. void test() {
  70. printf("soxr-lsr version: %s\n", src_get_version());
  71. }
  72. ]]}, {configs = {languages = "c11"}}))
  73. end
  74. end)