blob: 005e4cc9a89ff4f042d6393c6e10c9a12744bfab [file] [log] [blame]
Don Turneraef269e2020-02-19 17:46:23 +00001# 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 Turnercac71722020-06-01 21:39:02 +010015# Script to build Oboe for multiple Android ABIs and prepare them for distribution
Don Turneraef269e2020-02-19 17:46:23 +000016# 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
23if [ -z "$ANDROID_NDK" ]; then
24 echo "Please set ANDROID_NDK to the Android NDK folder"
25 exit 1
26fi
27
28# Directories, paths and filenames
29BUILD_DIR=build
30
31CMAKE_ARGS="-H. \
Don Turnercac71722020-06-01 21:39:02 +010032 -DBUILD_SHARED_LIBS=true \
Don Turneraef269e2020-02-19 17:46:23 +000033 -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
39function 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
61build_oboe armeabi-v7a 16
62build_oboe arm64-v8a 21
63build_oboe x86 16
64build_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 Turnercac71722020-06-01 21:39:02 +010069# build_oboe mips64