skia2/tools/skqp/make_universal_apk
Hal Canary d95303e10c SkQP: update script tools/skqp/make_universal_apk
works if skqp/src/main/assets/files.checksum is missing.
works with new version of tools that put APK in new place.

No-Try: true
Change-Id: I83649c50fe88a4d80204200c609603b4bed0b6b0
Reviewed-on: https://skia-review.googlesource.com/c/159660
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2018-10-04 18:00:22 +00:00

114 lines
3.0 KiB
Bash
Executable File

#! /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.
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.
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
# check if OUTPUT_DIR was set in the environment.
if [ -z "${APK_OUTPUT_DIR}" ]; then
APK_OUTPUT_DIR=out/skqp
fi
cd "$(dirname "$0")/../.."
if [ -f platform_tools/android/apps/skqp/src/main/assets/files.checksum ]; then
python tools/skqp/download_model
if [ -z "$SKQP_EXTRA_MODELS" ]; then
python tools/skqp/remove_unneeded_assets
fi
else
printf '\n* * *\n\nSkQP models are missing!!!!\n\n* * *\n\n'
fi
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
BUILD="${APK_OUTPUT_DIR}-${ARCH}"
if [ "$SKQP_DEBUG" ]; then
python tools/skqp/generate_gn_args $BUILD-debug "$ANDROID_NDK" --arch "$ARCH" --debug
else
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
APK_BUILD_DIR=platform_tools/android/apps/$APP/build/outputs/apk
rm -rf "$APK_BUILD_DIR"
(
cd platform_tools/android
apps/gradlew -p apps/$APP -P suppressNativeBuild :$APP:assembleUniversalDebug
)
mkdir -p $APK_OUTPUT_DIR
APK_BASENAME="$APP-universal-debug.apk"
for APK_PATH in \
"$APK_BUILD_DIR/universal/debug/$APK_BASENAME" \
"$APK_BUILD_DIR/$APK_BASENAME" \
; do
if [ -f "$APK_PATH" ]; then
cp "$APK_PATH" "${APK_OUTPUT_DIR}/$APK_BASENAME"
break
fi
done
ls -l "${APK_OUTPUT_DIR}/$APK_BASENAME"