feat: add libass (#2346)
* feat(fribidi): add version 1.0.13 and wasm supoort * feat(fribidi): turn on all platforms * chore(fribidi): tweaks * feat(harfbuzz): wasm support * chore(harfbuzz): tweaks * feat(meson): try to enable bsd support * feat(freetype): new dep command since 2.11.1 * fix(freetype): fix a typo * feat(fribidi): optimize includes export * feat: add libass * feat(harfbuzz): try to add some platform * fix(libass): try to fix windows build error * feat(libass): add more version * fix(harfbuzz): fix dependence error on bsd * fix(harfbuzz): disable freetype on bsd * fix: fix asm build error * Update xmake.lua * fix(harfbuzz): fix android build * Update xmake.lua * fix(harfbuzz): fix android build * fix(huffbuzz): fix a dep error * fix(harfbuzz): fix a typo * fix(harfbuzz): try to fix android build error * fix(harfbuzz): disable freetype on android * fix(libass): fix clang build error * Update xmake.lua * fix(libass): fix windows shared library build * feat(harfbuzz): add more versions * fix(harfbuzz): fix windows shared lib build * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua --------- Co-authored-by: ruki <waruqi@gmail.com>pull/2444/head
parent
e678ebbaac
commit
f6735ebeed
7 changed files with 201 additions and 15 deletions
@ -0,0 +1,12 @@ |
||||
/* found CoreText framework */ |
||||
#undef CONFIG_CORETEXT |
||||
|
||||
/* found DirectWrite and GDI (Win32) */ |
||||
#undef CONFIG_DIRECTWRITE |
||||
|
||||
/* found libpng via pkg-config */ |
||||
#undef CONFIG_LIBPNG |
||||
#define CONFIG_SOURCEVERSION "commit: ${GIT_TAG}${GIT_COMMIT_LONG}" |
||||
${define HAVE_STRDUP} |
||||
${define HAVE_STRNDUP} |
||||
|
@ -0,0 +1,98 @@ |
||||
set_project("libass") |
||||
add_requires("freetype", "fribidi", "harfbuzz") |
||||
|
||||
includes("check_cfuncs.lua") |
||||
add_rules("mode.debug", "mode.release") |
||||
if is_plat("windows") and is_kind("shared") then |
||||
add_rules("utils.symbols.export_all") |
||||
end |
||||
|
||||
option("asm") |
||||
set_default(true) |
||||
set_description("compiling with ASM") |
||||
add_defines("CONFIG_ASM") |
||||
option("large-tiles") |
||||
set_default(false) |
||||
set_description("use larger tiles in the rasterizer (better performance, slightly worse quality)") |
||||
add_defines("CONFIG_LARGE_TILES") |
||||
option("system-font-provider") |
||||
on_check(function (option) |
||||
option:enable(not is_plat("wasm")) |
||||
end) |
||||
set_description("enable checking for system fonts provider") |
||||
|
||||
target("ass") |
||||
set_kind("$(kind)") |
||||
add_options("asm", "large-tiles", "system-font-provider") |
||||
add_packages("freetype", "fribidi", "harfbuzz") |
||||
add_files("libass/*.c|ass_fontconfig.c|ass_directwrite.c|ass_coretext.c", |
||||
"libass/c/*.c") |
||||
add_includedirs("libass", "libass/c", "$(buildir)") |
||||
if not is_plat("windows") then |
||||
add_syslinks("m") |
||||
end |
||||
add_configfiles("config.h.in") |
||||
configvar_check_cfuncs("HAVE_STRDUP", "strdup", {includes = "string.h"}) |
||||
configvar_check_cfuncs("HAVE_STRNDUP", "strndup", {includes = "string.h"}) |
||||
if has_config("asm") then |
||||
if is_arch("x64", "x86", "x86_64") then |
||||
set_toolchains("nasm") |
||||
add_files("libass/x86/*.asm|utils.asm|x86inc.asm") |
||||
add_includedirs("libass/x86") |
||||
add_defines("ARCH_X86=1", "private_prefix=ass") |
||||
if is_arch("x86") then |
||||
add_defines("ARCH_X86_64=0", "BITMODE=32") |
||||
else |
||||
add_defines("ARCH_X86_64=1", "BITMODE=64") |
||||
end |
||||
if is_plat("windows") and is_arch("x86") then |
||||
add_defines("PREFIX") |
||||
elseif is_plat("macosx") then |
||||
add_defines("PREFIX", "STACK_ALIGNMENT=16") |
||||
elseif is_plat("linux") then |
||||
add_defines("STACK_ALIGNMENT=16") |
||||
end |
||||
elseif is_arch("arm64.*", "aarch64") then |
||||
add_files("libass/aarch64/*.S") |
||||
add_defines("ARCH_AARCH64") |
||||
end |
||||
end |
||||
if has_config("system-font-provider") then |
||||
on_config(function (target) |
||||
-- directwrite |
||||
if target:is_plat("windows", "mingw") and target:has_cincludes("dwrite_c.h") then |
||||
if target:check_csnippets([[#include <winapifamily.h> |
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
||||
#error Win32 desktop APIs are available |
||||
#endif]]) then |
||||
target:add("syslinks", "dwrite") |
||||
else |
||||
target:add("syslinks", "gdi32") |
||||
end |
||||
if target:kind() == "shared" then |
||||
target:add("syslinks", "user32") |
||||
end |
||||
target:add("files", "libass/ass_directwrite.c") |
||||
target:add("defines", "CONFIG_DIRECTWRITE") |
||||
end |
||||
-- coretext |
||||
if target:is_plat("macosx") then |
||||
if target:has_cfuncs("CTFontDescriptorCopyAttribute", {includes = "ApplicationServices/ApplicationServices.h"}) then |
||||
target:add("frameworks", "ApplicationServices", "CoreFoundation") |
||||
target:add("files", "libass/ass_coretext.c") |
||||
target:add("defines", "CONFIG_CORETEXT=1") |
||||
elseif target:has_cincludes("CoreText/CoreText.h") then |
||||
target:add("frameworks", "CoreText", "CoreFoundation") |
||||
target:add("files", "libass/ass_coretext.c") |
||||
target:add("defines", "CONFIG_CORETEXT=1") |
||||
end |
||||
end |
||||
-- fontconfig |
||||
if target:has_cincludes("fontconfig/fontconfig.h") then |
||||
target:add("files", "libass/ass_fontconfig.c") |
||||
target:add("defines", "CONFIG_FONTCONFIG") |
||||
target:add("syslinks", "fontconfig") |
||||
end |
||||
end) |
||||
end |
||||
add_headerfiles("libass/ass.h", "libass/ass_types.h", {prefix = "include/libass"}) |
@ -0,0 +1,32 @@ |
||||
package("libass") |
||||
set_homepage("https://github.com/libass/libass") |
||||
set_description("libass is a portable subtitle renderer for the ASS/SSA (Advanced Substation Alpha/Substation Alpha) subtitle format.") |
||||
set_license("ISC") |
||||
|
||||
add_urls("https://github.com/libass/libass/releases/download/$(version)/libass-$(version).tar.gz", |
||||
"https://github.com/libass/libass.git") |
||||
|
||||
add_versions("0.15.2", "1b2a54dda819ef84fa2dee3069cf99748a886363d2adb630fde87fe046e2d1d5") |
||||
add_versions("0.16.0", "fea8019b1887cab9ab00c1e58614b4ec2b1cee339b3f7e446f5fab01b032d430") |
||||
add_versions("0.17.0", "72b9ba5d9dd1ac6d30b5962f38cbe7aefb180174f71d8b65c5e3c3060dbc403f") |
||||
add_versions("0.17.1", "d653be97198a0543c69111122173c41a99e0b91426f9e17f06a858982c2fb03d") |
||||
|
||||
add_deps("freetype", "fribidi", "harfbuzz", "nasm") |
||||
|
||||
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") |
||||
os.cp(path.join(package:scriptdir(), "port", "config.h.in"), "config.h.in") |
||||
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("ass_library_init", {includes = "ass.h"})) |
||||
end) |
Loading…
Reference in new issue