Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/actions/setup-libraries/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
using: "composite"
steps:
- name: Install dependencies
run: sudo apt install gperf gettext autopoint
run: sudo apt install gperf gettext autopoint nasm
shell: bash

- name: Running autogen.sh in unibreak
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

steps:
- name: Download artifact
uses: actions/download-artifact@v6
uses: actions/download-artifact@v8
with:
path: artifacts

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
submodules: true

Expand All @@ -45,7 +45,7 @@ jobs:
working-directory: build
run: cmake --build .

- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v7
with:
name: build-${{ matrix.ANDROID_ABI }}
path: |
Expand Down
1 change: 0 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[submodule "src/unibreak"]
path = src/unibreak
url = https://github.com/adah1972/libunibreak.git
branch = libunibreak_6_1
[submodule "src/harfbuzz"]
path = src/harfbuzz
url = https://github.com/harfbuzz/harfbuzz.git
Expand Down
37 changes: 19 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ set(EXTERNAL_PROJECT_CMAKE_ARGS

include(${CMAKE_TOOLCHAIN_FILE})

# fribidi and unibreak can't match ANDROID_HOST_TAG!!!
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64-linux")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
set(ANDROID_HOST_TAG darwin-x86_64)
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64-darwin")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64-windows")
endif()

#
# Set some convenience variables.
#
Expand All @@ -42,23 +32,33 @@ set(PLATFORM_COMPILE_ENV_CMDS
OBJDUMP=${CMAKE_OBJDUMP}
RANLIB=${CMAKE_RANLIB}
STRIP=${CMAKE_STRIP}
PKG_CONFIG_PATH=${CMAKE_BINARY_DIR}/lib/pkgconfig)
PKG_CONFIG_PATH=${CMAKE_BINARY_DIR}/lib/pkgconfig
PKG_CONFIG_LIBDIR=)

set(PLATFORM_COMPILE_ENV_FLAGS
"CFLAGS=${CMAKE_C_FLAGS} -fPIC --target=${CMAKE_C_COMPILER_TARGET}"
"CXXFLAGS=${CMAKE_CXX_FLAGS} -fPIC --target=${CMAKE_CXX_COMPILER_TARGET}"
"CFLAGS=${CMAKE_C_FLAGS} --target=${CMAKE_C_COMPILER_TARGET}"
"CXXFLAGS=${CMAKE_CXX_FLAGS} --target=${CMAKE_CXX_COMPILER_TARGET}"
"LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS} --target=${CMAKE_C_COMPILER_TARGET}"
"ASFLAGS= -fPIC"
"YASMFLAGS= -fPIC"
)

set(PLATFORM_CONFIGURE_ENV ${PLATFORM_COMPILE_ENV_CMDS}
${PLATFORM_COMPILE_ENV_FLAGS})

# From https://developer.android.com/ndk/guides/other_build_systems#autoconf
if(CMAKE_ANDROID_ARCH STREQUAL "arm")
set(HOST_TRIPLET "armv7a-linux-androideabi")
elseif(CMAKE_ANDROID_ARCH STREQUAL "arm64")
set(HOST_TRIPLET "aarch64-linux-android")
elseif(CMAKE_ANDROID_ARCH STREQUAL "x86")
set(HOST_TRIPLET "i686-linux-android")
elseif(CMAKE_ANDROID_ARCH STREQUAL "x86_64")
set(HOST_TRIPLET "x86_64-linux-android")
else()
message(FATAL_ERROR "Unsupported CMAKE_ANDROID_ARCH: ${CMAKE_ANDROID_ARCH}")
endif()

set(PLATFORM_BUILD_AND_HOST
"--build=${CMAKE_HOST_SYSTEM_PROCESSOR}"
"--host=${CMAKE_C_COMPILER_TARGET}"
"--target=${CMAKE_C_COMPILER_TARGET}"
"--host=${HOST_TRIPLET}"
)

