jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Run the code in test.jar using the host-mode virtual machine. The jar should |
| 4 | # contain a top-level class named Main to run. |
| 5 | # |
| 6 | # Options: |
| 7 | # --quiet -- don't chatter |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 8 | # --debug -- wait for debugger to attach |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 9 | # --no-verify -- turn off verification (on by default) |
| 10 | # --no-optimize -- turn off optimization (on by default) |
| 11 | |
| 12 | msg() { |
| 13 | if [ "$QUIET" = "n" ]; then |
| 14 | echo "$@" |
| 15 | fi |
| 16 | } |
| 17 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 18 | DEBUG="n" |
| 19 | GDB="n" |
| 20 | VERIFY="y" |
| 21 | OPTIMIZE="y" |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 22 | INVOKE_WITH="" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 23 | DEV_MODE="n" |
| 24 | QUIET="n" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 25 | |
| 26 | while true; do |
| 27 | if [ "x$1" = "x--quiet" ]; then |
| 28 | QUIET="y" |
| 29 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 30 | elif [ "x$1" = "x--debug" ]; then |
| 31 | DEBUG="y" |
| 32 | shift |
| 33 | elif [ "x$1" = "x--gdb" ]; then |
| 34 | GDB="y" |
| 35 | shift |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 36 | elif [ "x$1" = "x--invoke-with" ]; then |
| 37 | shift |
| 38 | INVOKE_WITH="$1" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 39 | shift |
| 40 | elif [ "x$1" = "x--dev" ]; then |
| 41 | DEV_MODE="y" |
| 42 | shift |
| 43 | elif [ "x$1" = "x--no-verify" ]; then |
| 44 | VERIFY="n" |
| 45 | shift |
| 46 | elif [ "x$1" = "x--no-optimize" ]; then |
| 47 | OPTIMIZE="n" |
| 48 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 49 | elif [ "x$1" = "x--" ]; then |
| 50 | shift |
| 51 | break |
| 52 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 53 | echo "unknown $0 option: $1" 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 54 | exit 1 |
| 55 | else |
| 56 | break |
| 57 | fi |
| 58 | done |
| 59 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 60 | msg "------------------------------" |
| 61 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 62 | DATA_DIR=/tmp |
Brian Carlstrom | 4855cd5 | 2012-04-03 21:38:13 -0700 | [diff] [blame] | 63 | if [ ! -d $DATA_DIR/art-cache ]; then |
| 64 | mkdir -p $DATA_DIR/art-cache |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 65 | [[ $? -ne 0 ]] && exit |
| 66 | fi |
| 67 | |
| 68 | export ANDROID_PRINTF_LOG=brief |
| 69 | if [ "$DEV_MODE" = "y" ]; then |
| 70 | export ANDROID_LOG_TAGS='*:d' |
| 71 | else |
| 72 | export ANDROID_LOG_TAGS='*:s' |
| 73 | fi |
| 74 | export ANDROID_DATA="$DATA_DIR" |
Elliott Hughes | e7fb2a6 | 2012-04-23 12:39:12 -0700 | [diff] [blame] | 75 | export ANDROID_ROOT="${ANDROID_HOST_OUT}" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 76 | export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib" |
| 77 | export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib" |
| 78 | |
Brian Carlstrom | 4855cd5 | 2012-04-03 21:38:13 -0700 | [diff] [blame] | 79 | exe="${ANDROID_ROOT}/bin/oatexecd" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 80 | |
| 81 | if [ "$DEBUG" = "y" ]; then |
| 82 | PORT=8000 |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame^] | 83 | msg "Waiting for jdb to connect:" |
| 84 | msg " jdb -attach localhost:$PORT" |
| 85 | DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 86 | fi |
| 87 | |
| 88 | if [ "$GDB" = "y" ]; then |
| 89 | gdb=gdb |
| 90 | gdbargs="--args $exe" |
| 91 | fi |
| 92 | |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame^] | 93 | JNI_OPTS="-Xjnigreflimit:256 -Xcheck:jni" |
| 94 | |
Brian Carlstrom | 4855cd5 | 2012-04-03 21:38:13 -0700 | [diff] [blame] | 95 | cd $ANDROID_BUILD_TOP |
| 96 | $INVOKE_WITH $gdb $exe $gdbargs -Ximage:$ANDROID_ROOT/framework/core.art \ |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame^] | 97 | $JNI_OPTS $DEBUG_OPTS \ |
TDYa127 | b92bcab | 2012-04-08 00:09:51 -0700 | [diff] [blame] | 98 | -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@" |