| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Usage: the first argument selects the build type: |
| 4 |
# - release, to build release only |
| 5 |
# - debug, to build debug only |
| 6 |
# - continuous, to build release and debug |
| 7 |
# - presubmit, for presubmit builds |
| 8 |
# |
| 9 |
# The default is release |
| 10 |
|
| 11 |
NDK_VERSION="ndk;22.1.7171670" |
| 12 |
ANDROID_NDK_VERSION=22 |
| 13 |
|
| 14 |
echo "This script is intended to run in a CI environment and may modify your current environment." |
| 15 |
echo "Please refer to BUILDING.md for more information." |
| 16 |
|
| 17 |
read -r -p "Do you wish to proceed (y/n)? " choice |
| 18 |
case "${choice}" in |
| 19 |
y|Y) |
| 20 |
echo "Build will proceed..." |
| 21 |
;; |
| 22 |
n|N) |
| 23 |
exit 0 |
| 24 |
;; |
| 25 |
*) |
| 26 |
exit 0 |
| 27 |
;; |
| 28 |
esac |
| 29 |
|
| 30 |
set -e |
| 31 |
set -x |
| 32 |
|
| 33 |
UNAME=`echo $(uname)` |
| 34 |
LC_UNAME=`echo $UNAME | tr '[:upper:]' '[:lower:]'` |
| 35 |
|
| 36 |
FILAMENT_ANDROID_CI_BUILD=true |
| 37 |
|
| 38 |
# build-common.sh will generate the following variables: |
| 39 |
# $GENERATE_ARCHIVES |
| 40 |
# $BUILD_DEBUG |
| 41 |
# $BUILD_RELEASE |
| 42 |
source `dirname $0`/../common/ci-common.sh |
| 43 |
if [[ "$LC_UNAME" == "linux" ]]; then |
| 44 |
source `dirname $0`/../linux/ci-common.sh |
| 45 |
elif [[ "$LC_UNAME" == "darwin" ]]; then |
| 46 |
source `dirname $0`/../mac/ci-common.sh |
| 47 |
fi |
| 48 |
source `dirname $0`/../common/build-common.sh |
| 49 |
|
| 50 |
# Only update and install the NDK if necessary, as this can be slow |
| 51 |
ndk_side_by_side="${ANDROID_HOME}/ndk/" |
| 52 |
if [[ -d $ndk_side_by_side ]]; then |
| 53 |
ndk_version=`ls ${ndk_side_by_side} | sort -V | tail -n 1 | cut -f 1 -d "."` |
| 54 |
if [[ ${ndk_version} -lt ${ANDROID_NDK_VERSION} ]]; then |
| 55 |
${ANDROID_HOME}/tools/bin/sdkmanager "${NDK_VERSION}" > /dev/null |
| 56 |
fi |
| 57 |
else |
| 58 |
${ANDROID_HOME}/tools/bin/sdkmanager "${NDK_VERSION}" > /dev/null |
| 59 |
fi |
| 60 |
|
| 61 |
# Only build 1 32 bit and 1 64 bit target during presubmit to cut down build times |
| 62 |
# Continuous builds will build everything |
| 63 |
ANDROID_ABIS= |
| 64 |
if [[ "$TARGET" == "presubmit" ]]; then |
| 65 |
ANDROID_ABIS="-q arm64-v8a,x86" |
| 66 |
fi |
| 67 |
|
| 68 |
pushd `dirname $0`/../.. > /dev/null |
| 69 |
./build.sh -p android $ANDROID_ABIS -c $GENERATE_ARCHIVES $BUILD_DEBUG $BUILD_RELEASE |