xmake.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. if is_plat("linux") then
  15. add_configs("numa", {description = "Enable libnuma", default = false, type = "boolean"})
  16. end
  17. add_deps("cmake")
  18. if is_plat("wasm") then
  19. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  20. else
  21. add_deps("nasm >=2.13")
  22. end
  23. if is_plat("macosx") then
  24. add_syslinks("c++")
  25. elseif is_plat("linux", "bsd") then
  26. add_syslinks("pthread", "dl")
  27. end
  28. on_install("windows|x86", "windows|x64", "mingw", "linux", "bsd", "macosx", "wasm", "cross", function (package)
  29. os.cd("source")
  30. if package:is_plat("android") then
  31. io.replace("CMakeLists.txt", "list(APPEND PLATFORM_LIBS pthread)", "", { plain = true })
  32. end
  33. if package:is_plat("wasm") then
  34. io.replace("CMakeLists.txt", "X86 AND NOT X64", "FALSE")
  35. end
  36. local configs = {}
  37. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  38. table.insert(configs, "-DENABLE_HDR10_PLUS=" .. (package:config("hdr10_plus") and "ON" or "OFF"))
  39. table.insert(configs, "-DENABLE_SVT_HEVC=" .. (package:config("svt_hevc") and "ON" or "OFF"))
  40. table.insert(configs, "-DENABLE_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  41. if package:config("numa") then
  42. table.insert(configs, "-DENABLE_LIBNUMA=ON")
  43. package:add("syslinks", "numa")
  44. else
  45. table.insert(configs, "-DENABLE_LIBNUMA=OFF")
  46. end
  47. if package:is_cross() and package:is_targetarch("arm.*") then
  48. table.insert(configs, "-DCROSS_COMPILE_ARM=ON")
  49. if not package:is_plat("android") then
  50. table.insert(configs, "-DCMAKE_SYSTEM_PROCESSOR=" .. (package:is_targetarch("aarch64", "arm64") and "aarch64" or "armv6l"))
  51. table.insert(configs, "-DCMAKE_SIZEOF_VOID_P=" .. (package:is_targetarch("aarch64", "arm64") and "8" or "4"))
  52. end
  53. end
  54. if package:version() then
  55. table.insert(configs, "-DX265_LATEST_TAG=" .. package:version():rawstr())
  56. end
  57. import("package.tools.cmake").install(package, configs)
  58. if package:is_plat("windows") then -- fix x265.pc
  59. io.replace(path.join(package:installdir("lib", "pkgconfig"), "x265.pc"), "-lx265", "-lx265-static", {plain = true})
  60. end
  61. end)
  62. on_test(function (package)
  63. assert(package:has_cfuncs("x265_api_get", {includes = "x265.h"}))
  64. end)