Re-organize Android scripts

Addresses https://code.google.com/p/skia/issues/detail?id=1486

R=djsollen@google.com

Review URL: https://codereview.chromium.org/22411004

git-svn-id: http://skia.googlecode.com/svn/trunk@10585 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
borenet@google.com 2013-08-06 20:32:29 +00:00
parent aa2d35144b
commit 7627535b8f
5 changed files with 68 additions and 97 deletions

View File

@ -4,32 +4,11 @@
# and enters debugging environment.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
APP_NAME=$(basename $1)
source $SCRIPT_DIR/android_setup.sh
APP_NAME=${APP_ARGS[0]}
PORT=5039
# Collect extra arguments to be passed to the Skia binary
shift
deviceID=""
while (( "$#" )); do
if [[ $(echo "$1" | grep "^-d$") != "" ]];
then
deviceID=$2
shift
else
APP_ARGS="$APP_ARGS $1"
fi
shift
done
# hack for x86 support in android_setup.sh
if [ "$deviceID" == "x86" ] || [ "$deviceID" == "razr_i" ]
then
ANDROID_ARCH=x86
fi
source $SCRIPT_DIR/android_setup.sh
source $SCRIPT_DIR/utils/setup_adb.sh
echo "Installing Skia Android app"
@ -43,14 +22,14 @@ $ADB shell ps | grep gdbserver | awk '{print $2}' | xargs -r $ADB shell kill
# We need the debug symbols from these files
GDB_TMP_DIR=$(pwd)/android_gdb_tmp
mkdir $GDB_TMP_DIR
mkdir -p $GDB_TMP_DIR
echo "Copying symbol files"
$ADB pull /system/bin/app_process $GDB_TMP_DIR
$ADB pull /system/lib/libc.so $GDB_TMP_DIR
$ADB pull /data/data/com.skia/lib/lib$APP_NAME.so $GDB_TMP_DIR
# Launch the app
SK_COMMAND="$APP_NAME$APP_ARGS"
SK_COMMAND="$APP_ARGS"
echo "Running command $SK_COMMAND"
$ADB shell am broadcast -a com.skia.intent.action.LAUNCH_SKIA -n com.skia/.SkiaReceiver -e args "$SK_COMMAND"

View File

@ -2,30 +2,11 @@
#
# android_gdb: Pushes gdbserver. Connects and enters debugging environment.
deviceID=""
while (( "$#" )); do
if [[ $(echo "$1" | grep "^-d$") != "" ]];
then
deviceID="$2"
shift
else
gdbVars=("${gdbVars[@]}" "$1")
fi
shift
done
# hack for x86 support in android_setup.sh
if [ "$deviceID" == "x86" ] || [ "$deviceID" == "razr_i" ]
then
export ANDROID_ARCH=x86
fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/android_setup.sh
# setup the gdbserver
$SCRIPT_DIR/android_gdbserver ${gdbVars[@]}
$SCRIPT_DIR/android_gdbserver -d ${DEVICE_ID} ${APP_ARGS}
# quit if gdbserver setup failed
if [[ "$?" != "0" ]]; then
@ -38,7 +19,7 @@ sleep 2
# variables that must match those in gdb_server
GDB_TMP_DIR=$(pwd)/android_gdb_tmp
APP_NAME=$(basename ${gdbVars[0]})
APP_NAME=${APP_ARGS[0]}
PORT=5039
# Set up gdb commands
@ -53,8 +34,6 @@ echo "break launch_app" >> $GDBSETUP
echo "continue" >> $GDBSETUP
echo "sharedLibrary $APP_NAME" >> $GDBSETUP
source $SCRIPT_DIR/android_setup.sh
# Launch gdb client
echo "Entering gdb client shell"
if [ "$ANDROID_ARCH" == "x86" ]

View File

@ -3,17 +3,11 @@
# android_gdbserver: Pushes gdbserver. Starts debugging environment.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
APP_NAME=$(basename $1)
source $SCRIPT_DIR/android_setup.sh
APP_NAME=${APP_ARGS[0]}
PORT=5039
# Collect extra arguments to be passed to the Skia binary
shift
while (( "$#" )); do
APP_ARGS="$APP_ARGS $1"
shift
done
source $SCRIPT_DIR/android_setup.sh
source $SCRIPT_DIR/utils/setup_adb.sh
# We need the debug symbols from these files
@ -54,5 +48,5 @@ $ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill
$ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kill
# Starting up gdbserver in android shell
echo "Starting gdbserver with command: skia_launcher $APP_NAME$APP_ARGS"
$ADB shell gdbserver :5039 /system/bin/skia_launcher $APP_NAME$APP_ARGS &
echo "Starting gdbserver with command: skia_launcher $APP_ARGS"
$ADB shell gdbserver :5039 /system/bin/skia_launcher $APP_ARGS &

View File

