From 1651d94eab5818db154f5dd91b76ac7ff3c162f8 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 9 Apr 2024 22:03:17 +0800 Subject: [PATCH] Auto-update openh264 to v2.4.1 (#3489) * Update openh264 to v2.4.1 * improve meson * windows support arm --------- Co-authored-by: star9029 --- packages/o/openh264/xmake.lua | 56 +++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/packages/o/openh264/xmake.lua b/packages/o/openh264/xmake.lua index c30e281d4..880758649 100644 --- a/packages/o/openh264/xmake.lua +++ b/packages/o/openh264/xmake.lua @@ -1,28 +1,58 @@ package("openh264") - set_homepage("http://www.openh264.org/") set_description("OpenH264 is a codec library which supports H.264 encoding and decoding.") set_license("BSD-2-Clause") - add_urls("https://github.com/cisco/openh264/archive/refs/tags/$(version).tar.gz") + set_urls("https://github.com/cisco/openh264/archive/refs/tags/$(version).tar.gz", + "https://github.com/cisco/openh264.git") + + add_versions("v2.4.1", "8ffbe944e74043d0d3fb53d4a2a14c94de71f58dbea6a06d0dc92369542958ea") add_versions("v2.1.1", "af173e90fce65f80722fa894e1af0d6b07572292e76de7b65273df4c0a8be678") - add_deps("meson", "ninja", "nasm") if is_plat("linux") then add_syslinks("pthread", "rt") end + + add_deps("meson", "ninja", "nasm") + + on_load("windows", function (package) + if package:is_plat("windows") and package:is_arch("arm.*") and (not package:is_precompiled()) then + package:add("deps", "strawberry-perl") + end + end) + on_install("windows", "linux", function (package) - import("package.tools.meson").build(package, {"-Dtests=disabled"}, {buildir = "out"}) - import("package.tools.ninja").install(package, {}, {buildir = "out"}) - if package:config("shared") then - os.tryrm(path.join(package:installdir("lib"), "libopenh264.a")) + if package:version():ge("2.4.1") then + import("package.tools.meson") + + local opt = {} + opt.envs = meson.buildenvs(package) + -- add gas-preprocessor to PATH + if package:is_plat("windows") and package:is_arch("arm.*") then + opt.envs.PATH = path.join(os.programdir(), "scripts") .. path.envsep() .. opt.envs.PATH + end + + if package:is_plat("linux") and package:has_tool("cc", "clang", "clangxx") then + opt.ldflags = "-lstdc++" + opt.shflags = "-lstdc++" + end + + local configs = {"-Dtests=disabled"} + table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static")) + meson.install(package, configs, opt) else - os.tryrm(path.join(package:installdir("lib"), "libopenh264.so*")) - os.tryrm(path.join(package:installdir("lib"), "openh264.lib")) - os.tryrm(path.join(package:installdir("bin"), "openh264-*.dll")) - end - if package:is_plat("windows") then - os.trymv(path.join(package:installdir("lib"), "libopenh264.a"), path.join(package:installdir("lib"), "openh264.lib")) + import("package.tools.meson").build(package, {"-Dtests=disabled"}, {buildir = "out"}) + import("package.tools.ninja").install(package, {}, {buildir = "out"}) + if package:config("shared") then + os.tryrm(path.join(package:installdir("lib"), "libopenh264.a")) + else + os.tryrm(path.join(package:installdir("lib"), "libopenh264.so*")) + os.tryrm(path.join(package:installdir("lib"), "openh264.lib")) + os.tryrm(path.join(package:installdir("bin"), "openh264-*.dll")) + end + if package:is_plat("windows") then + os.trymv(path.join(package:installdir("lib"), "libopenh264.a"), path.join(package:installdir("lib"), "openh264.lib")) + end end end)