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. |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 5 | |
| 6 | msg() { |
| 7 | if [ "$QUIET" = "n" ]; then |
| 8 | echo "$@" |
| 9 | fi |
| 10 | } |
| 11 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 12 | DEBUG="n" |
| 13 | GDB="n" |
jeffhao | 0dff3f4 | 2012-11-20 15:13:43 -0800 | [diff] [blame] | 14 | INTERPRETER="n" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 15 | VERIFY="y" |
| 16 | OPTIMIZE="y" |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 17 | INVOKE_WITH="" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 18 | DEV_MODE="n" |
| 19 | QUIET="n" |
Ian Rogers | 6950e65 | 2012-08-28 18:20:00 -0700 | [diff] [blame] | 20 | OATEXEC="oatexecd" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 21 | |
| 22 | while true; do |
| 23 | if [ "x$1" = "x--quiet" ]; then |
| 24 | QUIET="y" |
| 25 | shift |
Ian Rogers | 6950e65 | 2012-08-28 18:20:00 -0700 | [diff] [blame] | 26 | elif [ "x$1" = "x-O" ]; then |
| 27 | OATEXEC="oatexec" |
| 28 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 29 | elif [ "x$1" = "x--debug" ]; then |
| 30 | DEBUG="y" |
| 31 | shift |
| 32 | elif [ "x$1" = "x--gdb" ]; then |
| 33 | GDB="y" |
Ian Rogers | 6030ef4 | 2013-02-20 14:15:53 -0800 | [diff] [blame] | 34 | DEV_MODE="y" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 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 |
jeffhao | 0dff3f4 | 2012-11-20 15:13:43 -0800 | [diff] [blame] | 43 | elif [ "x$1" = "x--interpreter" ]; then |
| 44 | INTERPRETER="y" |
| 45 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 46 | elif [ "x$1" = "x--no-verify" ]; then |
| 47 | VERIFY="n" |
| 48 | shift |
| 49 | elif [ "x$1" = "x--no-optimize" ]; then |
| 50 | OPTIMIZE="n" |
| 51 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 52 | elif [ "x$1" = "x--" ]; then |
| 53 | shift |
| 54 | break |
| 55 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 56 | echo "unknown $0 option: $1" 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 57 | exit 1 |
| 58 | else |
| 59 | break |
| 60 | fi |
| 61 | done |
| 62 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 63 | msg "------------------------------" |
| 64 | |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 65 | mkdir $DEX_LOCATION/art-cache |
| 66 | [[ $? -ne 0 ]] && exit |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 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 |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 74 | export ANDROID_DATA="$DEX_LOCATION" |
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" |
Brian Carlstrom | 2ab7f48 | 2012-06-04 15:37:25 -0700 | [diff] [blame] | 78 | unset ANDROID_PRODUCT_OUT # avoid defaulting dex2oat --host-prefix to target output |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 79 | |
Ian Rogers | 6950e65 | 2012-08-28 18:20:00 -0700 | [diff] [blame] | 80 | exe="${ANDROID_ROOT}/bin/${OATEXEC}" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 81 | |
| 82 | if [ "$DEBUG" = "y" ]; then |
| 83 | PORT=8000 |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame] | 84 | msg "Waiting for jdb to connect:" |
| 85 | msg " jdb -attach localhost:$PORT" |
| 86 | DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 87 | fi |
| 88 | |
| 89 | if [ "$GDB" = "y" ]; then |
| 90 | gdb=gdb |
Brian Carlstrom | ebf7eab | 2013-03-06 15:22:27 -0800 | [diff] [blame] | 91 | gdbargs="--args $exe" |
| 92 | # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line. |
| 93 | # gdbargs="--annotate=3 $gdbargs" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 94 | fi |
| 95 | |
jeffhao | 0dff3f4 | 2012-11-20 15:13:43 -0800 | [diff] [blame] | 96 | if [ "$INTERPRETER" = "y" ]; then |
| 97 | INT_OPTS="-Xint" |
| 98 | fi |
| 99 | |
Mathieu Chartier | dbe6f46 | 2012-09-25 16:54:50 -0700 | [diff] [blame] | 100 | JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni" |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame] | 101 | |
Brian Carlstrom | 4855cd5 | 2012-04-03 21:38:13 -0700 | [diff] [blame] | 102 | cd $ANDROID_BUILD_TOP |
| 103 | $INVOKE_WITH $gdb $exe $gdbargs -Ximage:$ANDROID_ROOT/framework/core.art \ |
jeffhao | 0dff3f4 | 2012-11-20 15:13:43 -0800 | [diff] [blame] | 104 | $JNI_OPTS $INT_OPTS $DEBUG_OPTS \ |
TDYa127 | b92bcab | 2012-04-08 00:09:51 -0700 | [diff] [blame] | 105 | -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@" |