xmake.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package("libsvtav1")
  2. set_homepage("https://gitlab.com/AOMediaCodec/SVT-AV1")
  3. set_description("An AV1-compliant software encoder/decoder library")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/$(version)/SVT-AV1-$(version).tar.gz",
  6. "https://gitlab.com/AOMediaCodec/SVT-AV1.git")
  7. add_versions("v2.1.0", "72a076807544f3b269518ab11656f77358284da7782cece497781ab64ed4cb8a")
  8. add_configs("encoder", {description = "Enable encoder", default = true, type = "boolean"})
  9. add_configs("decoder", {description = "Enable decoder", default = true, type = "boolean"})
  10. add_configs("minimal_build", {description = "Enable minimal build", default = false, type = "boolean"})
  11. if is_plat("mingw") and is_subhost("msys") then
  12. add_extsources("pacman::svt-av1")
  13. elseif is_plat("linux") then
  14. add_extsources("pacman::svt-av1", "apt::libsvtav1-dev")
  15. elseif is_plat("macosx") then
  16. add_extsources("brew::svt-av1")
  17. end
  18. if is_plat("linux", "bsd") then
  19. add_syslinks("pthread", "dl", "m")
  20. end
  21. add_deps("cmake", "nasm")
  22. add_deps("cpuinfo")
  23. on_install("!cross and !windows@arm.*", function (package)
  24. if package:is_plat("windows") and package:config("shared") then
  25. package:add("defines", "EB_DLL")
  26. end
  27. local configs = {"-DBUILD_TESTING=OFF", "-DBUILD_APPS=OFF", "-DUSE_EXTERNAL_CPUINFO=ON"}
  28. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  29. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  30. table.insert(configs, "-DSVT_AV1_LTO=" .. (package:config("lto") and "ON" or "OFF"))
  31. table.insert(configs, "-DBUILD_ENC=" .. (package:config("encoder") and "ON" or "OFF"))
  32. table.insert(configs, "-DBUILD_DEC=" .. (package:config("decoder") and "ON" or "OFF"))
  33. table.insert(configs, "-DMINIMAL_BUILD=" .. (package:config("minimal_build") and "ON" or "OFF"))
  34. import("package.tools.cmake").install(package, configs)
  35. end)
  36. on_test(function (package)
  37. if package:config("encoder") then
  38. assert(package:has_cfuncs("svt_av1_enc_init_handle", {includes = {"stddef.h", "svt-av1/EbSvtAv1Enc.h"}}))
  39. end
  40. if package:config("decoder") then
  41. assert(package:has_cfuncs("svt_av1_dec_init_handle", {includes = {"stddef.h", "svt-av1/EbSvtAv1Dec.h"}}))
  42. end
  43. end)