tomato/.github/scripts/cmake-android
Green Sky fd4c16d090 Squashed 'external/toxcore/c-toxcore/' changes from da438763d5b..671b1f92332
671b1f92332 fix: toxav rtp temp buffer allocation size was too large and cast from 32bit to 16bit, causing a overflow and making the allocated size too small
258148bd4e1 chore(ci): new minimum for all android versions is 21
d369c93c489 chore: Fix Emscripten build failing with no host specified
51b24d1c239 chore: Run CompCert on the stable branch of libsodium
cab1f7d522b chore: Update WineHQ's apt key hash
102a1fa9b82 chore: Fix -Werror=maybe-uninitialized in a test
cc9515da9c7 chore: Fix cpplint failing to install
3485b5feef3 chore: Disable -Wswitch-default and -Wunsafe-buffer-usage
719041e04b6 chore: Fix Circle CI failing on a missing clang lib
5344d7f84d0 fix: Memory leak in the bootstrap daemon
fa201681e18 cleanup: Remove useless if clause
7572888a218 chore: Fix GitHub actions deprecation warnings

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: 671b1f92332a8314dccf76d5df93c0b6c1230636
2024-09-19 13:45:12 +02:00

66 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -eu
# Set up environment
NDK=$ANDROID_NDK_HOME
ABI=${1:-"armeabi-v7a"}
case $ABI in
armeabi-v7a)
TARGET=armv7a-linux-androideabi
NDK_API=21
;;
arm64-v8a)
TARGET=aarch64-linux-android
NDK_API=21
;;
x86)
TARGET=i686-linux-android
NDK_API=21
;;
x86_64)
TARGET=x86_64-linux-android
NDK_API=21
;;
*)
exit 1
;;
esac
rm -rf _android_prefix
mkdir -p _android_prefix
PREFIX=$PWD/_android_prefix
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
SYSROOT=$TOOLCHAIN/sysroot
export CC="$TOOLCHAIN/bin/$TARGET$NDK_API"-clang
export LDFLAGS=-static-libstdc++
export PKG_CONFIG_PATH="$PREFIX"/lib/pkgconfig
# Build libsodium
if [ ! -d libsodium ]; then
git clone --branch=1.0.18 https://github.com/jedisct1/libsodium.git
fi
cd libsodium
git clean -ffdx
autoreconf -fi
./configure --prefix="$PREFIX" --host="$TARGET" --with-sysroot="$SYSROOT" --disable-shared --disable-pie
make -j"$(nproc)" install
cd ..
# Build c-toxcore
rm -rf _build
mkdir -p _build
cd _build
cmake .. \
-DBUILD_TOXAV=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DCMAKE_TOOLCHAIN_FILE="$NDK/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI="$ABI" \
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DCMAKE_PREFIX_PATH="$PREFIX"
cmake --build .