Kaynağa Gözat

feat: add theora (#2323)

* feat: add theora

* fix(theora): disable lock for libtool

* fix(theora): update flags

* feat(libogg): support bsd

* feat(libopus): add version 1.4 and wasm support

* fix(theora): fix build error

* fix(theora): fix build error

* fix(theora): fix macOS build error

* fix(libopus): fix android build error

* feat(theora): add mingw support

* fix(theora): fix mingw build

* fix(libopus): fix android build error

* fix(theora): fix some typos

* fix(libvpx): fix a typo

* fix(theora): fix some typos

* feat(theora): add windows support

* fix(theora): fix windows build error

* fix(theora): fix a typo

* fix(theora): also upgrade vcproj file

* chore(theora): tweaks

* chore(theora): tweaks

* fix(theora): add msvc patch

* feat(theora): try to use xmake port

* fix(theora): fix typos

* fix(theora): fix windows build error

* fix(theora): disable asm on win64

* chore(theora): tweaks

* Update xmake.lua

* Update xmake.lua

---------

Co-authored-by: ruki <[email protected]>
冰雪殇璃陌梦 2 yıl önce
ebeveyn
işleme
c59050edf0

+ 1 - 1
packages/l/libogg/xmake.lua

@@ -21,7 +21,7 @@ package("libogg")
         add_extsources("brew::libogg")
     end
 
-    on_install("windows", "macosx", "linux", "mingw", "iphoneos", "android", "cross", "wasm", function (package)
+    on_install("windows", "macosx", "linux", "bsd", "mingw", "iphoneos", "android", "cross", "wasm", function (package)
         local configs = {"-DBUILD_TESTING=OFF"}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))

+ 14 - 6
packages/l/libopus/xmake.lua

@@ -3,27 +3,35 @@ package("libopus")
     set_homepage("https://opus-codec.org")
     set_description("Modern audio compression for the internet.")
 
-    set_urls("https://archive.mozilla.org/pub/opus/opus-$(version).tar.gz",
-             "https://gitlab.xiph.org/xiph/opus.git")
+    set_urls("https://gitlab.xiph.org/xiph/opus/-/archive/v$(version)/opus-v$(version).tar.gz",
+             "https://gitlab.xiph.org/xiph/opus.git",
+             "https://github.com/xiph/opus.git")
 
-    add_versions("1.3.1", "65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d")
+    add_versions("1.4", "cf7c31577c384e1dc17a6f57e8460e520d135ab9e0b9068543dd657e25e7da1f")
+    add_versions("1.3.1", "a4ef56e2c8fce5dba63f6db1f671e3fa5b18299d953975b6636fee211ddc882a")
     add_patches("1.3.1", path.join(os.scriptdir(), "patches", "1.3.1", "cmake.patch"), "79fba5086d7747d0441f7f156b88e932b662e2d2ccd825279a5a396a2840d3a2")
 
     add_configs("avx", { description = "AVX supported", default = true, type = "boolean" })
     add_configs("check_avx", { description = "Does runtime check for AVX support", default = true, type = "boolean" })
 
+    if is_plat("wasm") then
+        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+    end
+
     add_deps("cmake")
 
-    on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", function (package)
+    on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", "wasm", function (package)
         local configs = {}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
         table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
         table.insert(configs, "-DAVX_SUPPORTED=" .. (package:config("avx") and "ON" or "OFF"))
         table.insert(configs, "-DOPUS_X86_MAY_HAVE_AVX=" .. (package:config("check_avx") and "ON" or "OFF"))
-        if package:is_plat("mingw") then
-            -- Disable stack protection on MinGW since it causes link errors
+        if package:is_plat("mingw", "wasm") then
+            -- Disable stack protection on MinGW and wasm since it causes link errors
             table.insert(configs, "-DOPUS_STACK_PROTECTOR=OFF")
+        elseif package:is_plat("android") then
+            table.insert(configs, "-DOPUS_DISABLE_INTRINSICS=ON")
         end
         import("package.tools.cmake").install(package, configs)
     end)

+ 1 - 0
packages/l/libtool/xmake.lua

@@ -9,6 +9,7 @@ package("libtool")
              "git://git.savannah.gnu.org/libtool.git")
     add_versions("2.4.6", "e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3")
     add_versions("2.4.5", "509cb49c7de14ce7eaf88993cf09fd4071882699dfd874c2e95b31ab107d6987")
