1#! /bin/sh 2 3# Copyright 2018 Google Inc. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7usage() { 8 cat >&2 <<EOM 9 10This script can be run with no arguments, in which case it will produce an 11APK with native libraries for all four architectures: arm, arm64, x86, and 12x64. You can instead list the architectures you want as arguments to this 13script. For example: 14 15 $0 arm x86 16 17The environment variables ANDROID_NDK and ANDROID_HOME must be set to the 18locations of the Android NDK and SDK. Current values: 19 20 ANDROID_NDK="$ANDROID_NDK" 21 ANDROID_HOME="$ANDROID_HOME" 22 23Additionally, \`python\` and \`ninja\` should be in your path. 24 25If SKQP_EXTRA_MODELS is non-empty, assets unneeded by the CTS tests will be 26included for experimental mode. 27 28EOM 29 exit 1 30} 31 32[ -d "$ANDROID_NDK" ] || usage 33[ -d "$ANDROID_HOME" ] || usage 34command -v ninja > /dev/null || usage 35command -v python > /dev/null || usage 36for ARCH in $*; do case $ARCH in arm|arm64|x86|x64);; *) usage;; esac; done 37 38set -x # Verbose 39set -e # Exit immediately 40 41cd "$(dirname "$0")/../.." 42 43( 44 cd platform_tools/android/apps 45 git clean -fxd skqp/build \ 46 skqp/src/main/assets/gmkb \ 47 skqp/src/main/assets/resources \ 48 skqp/src/main/libs \ 49 .gradle build viewer/build 50) 51python tools/skqp/download_model 52if [ -z "$SKQP_EXTRA_MODELS" ]; then 53 python tools/skqp/remove_unneeded_assets 54fi 55 56python tools/skqp/setup_resources 57python tools/git-sync-deps 58 59APP=skqp 60LIB=libskqp_app.so 61 62find platform_tools/android/apps/$APP -name $LIB -exec rm {} + 63 64if [ $# -eq 0 ]; then 65 set -- arm arm64 x86 x64 66fi 67 68for ARCH in $*; do 69 if [ "$SKQP_DEBUG" ]; then 70 BUILD=out/skqp-${ARCH}-debug 71 python tools/skqp/generate_gn_args $BUILD "$ANDROID_NDK" --arch "$ARCH" --debug 72 else 73 BUILD=out/skqp-$ARCH 74 python tools/skqp/generate_gn_args $BUILD "$ANDROID_NDK" --arch "$ARCH" 75 fi 76 bin/gn gen $BUILD 77 ninja -C $BUILD $LIB 78 case $ARCH in 79 arm) NATIVE=armeabi-v7a ;; 80 arm64) NATIVE=arm64-v8a ;; 81 x86) NATIVE=x86 ;; 82 x64) NATIVE=x86_64 ;; 83 *) usage ;; 84 esac 85 DST=platform_tools/android/apps/$APP/src/main/libs/$NATIVE 86 mkdir -p $DST 87 cp -a $BUILD/$LIB $DST/$LIB 88done 89 90( 91 cd platform_tools/android 92 apps/gradlew -p apps/$APP -P suppressNativeBuild :$APP:assembleUniversalDebug 93) 94 95mkdir -p out/skqp 96cp platform_tools/android/apps/$APP/build/outputs/apk/$APP-universal-debug.apk out/skqp/ 97 98