From 568815bac7834d306b45546ceaa9a1ae5ba48ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B0=E9=9B=AA=E6=AE=87=E7=92=83=E9=99=8C=E6=A2=A6?= <80821706+DreamOfIce@users.noreply.github.com> Date: Sat, 15 Jul 2023 00:12:53 +0800 Subject: [PATCH] feat: add wavpack (#2312) * feat: add wavpack * feat(svt-av1): add license * fix(wavpack): fix cross compile error * chore(wavpack): disable cross * feat(wavpack): some improves * fix(wavpack): fix wasm build error * fix(wavpack): fix wasm build error * fix(wavpack): try to fix windows build error * feat(wavpack): add options --- packages/f/fdk-aac/xmake.lua | 1 + packages/l/libiconv/xmake.lua | 6 +++-- packages/s/svt-av1/xmake.lua | 1 + packages/w/wavpack/xmake.lua | 43 +++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 packages/w/wavpack/xmake.lua diff --git a/packages/f/fdk-aac/xmake.lua b/packages/f/fdk-aac/xmake.lua index 83a77cd3f..fe46db1b8 100644 --- a/packages/f/fdk-aac/xmake.lua +++ b/packages/f/fdk-aac/xmake.lua @@ -1,6 +1,7 @@ package("fdk-aac") set_homepage("https://sourceforge.net/projects/opencore-amr/") set_description("A standalone library of the Fraunhofer FDK AAC code from Android.") + set_license("Apache-2.0") add_urls("https://github.com/mstorsjo/fdk-aac/archive/refs/tags/v$(version).tar.gz", "https://github.com/mstorsjo/fdk-aac.git") diff --git a/packages/l/libiconv/xmake.lua b/packages/l/libiconv/xmake.lua index 1f51d9324..f6d95bb87 100644 --- a/packages/l/libiconv/xmake.lua +++ b/packages/l/libiconv/xmake.lua @@ -15,6 +15,8 @@ package("libiconv") elseif is_plat("android") then add_patches("1.x", path.join(os.scriptdir(), "patches", "1.16", "makefile.in.patch"), "d09e4212040f5adf1faa5cf5a9a18f6f79d4cdce9affb05f2e75df2ea3b3d686") + elseif is_plat("wasm") then + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) end on_fetch("macosx", "linux", function (package, opt) @@ -46,7 +48,7 @@ package("libiconv") }) end) - on_install("macosx", "linux", "cross", "android", function (package) + on_install("macosx", "linux", "bsd", "cross", "android", "wasm", function (package) local configs = {"--disable-dependency-tracking", "--enable-extra-encodings"} if not package:is_plat("macosx") then table.insert(configs, "--enable-relocatable") @@ -65,7 +67,7 @@ package("libiconv") end) on_test(function (package) - if package:is_plat("macosx", "linux") then + if package:is_plat("macosx", "linux", "bsd") then os.vrun("iconv --version") end assert(package:check_csnippets({test = [[ diff --git a/packages/s/svt-av1/xmake.lua b/packages/s/svt-av1/xmake.lua index 7215d783b..f18e98adf 100644 --- a/packages/s/svt-av1/xmake.lua +++ b/packages/s/svt-av1/xmake.lua @@ -1,6 +1,7 @@ package("svt-av1") set_homepage("https://gitlab.com/AOMediaCodec/SVT-AV1") set_description("Scalable Video Technology for AV1 (SVT-AV1 Encoder and Decoder)") + set_license("BSD-2-clause") add_urls("https://gitlab.com/AOMediaCodec/SVT-AV1.git", "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v$(version)/SVT-AV1-v$(version).tar.gz") diff --git a/packages/w/wavpack/xmake.lua b/packages/w/wavpack/xmake.lua new file mode 100644 index 000000000..3a6c19016 --- /dev/null +++ b/packages/w/wavpack/xmake.lua @@ -0,0 +1,43 @@ +package("wavpack") + set_homepage("https://github.com/dbry/WavPack") + set_description("WavPack encode/decode library, command-line programs, and several plugins") + set_license("BSD-3-Clause") + + add_urls("https://github.com/dbry/WavPack//archive/refs/tags/$(version).tar.gz", + "https://github.com/dbry/WavPack.git") + + add_versions("4.80.0", "c72cb0bbe6490b84881d61f326611487eedb570d8d2e74f073359578b08322e2") + add_versions("5.4.0", "abbe5ca3fc918fdd64ef216200a5c896243ea803a059a0662cd362d0fa827cd2") + add_versions("5.5.0", "b3d11ba35d12c7d2ed143036478b6f9f4bdac993d84b5ed92615bc6b60697b8a") + add_versions("5.6.0", "44043e8ffe415548d5723e9f4fc6bda5e1f429189491c5fb3df08b8dcf28df72") + + add_configs("legacy", {description = "Decode legacy (< 4.0) WavPack files", default = false, type = "boolean"}) + add_configs("threads", {description = "Enable support for threading in libwavpack", default = true, type = "boolean"}) + add_configs("dsd", {description = "Enable support for WavPack DSD files", default = true, type = "boolean"}) + + add_deps("cmake") + if not is_plat("windows") then + add_deps("libiconv", "openssl", {optional = true}) + end + + if is_plat("wasm") then + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + end + + on_install("windows", "linux", "bsd", "macosx", "mingw", "android", "wasm", function (package) + local configs = {"-DWAVPACK_INSTALL_CMAKE_MODULE=OFF", "-DWAVPACK_INSTALL_DOCS=OFF", "-DWAVPACK_INSTALL_PKGCONFIG_MODULE=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")) + + for name, enabled in pairs(package:configs()) do + if not package:extraconf("configs", name, "builtin") then + table.insert(configs, "-DWAVPACK_ENABLE_" .. name:upper() .. "=" .. (enabled and "ON" or "OFF")) + end + end + + import("package.tools.cmake").install(package, configs) + end) + + on_test(function (package) + assert(package:has_cfuncs("WavpackOpenRawDecoder", {includes = "wavpack/wavpack.h"})) + end)