| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # | 2 # |
| 3 # android_run_skia: starts the correct skia program on the device, prints the | 3 # android_run_skia: starts the correct skia program on the device, prints the |
| 4 # output, and kills the app if interrupted. | 4 # output, and kills the app if interrupted. |
| 5 | 5 |
| 6 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | 6 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 7 | 7 source $SCRIPT_DIR/android_setup.sh |
| 8 source $SCRIPT_DIR/utils/setup_adb.sh | 8 source $SCRIPT_DIR/utils/setup_adb.sh |
| 9 | 9 |
| 10 APP_ARGS="" | 10 configuration="Debug" |
| 11 USE_INTENT="false" | 11 serialNumber="" |
| 12 SERIAL="" | |
| 13 | 12 |
| 14 while (( "$#" )); do | 13 for arg in ${APP_ARGS} |
| 15 | 14 do |
| 16 if [[ "$1" == "--intent" ]]; | 15 if [[ "${arg}" == "-s" ]]; |
| 17 then | |
| 18 USE_INTENT="true" | |
| 19 elif [[ "$1" == "-s" ]]; | |
| 20 then | 16 then |
| 21 if [[ $# -lt 2 ]]; | 17 if [[ $# -lt 2 ]]; |
| 22 then | 18 then |
| 23 echo "ERROR: missing serial number" | 19 echo "ERROR: missing serial number" |
| 24 exit 1; | 20 exit 1; |
| 25 fi | 21 fi |
| 26 SERIAL="-s $2" | 22 # TODO this is a bug to have $1 and $2 |
| 23 serialNumber="-s $2" |
| 27 shift | 24 shift |
| 25 elif [[ "$1" == "--release" ]]; |
| 26 then |
| 27 configuration="Release" |
| 28 else | 28 else |
| 29 APP_ARGS="$APP_ARGS $1" | 29 runVars=("${runVars[@]}" "${arg}") |
| 30 fi | 30 fi |
| 31 | 31 |
| 32 shift | 32 shift |
| 33 done | 33 done |
| 34 | 34 |
| 35 if [ ! -f "${SKIA_OUT}/${configuration}/lib.target/lib${runVars[0]}.so" ]; |
| 36 then |
| 37 echo "Unable to find the ${runVars[0]} library" |
| 38 exit 1 |
| 39 fi |
| 35 | 40 |
| 36 if [[ "$USE_INTENT" == "true" ]]; | 41 adb_push_if_needed "${SKIA_OUT}/${configuration}/skia_launcher" /data/local/tmp |
| 37 then | 42 adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/libskia_android.so"
/data/local/tmp |
| 38 $ADB $SERIAL logcat -c | 43 adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/${runVars[0]}" /data
/local/tmp |
| 39 $ADB $SERIAL shell am broadcast -a com.skia.intent.action.LAUNCH_SKIA -n com
.skia/.SkiaReceiver -e args "$APP_ARGS" | 44 |
| 40 trap "echo \"Interrupt.\"" INT | 45 |
| 41 eval "($ADB $SERIAL logcat)" | 46 $ADB $serialNumber shell /data/local/tmp/skia_launcher ${runVars[@]} |
| 42 trap - INT | |
| 43 echo "Interrupt. Killing Skia process..." | |
| 44 $SCRIPT_DIR/android_kill_skia $SERIAL | |
| 45 echo "Done." | |
| 46 else | |
| 47 $ADB $SERIAL shell skia_launcher $APP_ARGS | |
| 48 fi | |
| OLD | NEW |