skia2/platform_tools/android/bin/android_run_skia

49 lines
1.8 KiB
Plaintext
Raw Normal View History

#!/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 )"
source $SCRIPT_DIR/android_setup.sh
source $SCRIPT_DIR/utils/setup_adb.sh
if [ ! -f "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" ];
then
echo "Unable to find $BUILDTYPE ${APP_ARGS[0]} library"
exit 1
fi
adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/skia_launcher" /data/local/tmp
if [ -f "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" ]; then
# Does not exist for builds with static skia.
adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" /data/local/tmp
fi
adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" /data/local/tmp
STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)"
$ADB ${DEVICE_SERIAL} shell \
"/data/local/tmp/skia_launcher ${APP_ARGS[*]}; echo \$? > ${STATUS_FILENAME}"
if [ -z "$($ADB $DEVICE_SERIAL shell 'if [ -f $STATUS_FILENAME ]; then echo exists; fi')" ]; then
echo "***********************************************************************"
echo "The application terminated unexpectedly and did not produce an exit code"
echo "***********************************************************************"
exit 1
fi
EXIT_CODE=`$ADB ${DEVICE_SERIAL} shell cat ${STATUS_FILENAME}`
$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
echo "EXIT_CODE is ${EXIT_CODE}"
if [ $'0\r' != "${EXIT_CODE}" ]; then
exit 1
fi
exit 0