Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x265: add 4.0 version #5458

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 81 additions & 27 deletions packages/x/x265/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,124 @@ package("x265")
set_description("A free software library and application for encoding video streams into the H.265/MPEG-H HEVC compression format.")
set_license("GPL-2.0")

add_urls("https://github.com/videolan/x265/archive/$(version).tar.gz",
"https://github.com/videolan/x265.git",
add_urls("https://github.com/videolan/x265.git",
"https://bitbucket.org/multicoreware/x265_git")

add_versions("3.2", "4dd707648ea90b96bf1f8ea6a36ed21c11fe3a9048923909c5b629755ca8d8f3")
add_versions("3.2.1", "b5ee7ea796a664d6e2763f9c0ae281fac5d25892fc2cb134698547103466a06a")
add_versions("3.3", "ca25a38772fc6b49e5f1aa88733bc1dc92da7dc18f02a85cc3e99d76ba85b0a9")
add_versions("3.4", "544d147bf146f8994a7bf8521ed878c93067ea1c7c6e93ab602389be3117eaaf")
add_urls("https://github.com/videolan/x265/archive/refs/tags/$(version).tar.gz", {alias = "github"})
add_urls("https://bitbucket.org/multicoreware/x265_git/downloads/x265_$(version).tar.gz", {alias = "bitbucket"})

add_versions("bitbucket:4.0", "75b4d05629e365913de3100b38a459b04e2a217a8f30efaa91b572d8e6d71282")

add_versions("github:3.4", "544d147bf146f8994a7bf8521ed878c93067ea1c7c6e93ab602389be3117eaaf")
add_versions("github:3.3", "ca25a38772fc6b49e5f1aa88733bc1dc92da7dc18f02a85cc3e99d76ba85b0a9")
add_versions("github:3.2.1", "b5ee7ea796a664d6e2763f9c0ae281fac5d25892fc2cb134698547103466a06a")
add_versions("github:3.2", "4dd707648ea90b96bf1f8ea6a36ed21c11fe3a9048923909c5b629755ca8d8f3")

add_configs("hdr10_plus", {description = "Enable dynamic HDR10 compilation", default = false, type = "boolean"})
add_configs("svt_hevc", {description = "Enable SVT HEVC Encoder", default = false, type = "boolean"})
add_configs("high_bit_depth", {description = "Store pixel samples as 16bit values (Main10/Main12)", default = false, type = "boolean"})
add_configs("main12", {description = "Support Main12 instead of Main10", default = false, type = "boolean"})
if is_plat("linux") then
add_configs("numa", {description = "Enable libnuma", default = false, type = "boolean"})
end

add_deps("cmake")
if is_plat("wasm") then
elseif is_plat("wasm") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
else
add_deps("nasm >=2.13")
end
add_configs("tools", {description = "Build tools", default = false, type = "boolean"})

if is_plat("macosx") then
add_syslinks("c++")
elseif is_plat("linux", "bsd") then
add_syslinks("pthread", "dl")
end

on_install("windows|x86", "windows|x64", "mingw", "linux", "bsd", "macosx", "wasm", "cross", function (package)
add_deps("cmake", "nasm >=2.13")

if on_check then
on_check("cross", function (package)
if package:version():ge("4.0") then
raise("package(x265 >=4.0) unsupported cross pltform")
end
end)
end

on_install(function (package)
os.cd("source")
-- Let xmake cp pdb
io.replace("CMakeLists.txt", "if((WIN32 AND ENABLE_CLI) OR (WIN32 AND ENABLE_SHARED))", "if(0)", {plain = true})

if package:is_plat("android") then
io.replace("CMakeLists.txt", "list(APPEND PLATFORM_LIBS pthread)", "", { plain = true })
end
if package:is_plat("wasm") then
io.replace("CMakeLists.txt", "X86 AND NOT X64", "FALSE")
io.replace("CMakeLists.txt", "list(APPEND PLATFORM_LIBS pthread)", "", {plain = true})
elseif package:is_plat("wasm") then
io.replace("CMakeLists.txt", "X86 AND NOT X64", "FALSE", {plain = true})
end

local configs = {}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DCHECKED_BUILD=" .. (package:is_debug() and "ON" or "OFF"))
table.insert(configs, "-DENABLE_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DENABLE_PIC=" .. (package:config("pic") and "ON" or "OFF"))

table.insert(configs, "-DENABLE_HDR10_PLUS=" .. (package:config("hdr10_plus") and "ON" or "OFF"))
table.insert(configs, "-DENABLE_SVT_HEVC=" .. (package:config("svt_hevc") and "ON" or "OFF"))
table.insert(configs, "-DENABLE_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DHIGH_BIT_DEPTH=" .. (package:config("high_bit_depth") and "ON" or "OFF"))
table.insert(configs, "-DMAIN12=" .. (package:config("main12") and "ON" or "OFF"))
table.insert(configs, "-DENABLE_CLI=" .. (package:config("tools") and "ON" or "OFF"))
table.insert(configs, "-DNATIVE_BUILD=" .. (package:is_cross() and "OFF" or "ON"))

if package:config("numa") then
table.insert(configs, "-DENABLE_LIBNUMA=ON")
package:add("syslinks", "numa")
else
table.insert(configs, "-DENABLE_LIBNUMA=OFF")
end
if package:version() then
table.insert(configs, "-DX265_LATEST_TAG=" .. package:version():rawstr())
end

if (package:is_plat("windows") and package:is_arch("arm.*"))
or package:is_plat("android", "iphoneos", "wasm") then
table.insert(configs, "-DENABLE_ASSEMBLY=OFF")
end

if package:is_cross() and package:is_targetarch("arm.*") then
table.insert(configs, "-DCROSS_COMPILE_ARM=ON")
if not package:is_plat("android") then
table.insert(configs, "-DCMAKE_SYSTEM_PROCESSOR=" .. (package:is_targetarch("aarch64", "arm64") and "aarch64" or "armv6l"))
table.insert(configs, "-DCMAKE_SIZEOF_VOID_P=" .. (package:is_targetarch("aarch64", "arm64") and "8" or "4"))
if package:is_arch64() then
table.insert(configs, "-DCROSS_COMPILE_ARM64=ON")
else
table.insert(configs, "-DCROSS_COMPILE_ARM=ON")
end
end
if package:version() then
table.insert(configs, "-DX265_LATEST_TAG=" .. package:version():rawstr())

if package:is_plat("windows") then
table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
end

local opt = {}
if package:gitref() or package:version():ge("4.0") then
if package:is_plat("wasm") then
opt.cxflags = "-pthread"
package:add("ldflags", "-s USE_PTHREADS=1")
end
end
import("package.tools.cmake").install(package, configs, opt)

if package:is_plat("windows") then
if package:config("shared") then
os.tryrm(package:installdir("lib/x265-static.lib"))
end
-- Error links, switch to xmake pc file
os.rm(package:installdir("lib/pkgconfig/x265.pc"))

import("package.tools.cmake").install(package, configs)
if package:is_plat("windows") then -- fix x265.pc
io.replace(path.join(package:installdir("lib", "pkgconfig"), "x265.pc"), "-lx265", "-lx265-static", {plain = true})
if package:is_debug() then
local dir = package:installdir(package:config("shared") and "bin" or "lib")
os.trycp(path.join(package:buildir(), "libx265.pdb"), dir)
if package:config("tools") then
os.trycp(path.join(package:buildir(), "x265.pdb"), package:installdir("bin"))
end
end
else
if package:config("shared") then
os.rm(package:installdir("lib/libx265.a"))
end
end
end)

Expand Down
Loading