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 SKIP_TOOLCHAIN_SETUP="true" | 7 SKIP_TOOLCHAIN_SETUP="true" |
8 source $SCRIPT_DIR/android_setup.sh | 8 source $SCRIPT_DIR/android_setup.sh |
9 source $SCRIPT_DIR/utils/setup_adb.sh | 9 source $SCRIPT_DIR/utils/setup_adb.sh |
10 | 10 |
11 if [ ! -f "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" ]; | 11 if [ ! -f "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" ]; |
12 then | 12 then |
13 echo "Unable to find $BUILDTYPE ${APP_ARGS[0]} library" | 13 echo "Unable to find $BUILDTYPE ${APP_ARGS[0]} library" |
14 exit 1 | 14 exit 1 |
15 fi | 15 fi |
16 | 16 |
17 verbose "pushing binaries onto the device..." | 17 verbose "pushing binaries onto the device..." |
18 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/skia_launcher" /data/local/tmp | 18 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/skia_launcher" /data/local/tmp |
19 if [ -f "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" ]; then | 19 if [ -f "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" ]; then |
20 # Does not exist for builds with static skia. | 20 # Does not exist for builds with static skia. |
21 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" /data/loc
al/tmp | 21 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" /data/loc
al/tmp |
22 fi | 22 fi |
23 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" /data/local
/tmp | 23 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" /data/local
/tmp |
24 if [[ -n $RESOURCE_PATH ]]; then | 24 if [[ -n $RESOURCE_PATH ]]; then |
25 verbose "pushing resources onto the device..." | 25 verbose "pushing resources onto the device..." |
26 adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH | 26 adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH |
27 fi | 27 fi |
28 | 28 |
29 if [ $LOGCAT ]; then | 29 if [ $LOGCAT ]; then |
30 verbose "clearing the device logs..." | 30 verbose "clearing the device logs..." |
31 $ADB $DEVICE_SERIAL logcat -c; | 31 $ADB $DEVICE_SERIAL logcat -c; |
32 fi | 32 fi |
33 STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)" | 33 STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)" |
34 CMD_FILENAME=".skia_cmd_tmp_$(date +%s%N)" | 34 CMD_FILENAME=".skia_cmd_tmp_$(date +%s%N)" |
35 echo "LD_LIBRARY_PATH=/data/local/tmp:$LD_LIBRARY_PATH \ | 35 echo "LD_LIBRARY_PATH=/data/local/tmp:$LD_LIBRARY_PATH \ |
36 /data/local/tmp/skia_launcher ${APP_ARGS[*]}; \ | 36 /data/local/tmp/skia_launcher ${APP_ARGS[*]}; \ |
37 echo \$? > ${STATUS_FILENAME}" > ${CMD_FILENAME} | 37 echo \$? > ${STATUS_FILENAME}" > ${CMD_FILENAME} |
38 chmod +x ${CMD_FILENAME} | 38 chmod +x ${CMD_FILENAME} |
39 verbose "======== To reproduce this run: ========" | 39 verbose "======== To reproduce this run: ========" |
40 verbose "android_run_skia ${APP_ARGS[*]}" | 40 verbose "android_run_skia ${APP_ARGS[*]}" |
41 verbose "========================================" | 41 verbose "========================================" |
42 verbose "pushing command file onto the device..." | 42 verbose "pushing command file onto the device..." |
43 $ADB ${DEVICE_SERIAL} push ${CMD_FILENAME} /data/local/tmp | 43 $ADB ${DEVICE_SERIAL} push ${CMD_FILENAME} /data/local/tmp |
44 rm ${CMD_FILENAME} | 44 rm ${CMD_FILENAME} |
45 verbose "preparing to run ${APP_ARGS[0]} on the device..." | 45 verbose "preparing to run ${APP_ARGS[0]} on the device..." |
46 $ADB ${DEVICE_SERIAL} shell sh /data/local/tmp/${CMD_FILENAME} | 46 $ADB ${DEVICE_SERIAL} shell sh /data/local/tmp/${CMD_FILENAME} |
47 | 47 |
48 if [ -z "$($ADB $DEVICE_SERIAL shell 'if [ -f $STATUS_FILENAME ]; then echo exis
ts; fi')" ]; then | 48 if [ -z "$($ADB $DEVICE_SERIAL shell 'if [ -f $STATUS_FILENAME ]; then echo exis
ts; fi')" ]; then |
49 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi | 49 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi |
50 echo "***********************************************************************" | 50 echo "***********************************************************************" |
51 echo "The application terminated unexpectedly and did not produce an exit code
" | 51 echo "The application terminated unexpectedly and did not produce an exit code
" |
52 echo "***********************************************************************" | 52 echo "***********************************************************************" |
53 exit 1 | 53 exit 1 |
54 fi | 54 fi |
55 | 55 |
56 EXIT_CODE=`$ADB ${DEVICE_SERIAL} shell cat ${STATUS_FILENAME}` | 56 EXIT_CODE=`$ADB ${DEVICE_SERIAL} shell cat ${STATUS_FILENAME}` |
57 $ADB ${DEVICE_SERIAL} shell rm -f ${STATUS_FILENAME} ${CMD_FILENAME} | 57 $ADB ${DEVICE_SERIAL} shell rm -f ${STATUS_FILENAME} ${CMD_FILENAME} |
58 | 58 |
59 # check to see if the 'cat' command failed and print errors accordingly | 59 # check to see if the 'cat' command failed and print errors accordingly |
60 if [[ ${EXIT_CODE} == *${STATUS_FILENAME}* ]]; then | 60 if [[ ${EXIT_CODE} == *${STATUS_FILENAME}* ]]; then |
61 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi | 61 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi |
62 echo "***********************************************************************" | 62 echo "***********************************************************************" |
63 echo "ADB failed to retrieve the application's exit code" | 63 echo "ADB failed to retrieve the application's exit code" |
64 echo "***********************************************************************" | 64 echo "***********************************************************************" |
65 exit 1 | 65 exit 1 |
66 fi | 66 fi |
67 | 67 |
68 echo "EXIT_CODE is ${EXIT_CODE}" | 68 echo "EXIT_CODE is ${EXIT_CODE}" |
69 if [ $'0\r' != "${EXIT_CODE}" ]; then | 69 if [[ "${EXIT_CODE}" != 0* ]]; then |
70 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi | 70 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi |
71 exit 1 | 71 exit 1 |
72 fi | 72 fi |
73 exit 0 | 73 exit 0 |
OLD | NEW |