xmake.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package("libopus")
  2. set_homepage("https://opus-codec.org")
  3. set_description("Modern audio compression for the internet.")
  4. set_urls("https://gitlab.xiph.org/xiph/opus/-/archive/v$(version)/opus-v$(version).tar.gz",
  5. "https://gitlab.xiph.org/xiph/opus.git",
  6. "https://github.com/xiph/opus.git")
  7. add_versions("1.4", "cf7c31577c384e1dc17a6f57e8460e520d135ab9e0b9068543dd657e25e7da1f")
  8. add_versions("1.3.1", "a4ef56e2c8fce5dba63f6db1f671e3fa5b18299d953975b6636fee211ddc882a")
  9. add_patches("1.3.1", path.join(os.scriptdir(), "patches", "1.3.1", "cmake.patch"), "79fba5086d7747d0441f7f156b88e932b662e2d2ccd825279a5a396a2840d3a2")
  10. add_configs("avx", { description = "AVX supported", default = true, type = "boolean" })
  11. add_configs("check_avx", { description = "Does runtime check for AVX support", default = true, type = "boolean" })
  12. if is_plat("wasm") then
  13. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  14. end
  15. add_deps("cmake")
  16. on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", "wasm", function (package)
  17. local configs = {}
  18. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  19. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  20. table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
  21. table.insert(configs, "-DAVX_SUPPORTED=" .. (package:config("avx") and "ON" or "OFF"))
  22. table.insert(configs, "-DOPUS_X86_MAY_HAVE_AVX=" .. (package:config("check_avx") and "ON" or "OFF"))
  23. if package:is_plat("mingw", "wasm") then
  24. -- Disable stack protection on MinGW and wasm since it causes link errors
  25. table.insert(configs, "-DOPUS_STACK_PROTECTOR=OFF")
  26. elseif package:is_plat("android") then
  27. table.insert(configs, "-DOPUS_DISABLE_INTRINSICS=ON")
  28. end
  29. import("package.tools.cmake").install(package, configs)
  30. end)
  31. on_test(function (package)
  32. assert(package:has_cfuncs("opus_encoder_create", {includes = "opus/opus.h"}))
  33. end)