#
Expand All @@ -83,6 +83,7 @@ if(EXISTS ${PROJECT_SOURCE_DIR}/cmake/files/meson-cross-android.in)
unset(MESON_SYSTEM_CPU_FAMILY)
endif()

include(cmake/zlib.cmake)
include(cmake/unibreak.cmake)
include(cmake/fribidi.cmake)
include(cmake/freetype.cmake)
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Build libass for Android.

## library version
* [unibreak](https://github.com/adah1972/libunibreak) [v6.1](https://github.com/adah1972/libunibreak/releases/tag/libunibreak_6_1)
* [harfbuzz](https://github.com/harfbuzz/harfbuzz) [v11.3.3](https://github.com/harfbuzz/harfbuzz/releases/tag/11.2.1)
* [unibreak](https://github.com/adah1972/libunibreak) [v7.0](https://github.com/adah1972/libunibreak/releases/tag/libunibreak_7_0)
* [harfbuzz](https://github.com/harfbuzz/harfbuzz) [v14.4.0](https://github.com/harfbuzz/harfbuzz/releases/tag/14.4.0)
* [fribidi](https://github.com/fribidi/fribidi) [v1.0.16](https://github.com/fribidi/fribidi/releases/tag/v1.0.16)
* [freetype](https://gitlab.freedesktop.org/freetype/freetype) [v2.13.3](https://gitlab.freedesktop.org/freetype/freetype/-/tags/VER-2-13-3)
* [expat](https://github.com/libexpat/libexpat) [2.7.1](https://github.com/libexpat/libexpat/releases/tag/R_2_7_1)
* [fontconfig](https://gitlab.freedesktop.org/fontconfig/fontconfig) [master with daa175d2](https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/daa175d234b8a362eedd4c18c33537cc2d19cd98)
* [ass](https://github.com/libass/libass) [v0.17.4](https://github.com/libass/libass/releases/tag/0.17.4)
* [freetype](https://gitlab.freedesktop.org/freetype/freetype) [v2.14.3](https://gitlab.freedesktop.org/freetype/freetype/-/tags/VER-2-14-3)
* [expat](https://github.com/libexpat/libexpat) [2.8.4](https://github.com/libexpat/libexpat/releases/tag/R_2_8_4)
* [fontconfig](https://gitlab.freedesktop.org/fontconfig/fontconfig) [v2.18.3](https://gitlab.freedesktop.org/fontconfig/fontconfig/-/tags/2.18.3)
* [ass](https://github.com/libass/libass) [v0.17.5](https://github.com/libass/libass/releases/tag/0.17.5)

## how to use

Expand All @@ -24,11 +24,11 @@ Build libass for Android.

### autogen
```
cd ./src/unibreak && ./autogen.sh
cd ./src/fribidi && ./autogen.sh
cd ./src/fontconfig && ./autogen.sh
cd ./src/expat/expat && ./buildconf.sh
cd ./src/ass && ./autogen.sh
cd ./src/unibreak && NOCONFIGURE=1 ./autogen.sh && cd -
cd ./src/fribidi && NOCONFIGURE=1 ./autogen.sh && cd -
cd ./src/fontconfig && NOCONFIGURE=1 ./autogen.sh && cd -
cd ./src/expat/expat && ./buildconf.sh && cd -
cd ./src/ass && ./autogen.sh && cd -
```

### add ass cmake to CMakeList.txt
Expand Down
10 changes: 10 additions & 0 deletions cmake/ass.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
cmake_minimum_required(VERSION 3.10)

if(NOT CMAKE_ANDROID_ARCH STREQUAL "arm")
set(ASS_ASM_ARG "--enable-asm")
else()
# libass doesn't support arm 32 bits asm.
set(ASS_ASM_ARG "--disable-asm")
endif()

ExternalProject_Add(ep_ass
DEPENDS ep_fontconfig ep_harfbuzz ep_freetype ep_fribidi ep_unibreak
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
Expand All @@ -11,8 +19,10 @@ ExternalProject_Add(ep_ass
--prefix=<INSTALL_DIR>
--enable-static
--disable-shared
--with-pic
--enable-fontconfig
--enable-libunibreak
${ASS_ASM_ARG}
--srcdir=<SOURCE_DIR>/<SOURCE_SUBDIR>
BUILD_COMMAND make
INSTALL_COMMAND make install
Expand Down
1 change: 1 addition & 0 deletions cmake/expat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ExternalProject_Add(ep_expat
--prefix=<INSTALL_DIR>
--enable-static
--disable-shared
--with-pic
--without-tests
--without-docbook
BUILD_COMMAND make
Expand Down
8 changes: 8 additions & 0 deletions cmake/fontconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ ExternalProject_Add(ep_fontconfig
INSTALL_DIR ${CMAKE_BINARY_DIR}
CONFIGURE_COMMAND
${CMAKE_COMMAND} -E env ${PLATFORM_CONFIGURE_ENV}
# m4/va_copy.m4 AC_RUN_IFELSE has no cross-compiling fallback.
# Due to that, the check fails with:
# checking for va_copy() function... configure: error: in `PATH/libass-cmake/build/ep_fontconfig-prefix/src/ep_fontconfig-build':
# configure: error: cannot run test program while cross compiling
# To avoid this failure, set its cache variable to skip the runtime check.
# The NDK toolchain always provides C99 va_copy().
ac_cv_va_copy=C99
<SOURCE_DIR>/<SOURCE_SUBDIR>/configure ${PLATFORM_BUILD_AND_HOST}
--prefix=<INSTALL_DIR>
--enable-static
--disable-shared
--with-pic
BUILD_COMMAND make
INSTALL_COMMAND make install
)
3 changes: 1 addition & 2 deletions cmake/fribidi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ ExternalProject_Add(ep_fribidi
--prefix=<INSTALL_DIR>
--enable-static
--disable-shared
--disable-docs
--disable-option-checking
--with-pic
BUILD_COMMAND make
INSTALL_COMMAND make install
)
Expand Down
1 change: 1 addition & 0 deletions cmake/unibreak.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ExternalProject_Add(ep_unibreak
--prefix=<INSTALL_DIR>
--enable-static
--disable-shared
--with-pic
BUILD_COMMAND make
INSTALL_COMMAND make install
)
Expand Down
23 changes: 23 additions & 0 deletions cmake/zlib.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# The Android NDK toolchain ships its own zlib in the sysroot,
# but it does not provide a zlib.pc.
# Since freetype's generated freetype2.pc declares `Requires.private:
# zlib`, pkg-config needs a zlib.pc to resolve that dependency.
set(NDK_ZLIB_HEADER "${CMAKE_SYSROOT}/usr/include/zlib.h")
set(NDK_ZLIB_VERSION "1.0.0")
if(EXISTS ${NDK_ZLIB_HEADER})
file(STRINGS ${NDK_ZLIB_HEADER} NDK_ZLIB_VERSION_LINE REGEX "#define ZLIB_VERSION ")
string(REGEX REPLACE ".*#define ZLIB_VERSION \"([^\"]+)\".*" "\\1" NDK_ZLIB_VERSION "${NDK_ZLIB_VERSION_LINE}")
endif()

file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib/pkgconfig)
file(WRITE ${CMAKE_BINARY_DIR}/lib/pkgconfig/zlib.pc
"Name: zlib
Description: zlib compression library (provided by the Android NDK toolchain)
Version: ${NDK_ZLIB_VERSION}
Libs: -lz
Cflags:
")

unset(NDK_ZLIB_HEADER)
unset(NDK_ZLIB_VERSION)
unset(NDK_ZLIB_VERSION_LINE)
2 changes: 1 addition & 1 deletion src/expat
Submodule expat updated 160 files
2 changes: 1 addition & 1 deletion src/fontconfig
Submodule fontconfig updated from daa175 to 0f2367
2 changes: 1 addition & 1 deletion src/freetype
Submodule freetype updated from 42608f to 0a0221
2 changes: 1 addition & 1 deletion src/harfbuzz
Submodule harfbuzz updated 1023 files