Skip to content

Instantly share code, notes, and snippets.

@courville
Created October 31, 2020 09:24
Show Gist options
  • Save courville/81001f5520a46f611f5173f58bb45791 to your computer and use it in GitHub Desktop.
Save courville/81001f5520a46f611f5173f58bb45791 to your computer and use it in GitHub Desktop.
#!/bin/bash
[ ! -d "opus" ] && git clone https://github.com/xiph/opus.git
# latest cmake and ndk
CMAKE_PATH=$(ls -d ${ANDROID_HOME}/cmake/* | sort -V | tail -n 1)
echo CMAKE_PATH is ${CMAKE_PATH}
NDK_PATH=$(ls -d ${ANDROID_HOME}/ndk/* | sort -V | tail -n 1)
echo NDK_PATH is ${NDK_PATH}
API_LEVEL=23
for ABI in armeabi-v7a arm64-v8a x86 x86_64
do
if [ ! -d "build-${ABI}" ]
then
mkdir -p build-${ABI}
pushd build-${ABI}
${CMAKE_PATH}/bin/cmake \
-GNinja \
-DBUILD_SHARED_LIBS=ON \
-DANDROID_ABI=${ABI} \
-DANDROID_NDK=${NDK_PATH} \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=../lib/${ABI} \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
-DANDROID_NATIVE_API_LEVEL=${API_LEVEL} \
../opus
ninja
popd
else
echo "Already built for ${ABI}"
exit 0
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment