2018-02-07 19:56:29 +00:00
|
|
|
#! /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.
|
|
|
|
|
2018-02-12 16:21:54 +00:00
|
|
|
If SKQP_EXTRA_MODELS is non-empty, assets unneeded by the CTS tests will be
|
|
|
|
included for experimental mode.
|
|
|
|
|
2018-03-07 19:44:44 +00:00
|
|
|
It assumes that the source tree is in the desired state, e.g. by having
|
|
|
|
run 'python tools/git-sync-deps' in the root of the skia checkout.
|
|
|
|
|
2018-02-07 19:56:29 +00:00
|
|
|
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
|
|
|
|
|
2018-03-07 19:44:44 +00:00
|
|
|
# check if OUTPUT_DIR was set in the environment.
|
|
|
|
if [ -z "${APK_OUTPUT_DIR}" ]; then
|
|
|
|
APK_OUTPUT_DIR=out/skqp
|
|
|
|
fi
|
2018-02-07 19:56:29 +00:00
|
|
|
|
2018-03-07 19:44:44 +00:00
|
|
|
cd "$(dirname "$0")/../.."
|
2018-02-07 19:56:29 +00:00
|
|
|
python tools/skqp/download_model
|
2018-02-12 16:21:54 +00:00
|
|
|
if [ -z "$SKQP_EXTRA_MODELS" ]; then
|
|
|
|
python tools/skqp/remove_unneeded_assets
|
|
|
|
fi
|
|
|
|
|
2018-02-07 19:56:29 +00:00
|
|
|
python tools/skqp/setup_resources
|
|
|
|
|
|
|
|
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
|
2018-03-07 19:44:44 +00:00
|
|
|
BUILD="${APK_OUTPUT_DIR}-${ARCH}"
|
2018-02-17 21:54:28 +00:00
|
|
|
if [ "$SKQP_DEBUG" ]; then
|
2018-03-07 19:44:44 +00:00
|
|
|
python tools/skqp/generate_gn_args $BUILD-debug "$ANDROID_NDK" --arch "$ARCH" --debug
|
2018-02-17 21:54:28 +00:00
|
|
|
else
|
|
|
|
python tools/skqp/generate_gn_args $BUILD "$ANDROID_NDK" --arch "$ARCH"
|
|
|
|
fi
|
2018-02-07 19:56:29 +00:00
|
|
|
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
|
2018-02-17 21:54:28 +00:00
|
|
|
apps/gradlew -p apps/$APP -P suppressNativeBuild :$APP:assembleUniversalDebug
|
2018-02-07 19:56:29 +00:00
|
|
|
)
|
|
|
|
|
2018-03-07 19:44:44 +00:00
|
|
|
mkdir -p $APK_OUTPUT_DIR
|
|
|
|
cp platform_tools/android/apps/$APP/build/outputs/apk/$APP-universal-debug.apk "${APK_OUTPUT_DIR}/"
|
2018-02-07 19:56:29 +00:00
|
|
|
|