From cc95b1aeb8cbb9201712c9982d12149b0e0027f0 Mon Sep 17 00:00:00 2001 From: "djsollen@google.com" Date: Mon, 12 Aug 2013 12:30:04 +0000 Subject: Update Skia Android tools. This CL moves the skia_launcher out of the system/bin and into /data/local/tmp; removes the need to package our shared libs in an apk; and updates all the scripts to work in the new environment. R=mtklein@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/22617002 git-svn-id: http://skia.googlecode.com/svn/trunk@10673 2bbb7eff-a529-9590-31e7-b0007b416f81 --- platform_tools/android/bin/android_gdb | 62 -------------- platform_tools/android/bin/android_gdb_apk | 63 ++++++++++++++ platform_tools/android/bin/android_gdbserver | 60 +++++++------ platform_tools/android/bin/android_install_apk | 55 ++++++++++++ platform_tools/android/bin/android_install_skia | 76 +---------------- platform_tools/android/bin/android_make | 2 +- platform_tools/android/bin/android_perf | 107 +++++++++++------------- platform_tools/android/bin/android_run_skia | 51 +++++------ platform_tools/android/bin/android_setup.sh | 57 +++++++++++-- platform_tools/android/bin/linux/perfhost | Bin 10 files changed, 272 insertions(+), 261 deletions(-) delete mode 100755 platform_tools/android/bin/android_gdb create mode 100755 platform_tools/android/bin/android_gdb_apk create mode 100755 platform_tools/android/bin/android_install_apk mode change 100644 => 100755 platform_tools/android/bin/android_perf mode change 100644 => 100755 platform_tools/android/bin/linux/perfhost (limited to 'platform_tools/android/bin') diff --git a/platform_tools/android/bin/android_gdb b/platform_tools/android/bin/android_gdb deleted file mode 100755 index 9087084912..0000000000 --- a/platform_tools/android/bin/android_gdb +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# -# android_gdb: Pushes parameter binary and gdbserver. Connects -# and enters debugging environment. - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/android_setup.sh - -APP_NAME=${APP_ARGS[0]} -PORT=5039 - -source $SCRIPT_DIR/utils/setup_adb.sh - -echo "Installing Skia Android app" -$SCRIPT_DIR/android_install_skia -f - -# Forward local to remote socket connection. -$ADB forward "tcp:$PORT" "tcp:$PORT" - -# We kill all previous instances of gdbserver to rid all port overriding errors. -$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 -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_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" - -# Attach gdbserver to the app process -PID=$($ADB shell ps | grep skia_native | awk '{print $2}') -echo "Attaching to pid: $PID" -$ADB shell /data/data/com.skia/lib/gdbserver :$PORT --attach $PID & - -# Wait for gdbserver -sleep 2 - -# Set up gdb commands -GDBSETUP=$GDB_TMP_DIR/gdb.setup -echo "file $GDB_TMP_DIR/app_process" >> $GDBSETUP -echo "target remote :$PORT" >> $GDBSETUP -echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP -echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP - -# Launch gdb client -echo "Entering gdb client shell" -if [ "$ANDROID_ARCH" == "x86" ] -then - $ANDROID_TOOLCHAIN/i686-linux-android-gdb -x $GDBSETUP -else - $ANDROID_TOOLCHAIN/arm-linux-androideabi-gdb -x $GDBSETUP -fi - -# Clean up -rm -rf $GDB_TMP_DIR - diff --git a/platform_tools/android/bin/android_gdb_apk b/platform_tools/android/bin/android_gdb_apk new file mode 100755 index 0000000000..a87b948b96 --- /dev/null +++ b/platform_tools/android/bin/android_gdb_apk @@ -0,0 +1,63 @@ +#!/bin/bash +# +# android_gdb: Pushes parameter binary and gdbserver. Connects +# and enters debugging environment. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $SCRIPT_DIR/android_setup.sh + +APP_NAME=${APP_ARGS[0]} +PORT=5039 + +source $SCRIPT_DIR/utils/setup_adb.sh + +echo "Installing Skia Android app" +$SCRIPT_DIR/android_install_skia_apk -f + +# Forward local to remote socket connection. +$ADB forward "tcp:$PORT" "tcp:$PORT" + +# We kill all previous instances of gdbserver to rid all port overriding errors. +$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 -p $GDB_TMP_DIR +echo "Copying symbol files" +adb_pull_if_needed /system/bin/app_process $GDB_TMP_DIR +adb_pull_if_needed /system/lib/libc.so $GDB_TMP_DIR +adb_pull_if_needed /data/data/com.skia/lib/libskia_android.so $GDB_TMP_DIR +adb_pull_if_needed /data/data/com.skia/lib/libSampleApp.so $GDB_TMP_DIR + +# Launch the app +SK_COMMAND="$APP_ARGS" +echo "Running command $SK_COMMAND" +adb shell am start -n com.skia/com.skia.SkiaSampleActivity + +# Attach gdbserver to the app process +PID=$($ADB shell ps | grep com.skia | awk '{print $2}') +echo "Attaching to pid: $PID" +$ADB shell /data/data/com.skia/lib/gdbserver :$PORT --attach $PID & + +# Wait for gdbserver +sleep 2 + +# Set up gdb commands +GDBSETUP=$GDB_TMP_DIR/gdb.setup +echo "file $GDB_TMP_DIR/app_process" >> $GDBSETUP +echo "target remote :$PORT" >> $GDBSETUP +echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP +echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP + +# Launch gdb client +echo "Entering gdb client shell" +if [ "$ANDROID_ARCH" == "x86" ] +then + $ANDROID_TOOLCHAIN/i686-linux-android-gdb -x $GDBSETUP +else + $ANDROID_TOOLCHAIN/arm-linux-androideabi-gdb -x $GDBSETUP +fi + +# Clean up +rm -rf $GDB_TMP_DIR + diff --git a/platform_tools/android/bin/android_gdbserver b/platform_tools/android/bin/android_gdbserver index 5c45b56acd..04c46f37c8 100755 --- a/platform_tools/android/bin/android_gdbserver +++ b/platform_tools/android/bin/android_gdbserver @@ -4,49 +4,57 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/android_setup.sh +source $SCRIPT_DIR/utils/setup_adb.sh + +configuration="Debug" + +for arg in ${APP_ARGS[@]} +do + if [[ "${arg}" == "--release" ]]; + then + configuration="Release" + else + gdbVars=("${gdbVars[@]}" "${arg}") + fi + +shift +done -APP_NAME=${APP_ARGS[0]} +APP_NAME=${gdbVars[0]} PORT=5039 -source $SCRIPT_DIR/utils/setup_adb.sh +if [ ! -f "${SKIA_OUT}/${configuration}/lib.target/lib${gdbVars[0]}.so" ]; +then + echo "Unable to find the ${gdbVars[0]} library" + exit 1 +fi # We need the debug symbols from these files GDB_TMP_DIR=$(pwd)/android_gdb_tmp mkdir $GDB_TMP_DIR + echo "Copying symbol files" -adb_pull_if_needed /system/bin/skia_launcher $GDB_TMP_DIR adb_pull_if_needed /system/lib/libc.so $GDB_TMP_DIR -adb_pull_if_needed /data/data/com.skia/lib/libskia_android.so $GDB_TMP_DIR -adb_pull_if_needed /data/data/com.skia/lib/lib$APP_NAME.so $GDB_TMP_DIR - -echo "Checking for skia_launcher app..." -if [ ! -f $GDB_TMP_DIR/skia_launcher ] -then - echo "Unable for find the skia_launcher on the device" - rm -rf $GDB_TMP_DIR - exit 1; -fi +cp "${SKIA_OUT}/${configuration}/skia_launcher" $GDB_TMP_DIR +cp "${SKIA_OUT}/${configuration}/lib.target/libskia_android.so" $GDB_TMP_DIR +cp "${SKIA_OUT}/${configuration}/lib.target/lib${APP_NAME}.so" $GDB_TMP_DIR -echo "Checking for $APP_NAME library..." -if [ ! -f $GDB_TMP_DIR/lib$APP_NAME.so ] -then - echo "Unable for find the app's shared library on the device" - rm -rf $GDB_TMP_DIR - exit 1; -fi +echo "Pushing app..." +adb_push_if_needed "${SKIA_OUT}/${configuration}/skia_launcher" /data/local/tmp +adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/libskia_android.so" /data/local/tmp +adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/lib${APP_NAME}.so" /data/local/tmp echo "Pushing gdbserver..." -$ADB remount -$ADB push $ANDROID_TOOLCHAIN/../gdbserver /system/bin/gdbserver +adb_push_if_needed $ANDROID_TOOLCHAIN/../gdbserver data/local/tmp echo "Setting up port forward" $ADB forward "tcp:5039" "tcp:5039" -# Kill all previous instances of gdbserver and skia_launcher to rid all port overriding errors. +# Kill all previous instances of gdbserver and the app to rid all port overriding errors. echo "Killing any running Skia processes." $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 +$ADB shell ps | grep ${APP_NAME} | awk '{print $2}' | xargs $ADB shell kill # Starting up gdbserver in android shell -echo "Starting gdbserver with command: skia_launcher $APP_ARGS" -$ADB shell gdbserver :5039 /system/bin/skia_launcher $APP_ARGS & \ No newline at end of file +echo "Starting gdbserver with command: ${gdbVars[@]}" +$ADB shell /data/local/tmp/gdbserver :5039 /data/local/tmp/skia_launcher ${gdbVars[@]} & \ No newline at end of file diff --git a/platform_tools/android/bin/android_install_apk b/platform_tools/android/bin/android_install_apk new file mode 100755 index 0000000000..ac162a1ed2 --- /dev/null +++ b/platform_tools/android/bin/android_install_apk @@ -0,0 +1,55 @@ +#!/bin/bash +# +# android_install_skia: installs the skia apk on the device. + +function print_usage { + echo "USAGE: android_install_skia [options]" + echo " Options: -f Forces the package to be installed by removing any" + echo " previously installed packages" + echo " -h Prints this help message" + echo " --release Install the release build of Skia" + echo " -s [device_s/n] Serial number of the device to be used" +} + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source $SCRIPT_DIR/utils/setup_adb.sh +source $SCRIPT_DIR/utils/setup_skia_out.sh + +forceRemoval="false" +installLauncher="false" +installOptions="-r" +configuration="Debug" + +while (( "$#" )); do + + if [[ "$1" == "-f" ]]; + then + forceRemoval="true" + elif [[ "$1" == "-h" ]]; + then + print_usage + exit + elif [[ "$1" == "-r" ]]; + then + echo "DEPRECATED: -r is now a no-op" + elif [[ "$1" == "--release" ]]; + then + configuration="Release" + else + echo "ERROR: unrecognized option $1" + print_usage + exit 1; + fi + +shift +done + +if [[ "$forceRemoval" == "true" ]]; +then + echo "Forcing removal of previously installed packages" + $ADB ${DEVICE_SERIAL} uninstall com.skia > /dev/null +fi + +echo "Installing Skia App from ${SKIA_OUT}/${configuration}" +$ADB ${DEVICE_SERIAL} install ${installOptions} ${SKIA_OUT}/${configuration}/android/bin/SkiaAndroid.apk diff --git a/platform_tools/android/bin/android_install_skia b/platform_tools/android/bin/android_install_skia index da16b1ab7a..21dec5b8c3 100755 --- a/platform_tools/android/bin/android_install_skia +++ b/platform_tools/android/bin/android_install_skia @@ -2,77 +2,5 @@ # # android_install_skia: installs the skia apk on the device. -function print_usage { - echo "USAGE: android_install_skia [options]" - echo " Options: -f Forces the package to be installed by removing any" - echo " previously installed packages" - echo " -h Prints this help message" - echo " --install-launcher Remounts the system partition and installs the" - echo " skia_launcher binary on the device" - echo " --release Install the release build of Skia" - echo " -s [device_s/n] Serial number of the device to be used" -} - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -source $SCRIPT_DIR/utils/setup_adb.sh -source $SCRIPT_DIR/utils/setup_skia_out.sh - -forceRemoval="false" -installLauncher="false" -installOptions="-r" -configuration="Debug" -serialNumber="" - -while (( "$#" )); do - - if [[ "$1" == "-f" ]]; - then - forceRemoval="true" - elif [[ "$1" == "-h" ]]; - then - print_usage - exit - elif [[ "$1" == "--install-launcher" ]]; - then - installLauncher="true" - elif [[ "$1" == "-r" ]]; - then - echo "DEPRECATED: -r is now a no-op" - elif [[ "$1" == "--release" ]]; - then - configuration="Release" - elif [[ "$1" == "-s" ]]; - then - if [[ $# -lt 2 ]]; - then - echo "ERROR: missing serial number" - exit 1; - fi - serialNumber="-s $2" - shift - else - echo "ERROR: unrecognized option $1" - print_usage - exit 1; - fi - -shift -done - -if [[ "$forceRemoval" == "true" ]]; -then - echo "Forcing removal of previously installed packages" - $ADB ${serialNumber} uninstall com.skia > /dev/null -fi - -if [[ "$installLauncher" == "true" ]]; -then - echo "Installing skia_launcher binary" - $ADB ${serialNumber} root - $ADB ${serialNumber} remount - $ADB ${serialNumber} push ${SKIA_OUT}/${configuration}/skia_launcher /system/bin -fi - -echo "Installing Skia App from ${SKIA_OUT}/${configuration}" -$ADB ${serialNumber} install ${installOptions} ${SKIA_OUT}/${configuration}/android/bin/SkiaAndroid.apk +echo "The install step is now a no-op" +exit; \ No newline at end of file diff --git a/platform_tools/android/bin/android_make b/platform_tools/android/bin/android_make index e5952e25be..ad52d67bca 100755 --- a/platform_tools/android/bin/android_make +++ b/platform_tools/android/bin/android_make @@ -3,7 +3,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/android_setup.sh -for arg in ${APP_ARGS} +for arg in ${APP_ARGS[@]} do if [[ "${arg}" == "--use-ccache" ]]; then diff --git a/platform_tools/android/bin/android_perf b/platform_tools/android/bin/android_perf old mode 100644 new mode 100755 index 5e4b7c8b7a..58e43202a4 --- a/platform_tools/android/bin/android_perf +++ b/platform_tools/android/bin/android_perf @@ -9,8 +9,7 @@ # SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -PERF_CMD=$1 - +source $SCRIPT_DIR/android_setup.sh source $SCRIPT_DIR/utils/setup_adb.sh if [ $(uname) == "Linux" ]; then @@ -22,77 +21,70 @@ else exit 1; fi +# grab and remove the perf command from the input args +PERF_CMD=${APP_ARGS[0]} +unset APP_ARGS[0] + +configuration="Debug" + +for arg in ${APP_ARGS[@]} +do + if [[ "${arg}" == "--release" ]]; + then + configuration="Release" + else + echo "${arg}" + runVars=("${runVars[@]}" "${arg}") + fi + +shift +done + # We need the debug symbols from these files PERF_TMP_DIR=$(pwd)/android_perf_tmp TMP_SYS_BIN=$PERF_TMP_DIR/system/bin TMP_SYS_LIB=$PERF_TMP_DIR/system/lib -TMP_APP_LIB=$PERF_TMP_DIR/data/data/com.skia/lib +TMP_APP_LOC=$PERF_TMP_DIR/data/local/tmp perf_setup() { mkdir -p $TMP_SYS_BIN mkdir -p $TMP_SYS_LIB - mkdir -p $TMP_APP_LIB + mkdir -p $TMP_APP_LOC - # setup symlinks to account for perf potentially looking elsewhere - mkdir -p $PERF_TMP_DIR/data/app-lib - $( cd $PERF_TMP_DIR/data/app-lib && ln -s ../data/com.skia/lib com.skia-1) - $( cd $PERF_TMP_DIR/data/app-lib && ln -s ../data/com.skia/lib com.skia-2) - echo "Copying symbol files" - $ADB pull /system/bin/skia_launcher $TMP_SYS_BIN - $ADB pull /system/lib/libc.so $TMP_SYS_LIB - $ADB pull /system/lib/libstlport.so $TMP_SYS_LIB - $ADB pull /system/lib/libcutils.so $TMP_SYS_LIB - $ADB pull /system/lib/libGLESv2.so $TMP_SYS_LIB - $ADB pull /system/lib/libandroid.so $TMP_SYS_LIB - $ADB pull /system/lib/libm.so $TMP_SYS_LIB - $ADB pull /system/lib/libz.so $TMP_SYS_LIB - - if [ $# -ge 2 ] + adb_pull_if_needed /system/lib/libc.so $TMP_SYS_LIB + adb_pull_if_needed /system/lib/libstlport.so $TMP_SYS_LIB + adb_pull_if_needed /system/lib/libcutils.so $TMP_SYS_LIB + adb_pull_if_needed /system/lib/libGLESv2.so $TMP_SYS_LIB + adb_pull_if_needed /system/lib/libandroid.so $TMP_SYS_LIB + adb_pull_if_needed /system/lib/libm.so $TMP_SYS_LIB + adb_pull_if_needed /system/lib/libz.so $TMP_SYS_LIB + + if [ ! -f "${SKIA_OUT}/${configuration}/lib.target/lib${runVars[0]}.so" ]; then - APP_NAME=$(basename $2) - $ADB pull /data/data/com.skia/lib/lib${APP_NAME}.so $TMP_APP_LIB - else - $ADB pull /data/data/com.skia/lib/ $TMP_APP_LIB + echo "Unable to find the ${runVars[0]} library" + exit 1 fi - + echo "Pushing app..." + adb_push_if_needed "${SKIA_OUT}/${configuration}/skia_launcher" /data/local/tmp + adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/libskia_android.so" /data/local/tmp + adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/lib${runVars[0]}.so" /data/local/tmp + + cp "${SKIA_OUT}/${configuration}/skia_launcher" $TMP_APP_LOC + cp "${SKIA_OUT}/${configuration}/lib.target/libskia_android.so" $TMP_APP_LOC + cp "${SKIA_OUT}/${configuration}/lib.target/lib${runVars[0]}.so" $TMP_APP_LOC } perf_record() { - APP_NAME=$(basename $2) - # Collect extra arguments to be passed to the skia_launcher binary - shift # perf_cmd - shift # app_name - while (( "$#" )); do - APP_ARGS="$APP_ARGS $1" - shift - done - - echo "Checking for skia_launcher app..." - if [ ! -f $TMP_SYS_BIN/skia_launcher ] - then - echo "Unable to find the skia_launcher on the device" - rm -rf $PERF_TMP_DIR - exit 1; - fi - - echo "Checking for $APP_NAME library..." - if [ ! -f $TMP_APP_LIB/lib$APP_NAME.so ] - then - echo "Unable to find the app's shared library on the device" - rm -rf $PERF_TMP_DIR - exit 1; - fi - echo "Killing any running Skia processes." $ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kill echo "Starting application" - $ADB shell skia_launcher $APP_NAME $APP_ARGS & + $ADB shell /data/local/tmp/skia_launcher ${runVars[@]} & # WE REALLY REALLY WANT TO BE ABLE TO PASS THE SKIA_LAUNCHER APP DIRECTLY TO # PERF, BUT AT THIS POINT THE DATA FILE WE GET WHEN GOING THAT ROUTE IS UNABLE @@ -107,13 +99,8 @@ perf_record() { } perf_report() { - # Collect extra arguments to be passed to the perfhost binary - while (( "$#" )); do - APP_ARGS="$APP_ARGS $1" - shift - done - - $PERFHOST report -i $PERF_TMP_DIR/perf.data --symfs=$PERF_TMP_DIR $APP_ARGS + adb_pull_if_needed /data/perf.data $PERF_TMP_DIR/perf.data + $PERFHOST report -i $PERF_TMP_DIR/perf.data --symfs=$PERF_TMP_DIR ${runVars[@]} } # Clean up @@ -123,11 +110,11 @@ perf_clean() { case $PERF_CMD in setup) - perf_setup $@ + perf_setup ${runVars[@]} ;; record) - perf_setup $@ - perf_record $@ + perf_setup ${runVars[@]} + perf_record ${runVars[@]} ;; report) perf_report diff --git a/platform_tools/android/bin/android_run_skia b/platform_tools/android/bin/android_run_skia index 00fe37f65d..133be35709 100755 --- a/platform_tools/android/bin/android_run_skia +++ b/platform_tools/android/bin/android_run_skia @@ -4,45 +4,32 @@ # output, and kills the app if interrupted. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - +source $SCRIPT_DIR/android_setup.sh source $SCRIPT_DIR/utils/setup_adb.sh -APP_ARGS="" -USE_INTENT="false" -SERIAL="" - -while (( "$#" )); do - - if [[ "$1" == "--intent" ]]; - then - USE_INTENT="true" - elif [[ "$1" == "-s" ]]; - then - if [[ $# -lt 2 ]]; - then - echo "ERROR: missing serial number" - exit 1; - fi - SERIAL="-s $2" - shift +configuration="Debug" + +for arg in ${APP_ARGS[@]} +do + if [[ "${arg}" == "--release" ]]; + then + configuration="Release" else - APP_ARGS="$APP_ARGS $1" + runVars=("${runVars[@]}" "${arg}") fi shift done - -if [[ "$USE_INTENT" == "true" ]]; +if [ ! -f "${SKIA_OUT}/${configuration}/lib.target/lib${runVars[0]}.so" ]; then - $ADB $SERIAL logcat -c - $ADB $SERIAL shell am broadcast -a com.skia.intent.action.LAUNCH_SKIA -n com.skia/.SkiaReceiver -e args "$APP_ARGS" - trap "echo \"Interrupt.\"" INT - eval "($ADB $SERIAL logcat)" - trap - INT - echo "Interrupt. Killing Skia process..." - $SCRIPT_DIR/android_kill_skia $SERIAL - echo "Done." -else - $ADB $SERIAL shell skia_launcher $APP_ARGS + echo "Unable to find the ${runVars[0]} library" + exit 1 fi + +adb_push_if_needed "${SKIA_OUT}/${configuration}/skia_launcher" /data/local/tmp +adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/libskia_android.so" /data/local/tmp +adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/lib${runVars[0]}.so" /data/local/tmp + + +$ADB ${DEVICE_SERIAL} shell /data/local/tmp/skia_launcher ${runVars[@]} diff --git a/platform_tools/android/bin/android_setup.sh b/platform_tools/android/bin/android_setup.sh index db1145f5d1..2525dbbdee 100755 --- a/platform_tools/android/bin/android_setup.sh +++ b/platform_tools/android/bin/android_setup.sh @@ -4,20 +4,28 @@ # Parse the arguments for a DEVICE_ID. DEVICE_ID="" +DEVICE_SERIAL="" while (( "$#" )); do if [[ $(echo "$1" | grep "^-d$") != "" ]]; then DEVICE_ID=$2 shift + elif [[ "$1" == "-s" ]]; + then + if [[ $# -lt 2 ]]; + then + echo "ERROR: missing serial number" + exit 1; + fi + DEVICE_SERIAL="-s $2" + shift else - APP_ARGS="$APP_ARGS $1" + APP_ARGS=("${APP_ARGS[@]}" "${1}") fi shift done -APP_ARGS=$(echo ${APP_ARGS} | sed 's/^ *//g') - function exportVar { NAME=$1 VALUE=$2 @@ -210,6 +218,7 @@ setup_device() { esac echo "The build is targeting the device: $TARGET_DEVICE" + export DEVICE_ID="$TARGET_DEVICE" # Set up the toolchain. setup_toolchain @@ -244,17 +253,53 @@ adb_pull_if_needed() { if [ -f $HOST_DST ]; then #get the MD5 for dst and src - ANDROID_MD5=`$ADB shell md5 $ANDROID_SRC` + ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5 $ANDROID_SRC` HOST_MD5=`md5sum $HOST_DST` if [ "${ANDROID_MD5:0:32}" != "${HOST_MD5:0:32}" ]; then - $ADB pull $ANDROID_SRC $HOST_DST + $ADB $DEVICE_SERIAL pull $ANDROID_SRC $HOST_DST # else # echo "md5 match of android [$ANDROID_SRC] and host [$HOST_DST]" fi else - $ADB pull $ANDROID_SRC $HOST_DST + $ADB $DEVICE_SERIAL pull $ANDROID_SRC $HOST_DST + fi +} + +# adb_push_if_needed(host_src, android_dst) +adb_push_if_needed() { + + # get adb location + source $SCRIPT_DIR/utils/setup_adb.sh + + # read input params + HOST_SRC="$1" + ANDROID_DST="$2" + + ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST` + if [ "${ANDROID_LS:0:1}" == "d" ]; + then + ANDROID_DST="${ANDROID_DST}/$(basename ${HOST_SRC})" + fi + + echo "ANDROID: $ANDROID_DST" + + ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST` + if [ "${ANDROID_LS:0:1}" == "-" ]; + then + #get the MD5 for dst and src + ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5 $ANDROID_DST` + HOST_MD5=`md5sum $HOST_SRC` + + if [ "${ANDROID_MD5:0:32}" != "${HOST_MD5:0:32}" ]; + then + $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST +# else +# echo "md5 match of android [${ANDROID_DST}] and host [${HOST_SRC}]" + fi + else + $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST fi } diff --git a/platform_tools/android/bin/linux/perfhost b/platform_tools/android/bin/linux/perfhost old mode 100644 new mode 100755 -- cgit v1.2.3