Don Turner | aef269e | 2020-02-19 17:46:23 +0000 | [diff] [blame] | 1 | # Copyright 2017 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Don Turner | cac7172 | 2020-06-01 21:39:02 +0100 | [diff] [blame] | 15 | # Script to build Oboe for multiple Android ABIs and prepare them for distribution |
Don Turner | aef269e | 2020-02-19 17:46:23 +0000 | [diff] [blame] | 16 | # via Prefab (github.com/google/prefab) |
| 17 | # |
| 18 | # Ensure that ANDROID_NDK environment variable is set to your Android NDK location |
| 19 | # e.g. /Library/Android/sdk/ndk-bundle |
| 20 | |
| 21 | #!/bin/bash |
| 22 | |
| 23 | if [ -z "$ANDROID_NDK" ]; then |
| 24 | echo "Please set ANDROID_NDK to the Android NDK folder" |
| 25 | exit 1 |
| 26 | fi |
| 27 | |
| 28 | # Directories, paths and filenames |
| 29 | BUILD_DIR=build |
| 30 | |
| 31 | CMAKE_ARGS="-H. \ |
Don Turner | cac7172 | 2020-06-01 21:39:02 +0100 | [diff] [blame] | 32 | -DBUILD_SHARED_LIBS=true \ |
Don Turner | aef269e | 2020-02-19 17:46:23 +0000 | [diff] [blame] | 33 | -DCMAKE_BUILD_TYPE=Release \ |
| 34 | -DANDROID_TOOLCHAIN=clang \ |
| 35 | -DANDROID_STL=c++_shared \ |
| 36 | -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \ |
| 37 | -DCMAKE_INSTALL_PREFIX=." |
| 38 | |
| 39 | function build_oboe { |
| 40 | |
| 41 | ABI=$1 |
| 42 | MINIMUM_API_LEVEL=$2 |
| 43 | ABI_BUILD_DIR=build/${ABI} |
| 44 | STAGING_DIR=staging |
| 45 | |
| 46 | echo "Building Oboe for ${ABI}" |
| 47 | |
| 48 | mkdir -p ${ABI_BUILD_DIR} ${ABI_BUILD_DIR}/${STAGING_DIR} |
| 49 | |
| 50 | cmake -B${ABI_BUILD_DIR} \ |
| 51 | -DANDROID_ABI=${ABI} \ |
| 52 | -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${STAGING_DIR}/lib/${ABI} \ |
| 53 | -DANDROID_PLATFORM=android-${MINIMUM_API_LEVEL}\ |
| 54 | ${CMAKE_ARGS} |
| 55 | |
| 56 | pushd ${ABI_BUILD_DIR} |
| 57 | make -j5 |
| 58 | popd |
| 59 | } |
| 60 | |
| 61 | build_oboe armeabi-v7a 16 |
| 62 | build_oboe arm64-v8a 21 |
| 63 | build_oboe x86 16 |
| 64 | build_oboe x86_64 21 |
| 65 | |
| 66 | # Currently unsupported ABIs |
| 67 | # build_oboe armeabi 16 - This was deprecated in Android 16 and removed in 17 |
| 68 | # build_oboe mips 21 - This was deprecated in Android 16 and removed in 17 |
Don Turner | cac7172 | 2020-06-01 21:39:02 +0100 | [diff] [blame] | 69 | # build_oboe mips64 |