+    add_versions("2.4.7", "04e96c2404ea70c590c546eba4202a4e12722c640016c12b9b2f1ce3d481e9a8")
 
     if is_host("linux") then
         add_extsources("apt::libtool", "pacman::libtool")

+ 75 - 0
packages/t/theora/port/xmake.lua

@@ -0,0 +1,75 @@
+set_project("theora")
+set_kind("$(kind)")
+
+add_rules("mode.debug", "mode.release")
+if is_plat("windows") and is_kind("shared") then
+     add_rules("utils.symbols.export_all")
+end
+
+add_requires("libogg")
+
+add_packages("libogg")
+add_includedirs("include")
+add_headerfiles("include/(theora/*.h)")
+set_warnings("all")
+
+target("theoraenc")
+    add_files("lib/apiwrapper.c",
+              "lib/fragment.c",
+              "lib/idct.c",
+              "lib/internal.c",
+              "lib/info.c",
+              "lib/state.c",
+              "lib/quant.c",
+              "lib/analyze.c",
+              "lib/encfrag.c",
+              "lib/encapiwrapper.c",
+              "lib/encinfo.c",
+              "lib/encode.c",
+              "lib/enquant.c",
+              "lib/fdct.c",
+              "lib/huffenc.c",
+              "lib/mathops.c",
+              "lib/mcenc.c",
+              "lib/rate.c",
+              "lib/tokenize.c")
+    local asmdir = is_plat("windows") and "x86_vc" or "x86"
+    if is_arch("x86") then
+        add_defines("OC_X86_ASM")
+        add_files(path.join("lib", asmdir, "*.c|sse2fdct.c"))
+    elseif is_arch("x64", "x86_64") and not is_plat("windows") then
+        add_defines("OC_X86_ASM", "OC_X86_64_ASM")
+        add_files(path.join("lib", asmdir, "*.c"))
+    end
+
+target("theoradec")
+    add_files("lib/apiwrapper.c",
+	          "lib/bitpack.c",
+              "lib/decapiwrapper.c",
+              "lib/decinfo.c",
+              "lib/decode.c",
+              "lib/dequant.c",
+              "lib/fragment.c",
+              "lib/huffdec.c",
+              "lib/idct.c",
+              "lib/info.c",
+              "lib/internal.c",
+              "lib/quant.c",
+              "lib/state.c")
+    local asmdir = is_plat("windows") and "x86_vc" or "x86"
+    if is_arch("x86") or (not is_plat("windows") and is_arch("x64", "x86_64")) then
+        add_defines("OC_X86_ASM")
+        add_files(path.join("lib", asmdir, "mmxidct.c"),
+                  path.join("lib", asmdir, "mmxfrag.c"),
+                  path.join("lib", asmdir, "mmxstate.c"),
+                  path.join("lib", asmdir, "x86state.c"))
+        if os.exists("lib", asmdir, "sse2idct.c") then
+            add_files("lib", asmdir, "sse2idct.c")
+        end
+        if os.exists(path.join("lib", asmdir, "x86cpu.c")) then
+            add_files(path.join("lib", asmdir, "x86cpu.c"))
+        end
+        if is_arch("x64", "x86_64") then
+            add_defines("OC_X86_64_ASM")
+        end
+    end

+ 31 - 0
packages/t/theora/xmake.lua

@@ -0,0 +1,31 @@
+package("theora")
+    set_homepage("https://theora.org/")
+    set_description("Reference implementation of the Theora video compression format.")
+    set_license("BSD-3-Clause")
+
+    add_urls("https://gitlab.xiph.org/xiph/theora.git",
+             "https://gitlab.xiph.org/xiph/theora/-/archive/v$(version)/theora-$(version).tar.gz",
+             "https://github.com/xiph/theora.git")
+
+    add_versions("v1.0", "bfaaa9dc04b57b44a3152c2132372c72a20d69e5fc6c9cc8f651cc1bc2434006")
+    add_versions("v1.1.0", "726e6e157f711011f7377773ce5ee233f7b73a425bf4ad192e4f8a8a71cf21d6")
+    add_versions("v1.1.1", "316ab9438310cf65c38aa7f5e25986b9d27e9aec771668260c733817ecf26dff")
+
+    add_deps("libogg")
+
+    if is_plat("wasm") then
+        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+    end
+
+    on_install(function (package)
+        os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
+        local configs = {}
+        if package:config("shared") then
+            configs.kind = "shared"
+        end
+        import("package.tools.xmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("theora_encode_init", {includes = "theora/theora.h"}))
+    end)