mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
WIP
This commit is contained in:
parent
77c787b51f
commit
1ee834d42b
37 changed files with 2322 additions and 18 deletions
82
scripts/mpv/README.md
Normal file
82
scripts/mpv/README.md
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
# Building
|
||||
|
||||
Compiling the native parts is a process separate from Gradle and the app won't work if you skip this.
|
||||
|
||||
This process is supported on Linux and macOS. Windows (or WSL) will **not** work.
|
||||
|
||||
## Download dependencies
|
||||
|
||||
`download.sh` will take care of installing the Android SDK, NDK and downloading the sources.
|
||||
|
||||
If you're running on Debian/Ubuntu or RHEL/Fedora it will also install the necessary dependencies for you.
|
||||
|
||||
```sh
|
||||
./download.sh
|
||||
```
|
||||
|
||||
If you already have the Android SDK installed you can symlink `android-sdk-linux` to your SDK root
|
||||
before running the script and the necessary SDK packages will still be installed.
|
||||
|
||||
A matching NDK version (inside the SDK) will be picked up automatically or downloaded and installed otherwise.
|
||||
|
||||
## Build
|
||||
|
||||
```sh
|
||||
./buildall.sh
|
||||
```
|
||||
|
||||
Run `buildall.sh` with `--clean` to clean the build directories before building.
|
||||
For a guaranteed clean build also run `rm -rf prefix` beforehand.
|
||||
|
||||
By default this will build only for 32-bit ARM (`armv7l`).
|
||||
You probably want to build for AArch64 too, and perhaps Intel x86.
|
||||
|
||||
To do this run one (or more) of these commands **before** ./buildall.sh:
|
||||
```sh
|
||||
./buildall.sh --arch arm64 mpv
|
||||
./buildall.sh --arch x86 mpv
|
||||
./buildall.sh --arch x86_64 mpv
|
||||
```
|
||||
|
||||
# Developing
|
||||
|
||||
## Getting logs
|
||||
|
||||
```sh
|
||||
adb logcat # get all logs, useful when drivers/vendor libs output to logcat
|
||||
adb logcat -s mpv # get only mpv logs
|
||||
```
|
||||
|
||||
## Rebuilding a single component
|
||||
|
||||
If you've made changes to a single component (e.g. ffmpeg or mpv) and want a new build you can of course just run ./buildall.sh but it's also possible to just build a single component like this:
|
||||
|
||||
```sh
|
||||
./buildall.sh -n ffmpeg
|
||||
# optional: add --clean to build from a clean state
|
||||
```
|
||||
|
||||
Note that you might need to rebuild for other architectures (`--arch`) too depending on your device.
|
||||
|
||||
Afterwards, build mpv-android and install the apk:
|
||||
|
||||
```sh
|
||||
./buildall.sh -n
|
||||
adb install -r ../app/build/outputs/apk/default/debug/app-default-universal-debug.apk
|
||||
```
|
||||
|
||||
## Using Android Studio
|
||||
|
||||
You can use Android Studio to develop the Java part of the codebase. Before using it, make sure to build the project at least once by following the steps in the **Build** section.
|
||||
|
||||
You should point Android Studio to existing SDK installation at `mpv-android/buildscripts/sdk/android-sdk-linux`.
|
||||
Then click "Open an existing Android Studio project" and select `mpv-android`.
|
||||
|
||||
Note that if you build from Android Studio only the Java/Kotlin part will be built.
|
||||
If you make any changes to libraries (ffmpeg, mpv, ...) or mpv-android native code (`app/src/main/jni/*`), first rebuild native code with:
|
||||
|
||||
```sh
|
||||
./buildall.sh -n
|
||||
```
|
||||
|
||||
then build the project from Android Studio.
|
||||
180
scripts/mpv/buildall.sh
Executable file
180
scripts/mpv/buildall.sh
Executable file
|
|
@ -0,0 +1,180 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
cd "$( dirname "${BASH_SOURCE[0]}" )"
|
||||
. ./include/depinfo.sh
|
||||
|
||||
cleanbuild=0
|
||||
nodeps=0
|
||||
clang=1
|
||||
target=mpv-android
|
||||
arch=armv7l
|
||||
|
||||
getdeps () {
|
||||
varname="dep_${1//-/_}[*]"
|
||||
echo ${!varname}
|
||||
}
|
||||
|
||||
loadarch () {
|
||||
unset CC CXX CPATH LIBRARY_PATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH
|
||||
unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
|
||||
|
||||
local apilvl=21
|
||||
# ndk_triple: what the toolchain actually is
|
||||
# cc_triple: what Google pretends the toolchain is
|
||||
if [ "$1" == "armv7l" ]; then
|
||||
export ndk_suffix=
|
||||
export ndk_triple=arm-linux-androideabi
|
||||
cc_triple=armv7a-linux-androideabi$apilvl
|
||||
prefix_name=armv7l
|
||||
elif [ "$1" == "arm64" ]; then
|
||||
export ndk_suffix=-arm64
|
||||
export ndk_triple=aarch64-linux-android
|
||||
cc_triple=$ndk_triple$apilvl
|
||||
prefix_name=arm64
|
||||
elif [ "$1" == "x86" ]; then
|
||||
export ndk_suffix=-x86
|
||||
export ndk_triple=i686-linux-android
|
||||
cc_triple=$ndk_triple$apilvl
|
||||
prefix_name=x86
|
||||
elif [ "$1" == "x86_64" ]; then
|
||||
export ndk_suffix=-x64
|
||||
export ndk_triple=x86_64-linux-android
|
||||
cc_triple=$ndk_triple$apilvl
|
||||
prefix_name=x86_64
|
||||
else
|
||||
echo "Invalid architecture" >&2
|
||||
exit 1
|
||||
fi
|
||||
export prefix_dir="$PWD/prefix/$prefix_name"
|
||||
if [ $clang -eq 1 ]; then
|
||||
export CC=$cc_triple-clang
|
||||
export CXX=$cc_triple-clang++
|
||||
else
|
||||
export CC=$cc_triple-gcc
|
||||
export CXX=$cc_triple-g++
|
||||
fi
|
||||
export LDFLAGS="-Wl,-O1,--icf=safe -Wl,-z,max-page-size=16384"
|
||||
export AR=llvm-ar
|
||||
export RANLIB=llvm-ranlib
|
||||
}
|
||||
|
||||
setup_prefix () {
|
||||
if [ ! -d "$prefix_dir" ]; then
|
||||
mkdir -p "$prefix_dir"
|
||||
# enforce flat structure (/usr/local -> /)
|
||||
ln -s . "$prefix_dir/usr"
|
||||
ln -s . "$prefix_dir/local"
|
||||
fi
|
||||
|
||||
local cpu_family=${ndk_triple%%-*}
|
||||
[ "$cpu_family" == "i686" ] && cpu_family=x86
|
||||
|
||||
if ! command -v pkg-config >/dev/null; then
|
||||
echo "pkg-config not provided!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# meson wants to be spoonfed this file, so create it ahead of time
|
||||
# also define: release build, static libs and no source downloads at runtime(!!!)
|
||||
cat >"$prefix_dir/crossfile.tmp" <<CROSSFILE
|
||||
[built-in options]
|
||||
buildtype = 'release'
|
||||
default_library = 'static'
|
||||
wrap_mode = 'nodownload'
|
||||
prefix = '/usr/local'
|
||||
[binaries]
|
||||
c = '$CC'
|
||||
cpp = '$CXX'
|
||||
ar = 'llvm-ar'
|
||||
nm = 'llvm-nm'
|
||||
strip = 'llvm-strip'
|
||||
pkgconfig = 'pkg-config'
|
||||
pkg-config = 'pkg-config'
|
||||
[host_machine]
|
||||
system = 'android'
|
||||
cpu_family = '$cpu_family'
|
||||
cpu = '${CC%%-*}'
|
||||
endian = 'little'
|
||||
CROSSFILE
|
||||
# also avoid rewriting it needlessly
|
||||
if cmp -s "$prefix_dir"/crossfile.{tmp,txt}; then
|
||||
rm "$prefix_dir/crossfile.tmp"
|
||||
else
|
||||
mv "$prefix_dir"/crossfile.{tmp,txt}
|
||||
fi
|
||||
}
|
||||
|
||||
build () {
|
||||
if [ $1 != "mpv-android" ] && [ ! -d deps/$1 ]; then
|
||||
printf >&2 '\e[1;31m%s\e[m\n' "Target $1 not found"
|
||||
return 1
|
||||
fi
|
||||
if [ $nodeps -eq 0 ]; then
|
||||
printf >&2 '\e[1;34m%s\e[m\n' "Preparing $1..."
|
||||
local deps=$(getdeps $1)
|
||||
echo >&2 "Dependencies: $deps"
|
||||
for dep in $deps; do
|
||||
build $dep
|
||||
done
|
||||
fi
|
||||
printf >&2 '\e[1;34m%s\e[m\n' "Building $1..."
|
||||
if [ "$1" == "mpv-android" ]; then
|
||||
pushd ..
|
||||
BUILDSCRIPT=buildscripts/scripts/$1.sh
|
||||
else
|
||||
pushd deps/$1
|
||||
BUILDSCRIPT=../../scripts/$1.sh
|
||||
fi
|
||||
[ $cleanbuild -eq 1 ] && $BUILDSCRIPT clean
|
||||
$BUILDSCRIPT build
|
||||
popd
|
||||
}
|
||||
|
||||
usage () {
|
||||
printf '%s\n' \
|
||||
"Usage: buildall.sh [options] [target]" \
|
||||
"Builds the specified target (default: $target)" \
|
||||
"-n Do not build dependencies" \
|
||||
"--clean Clean build dirs before compiling" \
|
||||
"--gcc Use gcc compiler (unsupported!)" \
|
||||
"--arch <arch> Build for specified architecture (default: $arch; supported: armv7l, arm64, x86, x86_64)"
|
||||
exit 0
|
||||
}
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--clean)
|
||||
cleanbuild=1
|
||||
;;
|
||||
-n|--no-deps)
|
||||
nodeps=1
|
||||
;;
|
||||
--gcc)
|
||||
clang=0
|
||||
;;
|
||||
--arch)
|
||||
shift
|
||||
arch=$1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown flag $1" >&2
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
target=$1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
loadarch $arch
|
||||
setup_prefix
|
||||
build $target
|
||||
|
||||
[ "$target" == "mpv-android" ] && \
|
||||
ls -lh ../app/build/outputs/apk/{default,api29}/*/*.apk
|
||||
|
||||
exit 0
|
||||
68
scripts/mpv/get_dependencies.sh
Executable file
68
scripts/mpv/get_dependencies.sh
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -exou pipefail
|
||||
|
||||
BUILD_PATH="./deps"
|
||||
|
||||
mkdir -p "$BUILD_PATH"
|
||||
pushd "$BUILD_PATH" || exit
|
||||
|
||||
function clone(){
|
||||
repo=$1
|
||||
branch=$2
|
||||
dir=$3
|
||||
shift 3
|
||||
|
||||
if [[ -d "$dir" ]]; then
|
||||
pushd "$dir" || exit
|
||||
git checkout --force "$branch"
|
||||
popd || exit
|
||||
else
|
||||
git clone "$repo" --depth 1 --single-branch -b "$branch" "$dir" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
clone "https://github.com/videolan/dav1d" "1.5.2" dav1d
|
||||
|
||||
clone "https://github.com/FFmpeg/FFmpeg" "n8.0" ffmpeg
|
||||
|
||||
clone "https://gitlab.freedesktop.org/freetype/freetype.git" "VER-2-14-1" freetype2 --recurse-submodules
|
||||
|
||||
clone "https://github.com/libass/libass" "master" libass
|
||||
|
||||
clone "https://github.com/haasn/libplacebo" "master" libplacebo --recurse-submodules
|
||||
|
||||
clone "https://github.com/mpv-player/mpv" "master" mpv
|
||||
|
||||
if [[ ! -d mbedtls ]]; then
|
||||
mkdir mbedtls
|
||||
wget https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-3.6.4/mbedtls-3.6.4.tar.bz2 -O - | \
|
||||
tar -xj -C mbedtls --strip-components=1
|
||||
fi
|
||||
|
||||
if [[ ! -d fribidi ]]; then
|
||||
mkdir fribidi
|
||||
wget https://github.com/fribidi/fribidi/releases/download/v1.0.16/fribidi-1.0.16.tar.xz -O - | \
|
||||
tar -xJ -C fribidi --strip-components=1
|
||||
fi
|
||||
|
||||
if [[ ! -d harfbuzz ]]; then
|
||||
mkdir harfbuzz
|
||||
wget https://github.com/harfbuzz/harfbuzz/releases/download/12.1.0/harfbuzz-12.1.0.tar.xz -O - | \
|
||||
tar -xJ -C harfbuzz --strip-components=1
|
||||
fi
|
||||
|
||||
version_unibreak="6.1"
|
||||
if [[ ! -d unibreak ]]; then
|
||||
mkdir unibreak
|
||||
wget https://github.com/adah1972/libunibreak/releases/download/libunibreak_${version_unibreak//./_}/libunibreak-${version_unibreak}.tar.gz -O - | \
|
||||
tar -xz -C unibreak --strip-components=1
|
||||
fi
|
||||
|
||||
if [[ ! -d lua ]]; then
|
||||
mkdir lua
|
||||
wget https://www.lua.org/ftp/lua-5.2.4.tar.gz -O - | \
|
||||
tar -xz -C lua --strip-components=1
|
||||
fi
|
||||
|
||||
# python packages: jsonschema jinja2 meson
|
||||
91
scripts/mpv/include/ci.sh
Executable file
91
scripts/mpv/include/ci.sh
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# go to buildscripts root folder
|
||||
cd "$( dirname "${BASH_SOURCE[0]}" )/.."
|
||||
|
||||
. ./include/depinfo.sh
|
||||
|
||||
msg() {
|
||||
printf '==> %s\n' "$1"
|
||||
}
|
||||
|
||||
fetch_prefix() {
|
||||
if [[ "$CACHE_MODE" == folder ]]; then
|
||||
local text=
|
||||
if [ -f "$CACHE_FOLDER/id.txt" ]; then
|
||||
text=$(cat "$CACHE_FOLDER/id.txt")
|
||||
else
|
||||
echo "Cache seems to be empty"
|
||||
fi
|
||||
printf 'Expecting "%s",\nfound "%s".\n' "$ci_tarball" "$text"
|
||||
if [[ "$text" == "$ci_tarball" ]]; then
|
||||
tar -xzf "$CACHE_FOLDER/data.tgz" -C prefix && return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
build_prefix() {
|
||||
msg "Building the prefix ($ci_tarball)..."
|
||||
|
||||
msg "Fetching deps"
|
||||
IN_CI=1 ./include/download-deps.sh
|
||||
|
||||
# build everything mpv depends on (but not mpv itself)
|
||||
for x in ${dep_mpv[@]}; do
|
||||
msg "Building $x"
|
||||
./buildall.sh $x
|
||||
done
|
||||
|
||||
if [[ "$CACHE_MODE" == folder && -w "$CACHE_FOLDER" ]]; then
|
||||
msg "Compressing the prefix"
|
||||
tar -cvzf "$CACHE_FOLDER/data.tgz" -C prefix .
|
||||
echo "$ci_tarball" >"$CACHE_FOLDER/id.txt"
|
||||
fi
|
||||
}
|
||||
|
||||
export WGET="wget --progress=bar:force"
|
||||
|
||||
if [ "$1" = "export" ]; then
|
||||
# export variable with unique cache identifier
|
||||
echo "CACHE_IDENTIFIER=$ci_tarball"
|
||||
exit 0
|
||||
elif [ "$1" = "install" ]; then
|
||||
# install deps
|
||||
if [[ -n "$ANDROID_HOME" && -d "$ANDROID_HOME" ]]; then
|
||||
msg "Linking existing SDK"
|
||||
mkdir -p sdk
|
||||
ln -sv "$ANDROID_HOME" sdk/android-sdk-linux
|
||||
fi
|
||||
|
||||
msg "Fetching SDK + NDK"
|
||||
IN_CI=1 ./include/download-sdk.sh
|
||||
|
||||
msg "Fetching mpv"
|
||||
mkdir -p deps/mpv
|
||||
$WGET https://github.com/mpv-player/mpv/archive/master.tar.gz -O master.tgz
|
||||
tar -xzf master.tgz -C deps/mpv --strip-components=1
|
||||
rm master.tgz
|
||||
|
||||
msg "Trying to fetch existing prefix"
|
||||
mkdir -p prefix
|
||||
fetch_prefix || build_prefix
|
||||
exit 0
|
||||
elif [ "$1" = "build" ]; then
|
||||
# run build
|
||||
:
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
msg "Building mpv"
|
||||
./buildall.sh -n mpv || {
|
||||
# show logfile if configure failed
|
||||
[ ! -f deps/mpv/_build/config.h ] && cat deps/mpv/_build/meson-logs/meson-log.txt
|
||||
exit 1
|
||||
}
|
||||
|
||||
msg "Building mpv-android"
|
||||
./buildall.sh -n
|
||||
|
||||
exit 0
|
||||
43
scripts/mpv/include/depinfo.sh
Executable file
43
scripts/mpv/include/depinfo.sh
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
## Dependency versions
|
||||
# Make sure to keep v_ndk and v_ndk_n in sync, both are listed on the NDK download page
|
||||
|
||||
v_sdk=11076708_latest
|
||||
v_ndk=r29
|
||||
v_ndk_n=29.0.14206865
|
||||
v_sdk_platform=35
|
||||
v_sdk_build_tools=35.0.0
|
||||
|
||||
v_lua=5.2.4
|
||||
v_unibreak=6.1
|
||||
v_harfbuzz=12.1.0
|
||||
v_fribidi=1.0.16
|
||||
v_freetype=2.14.1
|
||||
v_mbedtls=3.6.4
|
||||
|
||||
|
||||
## Dependency tree
|
||||
# I would've used a dict but putting arrays in a dict is not a thing
|
||||
|
||||
dep_mbedtls=()
|
||||
dep_dav1d=()
|
||||
dep_ffmpeg=(mbedtls dav1d)
|
||||
dep_freetype2=()
|
||||
dep_fribidi=()
|
||||
dep_harfbuzz=()
|
||||
dep_unibreak=()
|
||||
dep_libass=(freetype2 fribidi harfbuzz unibreak)
|
||||
dep_lua=()
|
||||
dep_libplacebo=()
|
||||
dep_mpv=(ffmpeg libass lua libplacebo)
|
||||
dep_mpv_android=(mpv)
|
||||
|
||||
|
||||
## for CI workflow
|
||||
|
||||
# pinned ffmpeg revision
|
||||
v_ci_ffmpeg=n8.0
|
||||
|
||||
# filename used to uniquely identify a build prefix
|
||||
ci_tarball="prefix-ndk-${v_ndk}-lua-${v_lua}-unibreak-${v_unibreak}-harfbuzz-${v_harfbuzz}-fribidi-${v_fribidi}-freetype-${v_freetype}-mbedtls-${v_mbedtls}-ffmpeg-${v_ci_ffmpeg}.tgz"
|
||||
32
scripts/mpv/include/path.sh
Executable file
32
scripts/mpv/include/path.sh
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
|
||||
|
||||
. "$DIR/include/depinfo.sh"
|
||||
|
||||
os=linux
|
||||
[[ "$OSTYPE" == "darwin"* ]] && os=mac
|
||||
export os
|
||||
|
||||
if [ "$os" == "mac" ]; then
|
||||
[ -z "$cores" ] && cores=$(sysctl -n hw.ncpu)
|
||||
# various things rely on GNU behaviour
|
||||
export INSTALL=`which ginstall`
|
||||
export SED=gsed
|
||||
else
|
||||
[ -z "$cores" ] && cores=$(grep -c ^processor /proc/cpuinfo)
|
||||
fi
|
||||
cores=${cores:-4}
|
||||
|
||||
# configure pkg-config paths if inside buildscripts
|
||||
if [ -n "$ndk_triple" ]; then
|
||||
export PKG_CONFIG_SYSROOT_DIR="$prefix_dir"
|
||||
export PKG_CONFIG_LIBDIR="$PKG_CONFIG_SYSROOT_DIR/lib/pkgconfig"
|
||||
unset PKG_CONFIG_PATH
|
||||
fi
|
||||
|
||||
toolchain=$(echo "$DIR/sdk/android-ndk-${v_ndk}/toolchains/llvm/prebuilt/"*)
|
||||
[ -d "$toolchain" ] && \
|
||||
export PATH="$toolchain/bin:$DIR/sdk/android-ndk-${v_ndk}:$DIR/sdk/bin:$PATH"
|
||||
export ANDROID_HOME="$DIR/sdk/android-sdk-$os"
|
||||
unset ANDROID_SDK_ROOT ANDROID_NDK_ROOT
|
||||
22
scripts/mpv/scripts/dav1d.sh
Executable file
22
scripts/mpv/scripts/dav1d.sh
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
. ../../include/path.sh
|
||||
|
||||
build=_build$ndk_suffix
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
rm -rf $build
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
unset CC CXX # meson wants these unset
|
||||
|
||||
meson setup $build --cross-file "$prefix_dir"/crossfile.txt \
|
||||
-Denable_tests=false -Db_lto=true -Dstack_alignment=16
|
||||
|
||||
ninja -C $build -j$cores
|
||||
DESTDIR="$prefix_dir" ninja -C $build install
|
||||
48
scripts/mpv/scripts/ffmpeg.sh
Executable file
48
scripts/mpv/scripts/ffmpeg.sh
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
. ../../include/path.sh
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
rm -rf _build$ndk_suffix
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
mkdir -p _build$ndk_suffix
|
||||
cd _build$ndk_suffix
|
||||
|
||||
cpu=armv7-a
|
||||
[[ "$ndk_triple" == "aarch64"* ]] && cpu=armv8-a
|
||||
[[ "$ndk_triple" == "x86_64"* ]] && cpu=generic
|
||||
[[ "$ndk_triple" == "i686"* ]] && cpu="i686 --disable-asm"
|
||||
|
||||
cpuflags=
|
||||
[[ "$ndk_triple" == "arm"* ]] && cpuflags="$cpuflags -mfpu=neon -mcpu=cortex-a8"
|
||||
|
||||
args=(
|
||||
--target-os=android --enable-cross-compile
|
||||
--cross-prefix=$ndk_triple- --cc=$CC --pkg-config=pkg-config --nm=llvm-nm
|
||||
--arch=${ndk_triple%%-*} --cpu=$cpu
|
||||
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib"
|
||||
|
||||
--enable-{jni,mediacodec,mbedtls,libdav1d} --disable-vulkan
|
||||
--disable-static --enable-shared --enable-{gpl,version3}
|
||||
|
||||
# disable unneeded parts
|
||||
--disable-{stripping,doc,programs}
|
||||
# to keep the build lean we disable some feature quite aggressively:
|
||||
# - muxers, encoders: mpv-android does not have any way to use these
|
||||
# - devices: no practical use on Android
|
||||
--disable-{muxers,encoders,devices}
|
||||
# useful to taking screenshots
|
||||
--enable-encoder=mjpeg,png
|
||||
# useful for the `dump-cache` command
|
||||
--enable-muxer=mov,matroska,mpegts
|
||||
)
|
||||
../configure "${args[@]}"
|
||||
|
||||
make -j$cores
|
||||
make DESTDIR="$prefix_dir" install
|
||||
21
scripts/mpv/scripts/freetype2.sh
Executable file
21
scripts/mpv/scripts/freetype2.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
. ../../include/path.sh
|
||||
|
||||
build=_build$ndk_suffix
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
rm -rf $build
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
unset CC CXX # meson wants these unset
|
||||
|
||||
meson setup $build --cross-file "$prefix_dir"/crossfile.txt
|
||||
|
||||
ninja -C $build -j$cores
|
||||
DESTDIR="$prefix_dir" ninja -C $build install
|
||||
22
scripts/mpv/scripts/fribidi.sh
Executable file
22
scripts/mpv/scripts/fribidi.sh
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
. ../../include/path.sh
|
||||
|
||||
build=_build$ndk_suffix
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
rm -rf $build
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
unset CC CXX # meson wants these unset
|
||||
|
||||
meson setup $build --cross-file "$prefix_dir"/crossfile.txt \
|
||||
-D{tests,docs}=false
|
||||
|
||||
ninja -C $build -j$cores
|
||||
DESTDIR="$prefix_dir" ninja -C $build install
|
||||
22
scripts/mpv/scripts/harfbuzz.sh
Executable file
22
scripts/mpv/scripts/harfbuzz.sh
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
. ../../include/path.sh
|
||||
|
||||
build=_build$ndk_suffix
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
rm -rf $build
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
unset CC CXX # meson wants these unset
|
||||
|
||||
meson setup $build --cross-file "$prefix_dir"/crossfile.txt \
|
||||
-Dtests=disabled -Ddocs=disabled
|
||||
|
||||
ninja -C $build -j$cores
|
||||
DESTDIR="$prefix_dir" ninja -C $build install
|
||||
25
scripts/mpv/scripts/libass.sh
Executable file
25
scripts/mpv/scripts/libass.sh
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
. ../../include/path.sh
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
rm -rf _build$ndk_suffix
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
[ -f configure ] || ./autogen.sh
|
||||
|
||||
mkdir -p _build$ndk_suffix
|
||||
cd _build$ndk_suffix
|
||||
|
||||
../configure \
|
||||
--host=$ndk_triple --with-pic \
|
||||
--enable-static --disable-shared \
|
||||
--enable-libunibreak --disable-require-system-font-provider
|
||||
|
||||
make -j$cores
|
||||
make DESTDIR="$prefix_dir" install
|
||||
25
scripts/mpv/scripts/libplacebo.sh
Executable file
25
scripts/mpv/scripts/libplacebo.sh
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
. ../../include/path.sh
|
||||
|
||||
build=_build$ndk_suffix
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
rm -rf $build
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
unset CC CXX
|
||||
meson setup $build --cross-file "$prefix_dir"/crossfile.txt \
|
||||
-Dvulkan=disabled -Ddemos=false
|
||||
|
||||
ninja -C $build -j$cores
|
||||
DESTDIR="$prefix_dir" ninja -C $build install
|
||||
|
||||
# add missing library for static linking
|
||||
# this isn't "-lstdc++" due to a meson bug: https://github.com/mesonbuild/meson/issues/11300
|
||||
${SED:-sed} '/^Libs:/ s|$| -lc++|' "$prefix_dir/lib/pkgconfig/libplacebo.pc" -i
|
||||
44
scripts/mpv/scripts/lua.sh
Executable file
44
scripts/mpv/scripts/lua.sh
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
. ../../include/path.sh
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
make clean
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# Building seperately from source tree is not supported, this means we are forced to always clean
|
||||
$0 clean
|
||||
|
||||
mycflags=(
|
||||
# ensures correct linking into libmpv.so
|
||||
-fPIC
|
||||
# bionic is missing decimal_point in localeconv [src/llex.c]
|
||||
-Dgetlocaledecpoint\\\(\\\)=\\\(46\\\)
|
||||
# force fallback as ftello/fseeko are not defined [src/liolib.c]
|
||||
-Dlua_fseek
|
||||
)
|
||||
|
||||
# LUA_T= and LUAC_T= to disable building lua & luac
|
||||
# -Dgetlocaledecpoint()=('.') fixes bionic missing decimal_point in localeconv
|
||||
make CC="$CC" AR="$AR rc" RANLIB="$RANLIB" \
|
||||
MYCFLAGS="${mycflags[*]}" \
|
||||
PLAT=linux LUA_T= LUAC_T= -j$cores
|
||||
|
||||
# TO_BIN=/dev/null disables installing lua & luac
|
||||
make INSTALL=${INSTALL:-install} INSTALL_TOP="$prefix_dir" TO_BIN=/dev/null install
|
||||
|
||||
# make pc only generates a partial pkg-config file because ????
|
||||
mkdir -p $prefix_dir/lib/pkgconfig
|
||||
make pc >$prefix_dir/lib/pkgconfig/lua.pc
|
||||
cat >>$prefix_dir/lib/pkgconfig/lua.pc <<'EOF'
|
||||
Name: Lua
|
||||
Description:
|
||||
Version: ${version}
|
||||
Libs: -L${libdir} -llua
|
||||
Cflags: -I${includedir}
|
||||
EOF
|
||||
22
scripts/mpv/scripts/mbedtls.sh
Executable file
22
scripts/mpv/scripts/mbedtls.sh
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
. ../../include/path.sh
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
make clean
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
$0 clean # separate building not supported, always clean
|
||||
if [[ "$ndk_triple" == "i686"* ]]; then
|
||||
./scripts/config.py unset MBEDTLS_AESNI_C
|
||||
else
|
||||
./scripts/config.py set MBEDTLS_AESNI_C
|
||||
fi
|
||||
|
||||
make -j$cores no_test
|
||||
make DESTDIR="$prefix_dir" install
|
||||
77
scripts/mpv/scripts/mpv-android.sh
Executable file
77
scripts/mpv/scripts/mpv-android.sh
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
BUILD="$DIR/.."
|
||||
MPV_ANDROID="$DIR/../.."
|
||||
|
||||
. $BUILD/include/path.sh
|
||||
. $BUILD/include/depinfo.sh
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
rm -rf $MPV_ANDROID/{app,.}/build $MPV_ANDROID/app/src/main/{libs,obj}
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
[ -n "$ANDROID_SIGNING_KEY" ] && BUNDLE=1
|
||||
|
||||
nativeprefix () {
|
||||
if [ -f $BUILD/prefix/$1/lib/libmpv.so ]; then
|
||||
echo $BUILD/prefix/$1
|
||||
else
|
||||
echo >&2 "Warning: libmpv.so not found in native prefix for $1, support will be omitted"
|
||||
fi
|
||||
}
|
||||
|
||||
prefix32=$(nativeprefix "armv7l")
|
||||
prefix64=$(nativeprefix "arm64")
|
||||
prefix_x64=$(nativeprefix "x86_64")
|
||||
prefix_x86=$(nativeprefix "x86")
|
||||
|
||||
if [[ -z "$prefix32" && -z "$prefix64" && -z "$prefix_x64" && -z "$prefix_x86" ]]; then
|
||||
echo >&2 "Error: no mpv library detected."
|
||||
exit 255
|
||||
fi
|
||||
|
||||
PREFIX32=$prefix32 PREFIX64=$prefix64 PREFIX_X64=$prefix_x64 PREFIX_X86=$prefix_x86 \
|
||||
ndk-build -C app/src/main -j$cores
|
||||
|
||||
targets=(assembleDebug)
|
||||
if [ -z "$DONT_BUILD_RELEASE" ]; then
|
||||
targets+=(assembleRelease)
|
||||
[ -n "$BUNDLE" ] && targets+=(bundleRelease)
|
||||
fi
|
||||
./gradlew "${targets[@]}"
|
||||
|
||||
if [ -n "$ANDROID_SIGNING_KEY" ]; then
|
||||
cd "${MPV_ANDROID}/app/build/outputs/apk"
|
||||
apksigner=${ANDROID_HOME}/build-tools/${v_sdk_build_tools}/apksigner
|
||||
for v in default api29; do
|
||||
pushd $v
|
||||
# sign the universal debug APK
|
||||
"$apksigner" sign --ks "${ANDROID_SIGNING_KEY}" \
|
||||
--in debug/app-$v-universal-debug.apk --out debug/app-$v-universal-debug-signed.apk
|
||||
# but all of the release APKs
|
||||
for apk in release/*-unsigned.apk; do
|
||||
"$apksigner" sign --ks "${ANDROID_SIGNING_KEY}" \
|
||||
--in $apk --out ${apk/-unsigned/-signed}
|
||||
done
|
||||
popd
|
||||
done
|
||||
# and the bundle
|
||||
cd ../bundle
|
||||
if [ -n "$BUNDLE" ]; then
|
||||
if [ -z "$ANDROID_SIGNING_ALIAS" ]; then
|
||||
echo >&2 "Error: ANDROID_SIGNING_ALIAS must be set to use jarsigner"
|
||||
exit 1
|
||||
fi
|
||||
pushd defaultRelease
|
||||
jarsigner -keystore "${ANDROID_SIGNING_KEY}" -signedjar \
|
||||
app-default-release-signed.aab app-default-release.aab \
|
||||
"${ANDROID_SIGNING_ALIAS}"
|
||||
popd
|
||||
fi
|
||||
fi
|
||||
30
scripts/mpv/scripts/mpv.sh
Executable file
30
scripts/mpv/scripts/mpv.sh
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
. ../../include/path.sh
|
||||
|
||||
build=_build$ndk_suffix
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
rm -rf $build
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
unset CC CXX # meson wants these unset
|
||||
|
||||
meson setup $build --cross-file "$prefix_dir"/crossfile.txt \
|
||||
--default-library shared \
|
||||
-Diconv=disabled -Dlua=enabled \
|
||||
-Dlibmpv=true -Dcplayer=false \
|
||||
-Dmanpage-build=disabled
|
||||
|
||||
ninja -C $build -j$cores
|
||||
if [ -f $build/libmpv.a ]; then
|
||||
echo >&2 "Meson fucked up, forcing rebuild."
|
||||
$0 clean
|
||||
exec $0 build
|
||||
fi
|
||||
DESTDIR="$prefix_dir" ninja -C $build install
|
||||
24
scripts/mpv/scripts/unibreak.sh
Executable file
24
scripts/mpv/scripts/unibreak.sh
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
. ../../include/path.sh
|
||||
|
||||
build=_build$ndk_suffix
|
||||
|
||||
if [ "$1" == "build" ]; then
|
||||
true
|
||||
elif [ "$1" == "clean" ]; then
|
||||
rm -rf $build
|
||||
exit 0
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
|
||||
mkdir -p $build
|
||||
cd $build
|
||||
|
||||
../configure \
|
||||
--host=$ndk_triple --with-pic \
|
||||
--enable-static --disable-shared
|
||||
|
||||
make -j$cores
|
||||
make DESTDIR="$prefix_dir" install
|
||||
Loading…
Add table
Add a link
Reference in a new issue