xmake.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package("x265")
  2. set_homepage("http://x265.org")
  3. set_description("A free software library and application for encoding video streams into the H.265/MPEG-H HEVC compression format.")
  4. set_license("GPL-2.0")
  5. add_urls("https://github.com/videolan/x265/archive/$(version).tar.gz",
  6. "https://github.com/videolan/x265.git",
  7. "https://bitbucket.org/multicoreware/x265_git")
  8. add_versions("3.2", "4dd707648ea90b96bf1f8ea6a36ed21c11fe3a9048923909c5b629755ca8d8f3")
  9. add_versions("3.2.1", "b5ee7ea796a664d6e2763f9c0ae281fac5d25892fc2cb134698547103466a06a")
  10. add_versions("3.3", "ca25a38772fc6b49e5f1aa88733bc1dc92da7dc18f02a85cc3e99d76ba85b0a9")
  11. add_versions("3.4", "544d147bf146f8994a7bf8521ed878c93067ea1c7c6e93ab602389be3117eaaf")
  12. add_configs("hdr10_plus", {description = "Enable dynamic HDR10 compilation", default = false, type = "boolean"})
  13. add_configs("svt_hevc", {description = "Enable SVT HEVC Encoder", default = false, type = "boolean"})
  14. add_deps("cmake")
  15. if is_plat("wasm") then
  16. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  17. else
  18. add_deps("nasm >=2.13")
  19. end
  20. if is_plat("macosx") then
  21. add_syslinks("c++")
  22. elseif is_plat("linux", "bsd") then
  23. add_syslinks("pthread", "dl")
  24. end
  25. on_install("windows|x86", "windows|x64", "mingw", "linux", "bsd", "macosx", "wasm", "cross", function (package)
  26. os.cd("source")
  27. if package:is_plat("android") then
  28. io.replace("CMakeLists.txt", "list(APPEND PLATFORM_LIBS pthread)", "", { plain = true })
  29. end
  30. if package:is_plat("wasm") then
  31. io.replace("CMakeLists.txt", "X86 AND NOT X64", "FALSE")
  32. end
  33. local configs = {}
  34. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  35. table.insert(configs, "-DENABLE_HDR10_PLUS=" .. (package:config("hdr10_plus") and "ON" or "OFF"))
  36. table.insert(configs, "-DENABLE_SVT_HEVC=" .. (package:config("svt_hevc") and "ON" or "OFF"))
  37. table.insert(configs, "-DENABLE_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  38. if package:is_cross() and package:is_targetarch("arm.*") then
  39. table.insert(configs, "-DCROSS_COMPILE_ARM=ON")
  40. if not package:is_plat("android") then
  41. table.insert(configs, "-DCMAKE_SYSTEM_PROCESSOR=" .. (package:is_targetarch("aarch64", "arm64") and "aarch64" or "armv6l"))
  42. table.insert(configs, "-DCMAKE_SIZEOF_VOID_P=" .. (package:is_targetarch("aarch64", "arm64") and "8" or "4"))
  43. end
  44. end
  45. if package:version() then
  46. table.insert(configs, "-DX265_LATEST_TAG=" .. package:version():rawstr())
  47. end
  48. table.insert(configs, "--trace")
  49. import("package.tools.cmake").install(package, configs)
  50. end)
  51. on_test(function (package)
  52. assert(package:has_cfuncs("x265_api_get", {includes = "x265.h"}))
  53. end)