summaryrefslogtreecommitdiff
path: root/scripts/android/run.sh
blob: 9381edfeed728c6091c07ad96be48d9e17a528c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash

set -e
set -o pipefail

# Add Mason to PATH
export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason"
export MASON_PLATFORM=android
export MASON_ANDROID_ABI=${ANDROID_ABI}

################################################################################
# Build
################################################################################

mkdir -p ./android/MapboxGLAndroidSDKTestApp/src/main/res/raw
echo "${MAPBOX_ACCESS_TOKEN}" > ./android/MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt

mapbox_time "compile_library" \
make android-lib HOST_VERSION=${ANDROID_ABI} -j${JOBS} BUILDTYPE=${BUILDTYPE}

mapbox_time "build_apk" \
make android HOST_VERSION=${ANDROID_ABI} -j${JOBS} BUILDTYPE=${BUILDTYPE}

################################################################################
# Deploy
################################################################################

if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then
    # Install and add awscli to PATH for uploading the results
    mapbox_time "install_awscli" \
    pip install --user awscli
    export PATH="`python -m site --user-base`/bin:${PATH}"

    mapbox_time_start "deploy_results"
    echo "Deploying results..."

    S3_PREFIX=s3://mapbox/mapbox-gl-native/android/build/${TRAVIS_JOB_NUMBER}
    APK_OUTPUTS=./android/MapboxGLAndroidSDKTestApp/build/outputs/apk
    JNILIB=`mason env JNIDIR`

    # ARM64 does not build APK for now
    if [ ${JNIDIR} != "arm64-v8a" ] ; then
        # Upload either the debug or the release build
        if [ ${BUILDTYPE} == "Debug" ] ; then
            aws s3 cp \
                ${APK_OUTPUTS}/MapboxGLAndroidSDKTestApp-${JNILIB}-debug.apk \
                ${S3_PREFIX}/MapboxGLAndroidSDKTestApp-debug.apk
        elif [ ${BUILDTYPE} == "Release" ] ; then
            aws s3 cp \
                ${APK_OUTPUTS}/MapboxGLAndroidSDKTestApp-${JNILIB}-release-unsigned.apk \
                ${S3_PREFIX}/MapboxGLAndroidSDKTestApp-release-unsigned.apk
        fi
    fi

    mapbox_time_finish
fi