2013-04-29 12:09:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# android_run_skia: starts the correct skia program on the device, prints the
|
|
|
|
# output, and kills the app if interrupted.
|
|
|
|
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2013-08-12 12:30:04 +00:00
|
|
|
source $SCRIPT_DIR/android_setup.sh
|
2013-04-29 12:09:31 +00:00
|
|
|
source $SCRIPT_DIR/utils/setup_adb.sh
|
|
|
|
|
2014-04-04 16:26:42 +00:00
|
|
|
if [ ! -f "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" ];
|
2013-04-29 12:09:31 +00:00
|
|
|
then
|
2014-04-04 16:26:42 +00:00
|
|
|
echo "Unable to find $BUILDTYPE ${APP_ARGS[0]} library"
|
2013-08-12 12:30:04 +00:00
|
|
|
exit 1
|
2013-04-29 12:09:31 +00:00
|
|
|
fi
|
2013-08-12 12:30:04 +00:00
|
|
|
|
2014-04-04 16:26:42 +00:00
|
|
|
adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/skia_launcher" /data/local/tmp
|
|
|
|
if [ -f "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" ]; then
|
2013-12-02 13:50:38 +00:00
|
|
|
# Does not exist for builds with static skia.
|
2014-04-04 16:26:42 +00:00
|
|
|
adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" /data/local/tmp
|
2013-12-02 13:50:38 +00:00
|
|
|
fi
|
2014-04-04 16:26:42 +00:00
|
|
|
adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" /data/local/tmp
|
2014-06-30 05:38:54 +00:00
|
|
|
if [[ -n $RESOURCE_PATH ]]; then
|
|
|
|
adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH
|
|
|
|
fi
|
2013-08-12 12:30:04 +00:00
|
|
|
|
2013-08-22 21:57:22 +00:00
|
|
|
STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)"
|
2014-04-04 16:26:42 +00:00
|
|
|
$ADB ${DEVICE_SERIAL} shell \
|
2014-06-06 13:43:46 +00:00
|
|
|
"/data/local/tmp/skia_launcher ${APP_ARGS[*]}; echo \$? > ${STATUS_FILENAME}"
|
2013-09-27 14:28:45 +00:00
|
|
|
if [ -z "$($ADB $DEVICE_SERIAL shell 'if [ -f $STATUS_FILENAME ]; then echo exists; fi')" ]; then
|
2014-05-01 19:30:35 +00:00
|
|
|
echo "***********************************************************************"
|
|
|
|
echo "The application terminated unexpectedly and did not produce an exit code"
|
|
|
|
echo "***********************************************************************"
|
2013-09-27 14:28:45 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2014-05-01 19:30:35 +00:00
|
|
|
|
2013-08-22 21:57:22 +00:00
|
|
|
EXIT_CODE=`$ADB ${DEVICE_SERIAL} shell cat ${STATUS_FILENAME}`
|
2014-05-01 19:30:35 +00:00
|
|
|
$ADB ${DEVICE_SERIAL} shell rm -f ${STATUS_FILENAME}
|
|
|
|
|
|
|
|
# check to see if the 'cat' command failed and print errors accordingly
|
|
|
|
if [[ ${EXIT_CODE} == *${STATUS_FILENAME}* ]]; then
|
|
|
|
echo "***********************************************************************"
|
|
|
|
echo "ADB failed to retrieve the application's exit code"
|
|
|
|
echo "***********************************************************************"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-04-04 16:26:42 +00:00
|
|
|
echo "EXIT_CODE is ${EXIT_CODE}"
|
2014-03-20 19:48:16 +00:00
|
|
|
if [ $'0\r' != "${EXIT_CODE}" ]; then
|
2013-08-22 21:57:22 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2014-03-20 17:32:27 +00:00
|
|
|
exit 0
|