ddnet/scripts/compile_libs/make_lib_opusfile.sh

80 lines
1.9 KiB
Bash
Raw Normal View History

2021-08-24 10:18:20 +00:00
#!/bin/bash
ANDROID_HOME=~/Android/Sdk
ANDROID_NDK="$(find "$ANDROID_HOME/ndk" -maxdepth 1 | sort -n | tail -1)"
export MAKEFLAGS=-j32
2022-03-25 08:26:37 +00:00
export CXXFLAGS="$3"
export CFLAGS="$3"
export CPPFLAGS="$4"
export LDFLAGS="$4"
2021-08-24 10:18:20 +00:00
export ANDROID_NDK_ROOT="$ANDROID_NDK"
function make_opusfile() {
_EXISTS_PROJECT=0
if [ -d "$1" ]; then
_EXISTS_PROJECT=1
else
mkdir "$1"
fi
(
cd "$1" || exit 1
if [[ "$_EXISTS_PROJECT" == 0 ]]; then
2022-10-25 16:51:56 +00:00
#not nice but doesn't matter
2021-08-24 10:18:20 +00:00
cp -R ../../ogg/include .
cp -R ../../opus/include .
cp -R ../../ogg/"$2"/include/ogg/* include/ogg/
cp ../../ogg/"$2"/libogg.a libogg.a
cp ../../opus/"$2"/libopus.a libopus.a
fi
2022-03-25 08:26:37 +00:00
TMP_COMPILER=""
TMP_AR=""
if [[ "${5}" == "android" ]]; then
TMP_COMPILER="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/$3$4-clang"
TMP_AR="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
elif [[ "${5}" == "webasm" ]]; then
TMP_COMPILER="emcc"
TMP_AR="emar"
fi
${TMP_COMPILER} \
2021-08-24 10:18:20 +00:00
-c \
-fPIC \
-I"${PWD}"/../include \
-I"${PWD}"/include \
../src/opusfile.c \
../src/info.c \
../src/internal.c
2022-03-25 08:26:37 +00:00
${TMP_COMPILER} \
2021-08-24 10:18:20 +00:00
-c \
-fPIC \
-I"${PWD}"/../include \
-I"${PWD}"/include \
-include stdio.h \
../src/stream.c
2022-03-25 08:26:37 +00:00
${TMP_AR} \
2021-08-24 10:18:20 +00:00
rvs \
libopusfile.a \
opusfile.o \
info.o \
stream.o \
internal.o
)
}
function compile_all_opusfile() {
2022-03-25 08:26:37 +00:00
if [[ "${2}" == "android" ]]; then
make_opusfile build_"$2"_arm build_"$2"_arm armv7a-linux-androideabi "$1" "$2"
make_opusfile build_"$2"_arm64 build_"$2"_arm64 aarch64-linux-android "$1" "$2"
make_opusfile build_"$2"_x86 build_"$2"_x86 i686-linux-android "$1" "$2"
make_opusfile build_"$2"_x86_64 build_"$2"_x86_64 x86_64-linux-android "$1" "$2"
elif [[ "${2}" == "webasm" ]]; then
make_opusfile build_"$2"_wasm build_"$2"_wasm "" "$1" "$2"
fi
2021-08-24 10:18:20 +00:00
}
2022-03-25 08:26:37 +00:00
compile_all_opusfile "$1" "$2"