@ -1,21 +1,18 @@
#!/bin/bash
deviceID=""
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/android_setup.sh
while (( "$#" )); do
if [[ $(echo "$1" | grep "^-d$") != "" ]];
then
deviceID="$2"
shift
elif [[ "$1" == "--use-ccache" ]];
for arg in ${APP_ARGS}
do
if [[ "${arg}" == "--use-ccache" ]];
then
if [[ -z "$ANDROID_MAKE_CCACHE" ]];
then
ANDROID_MAKE_CCACHE=$(which ccache)
fi
else
makeVars=("${makeVars[@]}" "$1")
makeVars=("${makeVars[@]}" "${arg}")
fi
shift
@ -29,23 +26,6 @@ if [[ -n "$ANDROID_MAKE_CCACHE" ]]; then
fi
fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# hack for x86 support in android_setup.sh
if [ "$deviceID" == "x86" ] || [ "$deviceID" == "razr_i" ]
then
ANDROID_ARCH="x86"
fi
source $SCRIPT_DIR/android_setup.sh
setup_device $deviceID
returnVal=$?
if [ $returnVal != 0 ]
then
exit 1;
fi
# write the out directory into the .android_config file
echo $SKIA_OUT > .android_config

View File

@ -1,3 +1,23 @@
#!/bin/bash
#
# android_setup.sh: Sets environment variables used by other Android scripts.
# Parse the arguments for a DEVICE_ID.
DEVICE_ID=""
while (( "$#" )); do
if [[ $(echo "$1" | grep "^-d$") != "" ]];
then
DEVICE_ID=$2
shift
else
APP_ARGS="$APP_ARGS $1"
fi
shift
done
APP_ARGS=$(echo ${APP_ARGS} | sed 's/^ *//g')
function exportVar {
NAME=$1
VALUE=$2
@ -105,19 +125,19 @@ setup_toolchain() {
# Remove the '-gcc' at the end to get the full toolchain prefix
ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc}
exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar"
if [[ -z "$ANDROID_MAKE_CCACHE" ]]; then
exportVar CC "$ANDROID_TOOLCHAIN_PREFIX-gcc"
exportVar CXX "$ANDROID_TOOLCHAIN_PREFIX-g++"
exportVar LINK "$ANDROID_TOOLCHAIN_PREFIX-gcc"
export CC="$ANDROID_TOOLCHAIN_PREFIX-gcc"
export CXX="$ANDROID_TOOLCHAIN_PREFIX-g++"
export LINK="$ANDROID_TOOLCHAIN_PREFIX-gcc"
else
exportVar CC "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
exportVar CXX "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++"
exportVar LINK "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
export CC="$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
export CXX="$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++"
export LINK="$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
fi
exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib"
exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy"
exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip"
export AR="$ANDROID_TOOLCHAIN_PREFIX-ar"
export RANLIB="$ANDROID_TOOLCHAIN_PREFIX-ranlib"
export OBJCOPY="$ANDROID_TOOLCHAIN_PREFIX-objcopy"
export STRIP="$ANDROID_TOOLCHAIN_PREFIX-strip"
}
# Helper function to configure the GYP defines to the appropriate values
@ -141,36 +161,46 @@ setup_device() {
nexus_s)
DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 arm_version=7 arm_thumb=1"
DEFINES="${DEFINES} skia_texture_cache_mb_limit=24"
ANDROID_ARCH="arm"
;;
nexus_4 | nexus_7 | nexus_10)
DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 arm_version=7 arm_thumb=1"
ANDROID_ARCH="arm"
;;
xoom)
DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 arm_version=7 arm_thumb=1"
ANDROID_ARCH="arm"
;;
galaxy_nexus)
DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 arm_version=7 arm_thumb=1"
DEFINES="${DEFINES} skia_texture_cache_mb_limit=32"
ANDROID_ARCH="arm"
;;
razr_i)
DEFINES="${DEFINES} skia_arch_type=x86 skia_arch_width=32"
DEFINES="${DEFINES} skia_texture_cache_mb_limit=32"
ANDROID_ARCH="x86"
;;
arm_v7)
DEFINES="${DEFINES} skia_arch_type=arm arm_neon_optional=1 arm_version=7 arm_thumb=0"
ANDROID_ARCH="arm"
;;
arm_v7_thumb)
DEFINES="${DEFINES} skia_arch_type=arm arm_neon_optional=1 arm_version=7 arm_thumb=1"
ANDROID_ARCH="arm"
;;
arm)
DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 arm_thumb=0"
ANDROID_ARCH="arm"
;;
arm_thumb)
DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 arm_thumb=1"
ANDROID_ARCH="arm"
;;
x86)
DEFINES="${DEFINES} skia_arch_type=x86 skia_arch_width=32"
DEFINES="${DEFINES} skia_texture_cache_mb_limit=32"
ANDROID_ARCH="x86"
;;
*)
echo -n "ERROR: unknown device specified ($TARGET_DEVICE), valid values: "
@ -183,6 +213,9 @@ setup_device() {
# Set up the toolchain.
setup_toolchain
if [[ "$?" != "0" ]]; then
return 1
fi
DEFINES="${DEFINES} android_toolchain=${TOOLCHAIN_TYPE}"
# Use the "android" flavor of the Makefile generator for both Linux and OS X.
@ -224,3 +257,9 @@ adb_pull_if_needed() {
$ADB pull $ANDROID_SRC $HOST_DST
fi
}
# Set up the device.
setup_device "${DEVICE_ID}"
if [[ "$?" != "0" ]]; then
exit 1
fi