aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skqp/make_universal_apk
blob: 56b725380b3a2542621cece25817179a76e27831 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! /bin/sh

# Copyright 2018 Google Inc.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

usage() {
    cat >&2 <<EOM

This script can be run with no arguments, in which case it will produce an
APK with native libraries for all four architectures: arm, arm64, x86, and
x64.  You can instead list the architectures you want as arguments to this
script.  For example:

    $0 arm x86

The environment variables ANDROID_NDK and ANDROID_HOME must be set to the
locations of the Android NDK and SDK.  Current values:

    ANDROID_NDK="$ANDROID_NDK"
    ANDROID_HOME="$ANDROID_HOME"

Additionally, \`python\` and \`ninja\` should be in your path.

If SKQP_EXTRA_MODELS is non-empty, assets unneeded by the CTS tests will be
included for experimental mode.

EOM
    exit 1
}

[ -d "$ANDROID_NDK"  ] || usage
[ -d "$ANDROID_HOME" ] || usage
command -v ninja  > /dev/null || usage
command -v python > /dev/null || usage
for ARCH in $*; do case $ARCH in arm|arm64|x86|x64);; *) usage;; esac; done

set -x # Verbose
set -e # Exit immediately

cd "$(dirname "$0")/../.."

(
    cd platform_tools/android/apps
    git clean -fxd skqp/build \
                   skqp/src/main/assets/gmkb \
                   skqp/src/main/assets/resources \
                   skqp/src/main/libs \
                   .gradle build viewer/build
)
python tools/skqp/download_model
if [ -z "$SKQP_EXTRA_MODELS" ]; then
    python tools/skqp/remove_unneeded_assets
fi

python tools/skqp/setup_resources
python tools/git-sync-deps

APP=skqp
LIB=libskqp_app.so

find platform_tools/android/apps/$APP -name $LIB -exec rm {} +

if [ $# -eq 0 ]; then
    set -- arm arm64 x86 x64
fi

for ARCH in $*; do
    if [ "$SKQP_DEBUG" ]; then
        BUILD=out/skqp-${ARCH}-debug
        python tools/skqp/generate_gn_args $BUILD "$ANDROID_NDK" --arch "$ARCH" --debug
    else
        BUILD=out/skqp-$ARCH
        python tools/skqp/generate_gn_args $BUILD "$ANDROID_NDK" --arch "$ARCH"
    fi
    bin/gn gen $BUILD
    ninja -C $BUILD $LIB
    case $ARCH in
        arm)    NATIVE=armeabi-v7a ;;
        arm64)  NATIVE=arm64-v8a   ;;
        x86)    NATIVE=x86         ;;
        x64)    NATIVE=x86_64      ;;
        *)      usage              ;;
    esac
    DST=platform_tools/android/apps/$APP/src/main/libs/$NATIVE
    mkdir -p $DST
    cp -a $BUILD/$LIB $DST/$LIB
done

(
    cd platform_tools/android
    apps/gradlew -p apps/$APP -P suppressNativeBuild :$APP:assembleUniversalDebug
)

mkdir -p out/skqp
cp platform_tools/android/apps/$APP/build/outputs/apk/$APP-universal-debug.apk out/skqp/