xmake.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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://salsa.debian.org/multimedia-team/libsoxr/-/archive/upstream/$(version)/libsoxr-upstream-$(version).zip")
  6. add_versions("0.1.3", "b755c59aa3eebeb7fb5591fc606bf56f4214d86d3668886ac6df48d3a9552817")
  7. add_configs("openmp", {description = "Include OpenMP threading.", default = false, type = "boolean"})
  8. add_configs("lsr", {description = "Include a `libsamplerate'-like interface.", default = true, type = "boolean"})
  9. if is_plat("mingw") and is_subhost("macosx") then
  10. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  11. elseif is_plat("linux") and is_arch("arm64") then
  12. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  13. end
  14. add_deps("cmake")
  15. if is_plat("linux", "bsd") then
  16. add_syslinks("m")
  17. end
  18. on_load(function (package)
  19. if package:config("lsr") then
  20. package:add("links", "soxr-lsr", "soxr")
  21. end
  22. if package:config("openmp") then
  23. package:add("deps", "openmp")
  24. end
  25. if package:is_plat("windows") and package:config("shared") then
  26. package:add("defines", "SOXR_DLL")
  27. end
  28. if package:is_plat("mingw") and not package:config("shared") then
  29. package:add("defines", "SOXR_DLL")
  30. package:add("defines", "soxr_EXPORTS")
  31. if package:config("lsr") then
  32. package:add("defines", "soxr_lsr_EXPORTS")
  33. end
  34. end
  35. end)
  36. on_install(function (package)
  37. local configs = {
  38. "-DBUILD_TESTS=OFF", "-DBUILD_EXAMPLES=OFF"
  39. }
  40. -- support for ndk >= r27 https://github.com/android/ndk/issues/2032
  41. table.insert(configs, "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW")
  42. -- Disable SIMD based resample engines for Apple Silicon and iOS ARMv8 architecture
  43. if package:is_plat("macosx", "iphoneos") and package:is_arch("arm.*") then
  44. table.insert(configs, "-DWITH_CR32S=OFF")
  45. table.insert(configs, "-DWITH_CR64S=OFF")
  46. end
  47. table.insert(configs, "-DWITH_OPENMP=" .. (package:config("openmp") and "ON" or "OFF"))
  48. table.insert(configs, "-DWITH_LSR_BINDINGS=" .. (package:config("lsr") and "ON" or "OFF"))
  49. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  50. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  51. import("package.tools.cmake").install(package, configs)
  52. end)
  53. on_test(function (package)
  54. assert(package:check_csnippets({test = [[
  55. #include <soxr.h>
  56. #include <stdio.h>
  57. void test() {
  58. printf("soxr version: %s\n", soxr_version());
  59. }
  60. ]]}, {configs = {languages = "c11"}}))
  61. if package:config("lsr") then
  62. assert(package:check_csnippets({test = [[
  63. #include <soxr-lsr.h>
  64. #include <stdio.h>
  65. void test() {
  66. printf("soxr-lsr version: %s\n", src_get_version());
  67. }
  68. ]]}, {configs = {languages = "c11"}}))
  69. end
  70. end)