Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / platform_tools / android / bin / android_run_skia
1 #!/bin/bash
2 #
3 # android_run_skia: starts the correct skia program on the device, prints the
4 # output, and kills the app if interrupted.
5
6 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7 source $SCRIPT_DIR/android_setup.sh
8 source $SCRIPT_DIR/utils/setup_adb.sh
9
10 if [ ! -f "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" ];
11 then
12   echo "Unable to find $BUILDTYPE ${APP_ARGS[0]} library"
13   exit 1
14 fi
15
16 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/skia_launcher" /data/local/tmp
17 if [ -f "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" ]; then
18     # Does not exist for builds with static skia.
19     adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" /data/local/tmp
20 fi
21 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" /data/local/tmp
22 if [[ -n $RESOURCE_PATH ]]; then
23   adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH
24 fi
25
26 STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)"
27 $ADB ${DEVICE_SERIAL} shell \
28     "LD_LIBRARY_PATH=/data/local/tmp:$LD_LIBRARY_PATH \
29      /data/local/tmp/skia_launcher ${APP_ARGS[*]}; echo \$? > ${STATUS_FILENAME}"
30 if [ -z "$($ADB $DEVICE_SERIAL shell 'if [ -f $STATUS_FILENAME ]; then echo exists; fi')" ]; then
31   echo "***********************************************************************"
32   echo "The application terminated unexpectedly and did not produce an exit code"
33   echo "***********************************************************************"
34   exit 1
35 fi
36
37 EXIT_CODE=`$ADB ${DEVICE_SERIAL} shell cat ${STATUS_FILENAME}`
38 $ADB ${DEVICE_SERIAL} shell rm -f ${STATUS_FILENAME}
39
40 # check to see if the 'cat' command failed and print errors accordingly
41 if [[ ${EXIT_CODE} == *${STATUS_FILENAME}* ]]; then
42   echo "***********************************************************************"
43   echo "ADB failed to retrieve the application's exit code"
44   echo "***********************************************************************"
45   exit 1
46 fi
47
48 echo "EXIT_CODE is ${EXIT_CODE}"
49 if [ $'0\r' != "${EXIT_CODE}" ]; then
50   exit 1
51 fi
52 exit 0