Home | History | Annotate | Download | only in skqp
      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 
      7 usage() {
      8     cat >&2 <<EOM
      9 
     10 This script can be run with no arguments, in which case it will produce an
     11 APK with native libraries for all four architectures: arm, arm64, x86, and
     12 x64.  You can instead list the architectures you want as arguments to this
     13 script.  For example:
     14 
     15     $0 arm x86
     16 
     17 The environment variables ANDROID_NDK and ANDROID_HOME must be set to the
     18 locations of the Android NDK and SDK.  Current values:
     19 
     20     ANDROID_NDK="$ANDROID_NDK"
     21     ANDROID_HOME="$ANDROID_HOME"
     22 
     23 Additionally, \`python\` and \`ninja\` should be in your path.
     24 
     25 If SKQP_EXTRA_MODELS is non-empty, assets unneeded by the CTS tests will be
     26 included for experimental mode.
     27 
     28 EOM
     29     exit 1
     30 }
     31 
     32 [ -d "$ANDROID_NDK"  ] || usage
     33 [ -d "$ANDROID_HOME" ] || usage
     34 command -v ninja  > /dev/null || usage
     35 command -v python > /dev/null || usage
     36 for ARCH in $*; do case $ARCH in arm|arm64|x86|x64);; *) usage;; esac; done
     37 
     38 set -x # Verbose
     39 set -e # Exit immediately
     40 
     41 cd "$(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 )
     51 python tools/skqp/download_model
     52 if [ -z "$SKQP_EXTRA_MODELS" ]; then
     53     python tools/skqp/remove_unneeded_assets
     54 fi
     55 
     56 python tools/skqp/setup_resources
     57 python tools/git-sync-deps
     58 
     59 APP=skqp
     60 LIB=libskqp_app.so
     61 
     62 find platform_tools/android/apps/$APP -name $LIB -exec rm {} +
     63 
     64 if [ $# -eq 0 ]; then
     65     set -- arm arm64 x86 x64
     66 fi
     67 
     68 for 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
     88 done
     89 
     90 (
     91     cd platform_tools/android
     92     apps/gradlew -p apps/$APP -P suppressNativeBuild :$APP:assembleUniversalDebug
     93 )
     94 
     95 mkdir -p out/skqp
     96 cp platform_tools/android/apps/$APP/build/outputs/apk/$APP-universal-debug.apk out/skqp/
     97 
     98