Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmercerind committed Oct 13, 2024
1 parent 293d1a6 commit b12405f
Show file tree
Hide file tree
Showing 36 changed files with 1,277 additions and 283 deletions.
125 changes: 0 additions & 125 deletions buildscripts/README.md

This file was deleted.

39 changes: 14 additions & 25 deletions buildscripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cd "$( dirname "${BASH_SOURCE[0]}" )"

cleanbuild=0
nodeps=0
target=mpv-android
target=mpv
archs=(armv7l arm64 x86 x86_64)

getdeps () {
Expand All @@ -15,9 +15,8 @@ getdeps () {

loadarch () {
unset CC CXX CPATH LIBRARY_PATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH
unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS

local apilvl=26
local apilvl=21
# ndk_triple: what the toolchain actually is
# cc_triple: what Google pretends the toolchain is
if [ "$1" == "armv7l" ]; then
Expand Down Expand Up @@ -47,6 +46,11 @@ loadarch () {
export prefix_dir="$PWD/prefix/$prefix_name"
export native_dir="$PWD/../libmpv/src/main/jniLibs/$prefix_name"
export CC=$cc_triple-clang
if [[ "$1" == arm* ]]; then
export AS="$CC"
else
export AS="nasm"
fi
export CXX=$cc_triple-clang++
export LDFLAGS="-Wl,-O1,--icf=safe -Wl,-z,max-page-size=16384"
export AR=llvm-ar
Expand Down Expand Up @@ -91,7 +95,7 @@ CROSSFILE
}

build () {
if [ $1 != "mpv-android" ] && [ ! -d deps/$1 ]; then
if [ ! -d deps/$1 ]; then
printf >&2 '\e[1;31m%s\e[m\n' "Target $1 not found"
return 1
fi
Expand All @@ -103,23 +107,14 @@ build () {
build $dep
done
fi
if [ "$1" != "mpv-android" ]; then
printf >&2 '\e[1;34m%s\e[m\n' "Building $1..."
pushd deps/$1
BUILDSCRIPT=../../scripts/$1.sh
[ $cleanbuild -eq 1 ] && $BUILDSCRIPT clean

printf >&2 '\e[1;34m%s\e[m\n' "Building $1..."
pushd deps/$1
BUILDSCRIPT=../../scripts/$1.sh
sudo chmod +x $BUILDSCRIPT
[ $cleanbuild -eq 1 ] && $BUILDSCRIPT clean
$BUILDSCRIPT build
popd
fi
}

assemble () {
printf >&2 '\e[1;34m%s\e[m\n' "Assembling $1..."
pushd ..
BUILDSCRIPT=buildscripts/scripts/mpv-android.sh
[ $cleanbuild -eq 1 ] && $BUILDSCRIPT clean
$BUILDSCRIPT build
popd
}

usage () {
Expand Down Expand Up @@ -166,10 +161,4 @@ else
build $target
fi

if [ "$target" == "mpv-android" ]; then
assemble
[ -d ../libmpv/build/outputs/aar ] && ls -lh ../libmpv/build/outputs/aar/*.aar
[ -d ../libmpv/build/libs ] && ls -lh ../libmpv/build/libs/*.jar
fi

exit 0
56 changes: 56 additions & 0 deletions buildscripts/bundle_default.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# --------------------------------------------------

if [ ! -f "deps" ]; then
sudo rm -r deps
fi
if [ ! -f "prefix" ]; then
sudo rm -r prefix
fi

./download.sh
./patch.sh

# --------------------------------------------------

if [ ! -f "scripts/ffmpeg" ]; then
rm scripts/ffmpeg.sh
fi
cp flavors/default.sh scripts/ffmpeg.sh

# --------------------------------------------------

./build.sh

# --------------------------------------------------

cd deps/media-kit-android-helper

sudo chmod +x gradlew
./gradlew assembleRelease

unzip -o app/build/outputs/apk/release/app-release.apk -d app/build/outputs/apk/release

ln -sf "$(pwd)/app/build/outputs/apk/release/lib/arm64-v8a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/arm64-v8a"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/armeabi-v7a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/armeabi-v7a"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86_64/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86_64"

cd ../..

zip -r "default-arm64-v8a.jar" lib/arm64-v8a
zip -r "default-armeabi-v7a.jar" lib/armeabi-v7a
zip -r "default-x86.jar" lib/x86
zip -r "default-x86_64.jar" lib/x86_64

mkdir -p ../../../../../../../../../../output

cp *.jar ../../../../../../../../../../output

md5sum *.jar

cd ../../../../../../../../..

# --------------------------------------------------

zip -r debug-symbols-default.zip prefix/*/lib
cp debug-symbols-default.zip ../output
57 changes: 57 additions & 0 deletions buildscripts/bundle_encoders-gpl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# --------------------------------------------------
set -euxo pipefail

export ENCODERS_GPL=1

if [ -d deps ]; then
sudo rm -r deps
fi
if [ -d prefix ]; then
sudo rm -r prefix
fi

./download.sh
./patch-encoders-gpl.sh

# --------------------------------------------------

rm scripts/ffmpeg.sh
cp flavors/encoders-gpl.sh scripts/ffmpeg.sh

# --------------------------------------------------

./build.sh

# --------------------------------------------------

cd deps/media-kit-android-helper

sudo chmod +x gradlew
./gradlew assembleRelease

unzip -o app/build/outputs/apk/release/app-release.apk -d app/build/outputs/apk/release

ln -sf "$(pwd)/app/build/outputs/apk/release/lib/arm64-v8a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/arm64-v8a"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/armeabi-v7a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/armeabi-v7a"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86_64/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86_64"

cd ../..

zip -r "encoders-gpl-arm64-v8a.jar" lib/arm64-v8a
zip -r "encoders-gpl-armeabi-v7a.jar" lib/armeabi-v7a
zip -r "encoders-gpl-x86.jar" lib/x86
zip -r "encoders-gpl-x86_64.jar" lib/x86_64

mkdir -p ../../../../../../../../../../output

cp *.jar ../../../../../../../../../../output

md5sum *.jar

cd ../../../../../../../../..

# --------------------------------------------------

zip -r debug-symbols-encoders-gpl.zip prefix/*/lib
cp debug-symbols-encoders-gpl.zip ../output
56 changes: 56 additions & 0 deletions buildscripts/bundle_full.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# --------------------------------------------------

if [ ! -f "deps" ]; then
sudo rm -r deps
fi
if [ ! -f "prefix" ]; then
sudo rm -r prefix
fi

./download.sh
./patch.sh

# --------------------------------------------------

if [ ! -f "scripts/ffmpeg" ]; then
rm scripts/ffmpeg.sh
fi
cp flavors/full.sh scripts/ffmpeg.sh

# --------------------------------------------------

./build.sh

# --------------------------------------------------

cd deps/media-kit-android-helper

sudo chmod +x gradlew
./gradlew assembleRelease

unzip -o app/build/outputs/apk/release/app-release.apk -d app/build/outputs/apk/release

ln -sf "$(pwd)/app/build/outputs/apk/release/lib/arm64-v8a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/arm64-v8a"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/armeabi-v7a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/armeabi-v7a"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86_64/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86_64"

cd ../..

zip -r "full-arm64-v8a.jar" lib/arm64-v8a
zip -r "full-armeabi-v7a.jar" lib/armeabi-v7a
zip -r "full-x86.jar" lib/x86
zip -r "full-x86_64.jar" lib/x86_64

mkdir -p ../../../../../../../../../../output

cp *.jar ../../../../../../../../../../output

md5sum *.jar

cd ../../../../../../../../..

# --------------------------------------------------

zip -r debug-symbols-full.zip prefix/*/lib
cp debug-symbols-full.zip ../output
Loading

0 comments on commit b12405f

Please sign in to comment.