Android Tools: build x86_64 correctly.
- Fix some naming confusion between `x64` and `x86-64`. - SkQP Universal (multi-arch apk) Build Script [tools/skqp/make_universal_apk] - skqp/build.gradle: add `universal` product flavor - skqp manifest: make debug build optional. No-Try: true Change-Id: Ic8cd88719a34786ab2d53771749b2beb9db98be5 Reviewed-on: https://skia-review.googlesource.com/105023 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Stephan Altmueller <stephana@google.com>
This commit is contained in:
parent
7fcfb62199
commit
c87fbf93d0
@ -67,7 +67,7 @@ def getVariantOutDir(project, variant) {
|
||||
} else if (variant.name.startsWith("arm")) {
|
||||
variantPrefix = "arm"
|
||||
androidLibDir = "armeabi-v7a"
|
||||
} else if (variant.name.startsWith("x86_64")) {
|
||||
} else if (variant.name.startsWith("x64")) {
|
||||
variantPrefix = "x64"
|
||||
androidLibDir = "x86_64"
|
||||
} else if (variant.name.startsWith("x86")) {
|
||||
|
@ -24,6 +24,6 @@ android {
|
||||
}
|
||||
sourceSets.main.jni.srcDirs = []
|
||||
sourceSets.main.jniLibs.srcDir "src/main/libs"
|
||||
productFlavors { arm {}; arm64 {}; x86 {}; x64 {}; arm64vulkan{}; }
|
||||
productFlavors { universal{}; arm {}; arm64 {}; x86 {}; x64 {}; arm64vulkan{}; }
|
||||
setupSkiaLibraryBuild(project, applicationVariants, "libskqp_app")
|
||||
}
|
||||
|
@ -9,8 +9,7 @@
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:theme="@style/AppTheme"
|
||||
android:label="SkQP"
|
||||
android:debuggable="true">
|
||||
android:label="SkQP">
|
||||
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
|
@ -19,7 +19,6 @@ parser.add_argument('app_name')
|
||||
args = parser.parse_args()
|
||||
|
||||
target_cpu = "arm64"
|
||||
android_variant = ""
|
||||
android_buildtype = "debug"
|
||||
|
||||
if args.output_dir == None:
|
||||
@ -32,21 +31,10 @@ if os.path.exists(args_gn_path):
|
||||
if m:
|
||||
target_cpu = m.group(1)
|
||||
|
||||
if target_cpu == "arm":
|
||||
android_variant = "arm"
|
||||
elif target_cpu == "arm64":
|
||||
android_variant = "arm64"
|
||||
elif target_cpu == "x86":
|
||||
android_variant = "x86"
|
||||
elif target_cpu == "x64":
|
||||
android_variant = "x86_64"
|
||||
else:
|
||||
sys.exit("unknown target_cpu")
|
||||
|
||||
# build the apk using gradle
|
||||
try:
|
||||
subprocess.check_call(['./apps/gradlew',
|
||||
':' + args.app_name + ':assemble' + android_variant + android_buildtype,
|
||||
':' + args.app_name + ':assemble' + target_cpu + android_buildtype,
|
||||
'-papps/' + args.app_name,
|
||||
'-P' + target_cpu + '.out.dir=' + os.path.abspath(args.output_dir),
|
||||
'--daemon'], cwd=os.path.join(os.path.dirname(__file__), ".."))
|
||||
@ -57,6 +45,6 @@ except subprocess.CalledProcessError as error:
|
||||
# copy apk back into the main out directory
|
||||
current_dir = os.path.dirname(__file__)
|
||||
apk_src = os.path.join(current_dir, "..", "apps", args.app_name, "build", "outputs", "apk",
|
||||
args.app_name + "-" + android_variant + "-" + android_buildtype + ".apk")
|
||||
args.app_name + "-" + target_cpu + "-" + android_buildtype + ".apk")
|
||||
apk_dst = os.path.join(args.output_dir, args.app_name + ".apk")
|
||||
shutil.copyfile(apk_src, apk_dst)
|
||||
|
77
tools/skqp/make_universal_apk
Executable file
77
tools/skqp/make_universal_apk
Executable file
@ -0,0 +1,77 @@
|
||||
#! /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.
|
||||
|
||||
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")/../.."
|
||||
|
||||
python tools/skqp/download_model
|
||||
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
|
||||
BUILD=out/skqp-$ARCH
|
||||
python tools/skqp/generate_gn_args $BUILD "$ANDROID_NDK" --arch "$ARCH"
|
||||
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 --daemon -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/
|
||||
|
Loading…
Reference in New Issue
Block a user