23145a3c5c
BUG=skia: Change-Id: Ib847e5ae89d2ac3f496507f69f82f5bac4914f36 Reviewed-on: https://skia-review.googlesource.com/8133 Reviewed-by: Chris Dalton <csmartdalton@google.com>
67 lines
1.9 KiB
Python
Executable File
67 lines
1.9 KiB
Python
Executable File
#!/usr/bin/python
|
|
#
|
|
# Copyright 2017 Google Inc.
|
|
#
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
import argparse
|
|
import os
|
|
import re
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
|
|
parser = argparse.ArgumentParser(description='builds skia android apps')
|
|
parser.add_argument('-C', '--output_dir', help='ninja out dir')
|
|
parser.add_argument('app_name')
|
|
|
|
args = parser.parse_args()
|
|
|
|
target_cpu = "arm64"
|
|
android_variant = ""
|
|
android_buildtype = "debug"
|
|
|
|
if args.output_dir == None:
|
|
sys.exit("unknown out directory")
|
|
|
|
args_gn_path = os.path.join(args.output_dir, "args.gn")
|
|
if os.path.exists(args_gn_path):
|
|
for line in open(args_gn_path):
|
|
m = re.match('target_cpu ?= ?"(.*)"', line.strip())
|
|
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"
|
|
elif target_cpu == "mipsel":
|
|
android_variant = "mips"
|
|
elif target_cpu == "mips64el":
|
|
android_variant = "mips64"
|
|
else:
|
|
sys.exit("unknown target_cpu")
|
|
|
|
# build the apk using gradle
|
|
try:
|
|
subprocess.check_call(['./apps/gradlew',
|
|
':viewer:assemble' + android_variant + android_buildtype,
|
|
'-papps/' + args.app_name,
|
|
'-P' + target_cpu + '.out.dir=' + args.output_dir,
|
|
'--daemon'], cwd=os.path.join(os.path.dirname(__file__), ".."))
|
|
except subprocess.CalledProcessError as error:
|
|
print error
|
|
sys.exit("gradle build failed")
|
|
|
|
# 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")
|
|
apk_dst = os.path.join(args.output_dir, args.app_name + ".apk")
|
|
shutil.copyfile(apk_src, apk_dst)
|