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 | |
Brian Carlstrom | fa42b44 | 2013-06-17 12:53:45 -0700 | [diff] [blame] | 12 | DEBUGGER="n" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 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" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 20 | |
| 21 | while true; do |
| 22 | if [ "x$1" = "x--quiet" ]; then |
| 23 | QUIET="y" |
| 24 | shift |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 25 | elif [ "x$1" = "x--lib" ]; then |
Brian Carlstrom | fa42b44 | 2013-06-17 12:53:45 -0700 | [diff] [blame] | 26 | shift |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 27 | if [ "x$1" = "x" ]; then |
| 28 | echo "$0 missing argument to --lib" 1>&2 |
| 29 | exit 1 |
| 30 | fi |
Brian Carlstrom | fa42b44 | 2013-06-17 12:53:45 -0700 | [diff] [blame] | 31 | LIB="$1" |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 32 | shift |
| 33 | elif [ "x$1" = "x--boot" ]; then |
| 34 | shift |
| 35 | BOOT_OPT="$1" |
Ian Rogers | 6950e65 | 2012-08-28 18:20:00 -0700 | [diff] [blame] | 36 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 37 | elif [ "x$1" = "x--debug" ]; then |
Brian Carlstrom | fa42b44 | 2013-06-17 12:53:45 -0700 | [diff] [blame] | 38 | DEBUGGER="y" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 39 | shift |
| 40 | elif [ "x$1" = "x--gdb" ]; then |
| 41 | GDB="y" |
Ian Rogers | 6030ef4 | 2013-02-20 14:15:53 -0800 | [diff] [blame] | 42 | DEV_MODE="y" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 43 | shift |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 44 | elif [ "x$1" = "x--invoke-with" ]; then |
| 45 | shift |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 46 | if [ "x$1" = "x" ]; then |
| 47 | echo "$0 missing argument to --invoke-with" 1>&2 |
| 48 | exit 1 |
| 49 | fi |
Ian Rogers | 0e03367 | 2013-04-19 10:22:46 -0700 | [diff] [blame] | 50 | if [ "x$INVOKE_WITH" = "x" ]; then |
| 51 | INVOKE_WITH="$1" |
| 52 | else |
| 53 | INVOKE_WITH="$INVOKE_WITH $1" |
| 54 | fi |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 55 | shift |
| 56 | elif [ "x$1" = "x--dev" ]; then |
| 57 | DEV_MODE="y" |
| 58 | shift |
jeffhao | 0dff3f4 | 2012-11-20 15:13:43 -0800 | [diff] [blame] | 59 | elif [ "x$1" = "x--interpreter" ]; then |
| 60 | INTERPRETER="y" |
| 61 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 62 | elif [ "x$1" = "x--no-verify" ]; then |
| 63 | VERIFY="n" |
| 64 | shift |
| 65 | elif [ "x$1" = "x--no-optimize" ]; then |
| 66 | OPTIMIZE="n" |
| 67 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 68 | elif [ "x$1" = "x--" ]; then |
| 69 | shift |
| 70 | break |
| 71 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 72 | echo "unknown $0 option: $1" 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 73 | exit 1 |
| 74 | else |
| 75 | break |
| 76 | fi |
| 77 | done |
| 78 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 79 | msg "------------------------------" |
| 80 | |
Brian Carlstrom | 7675e16 | 2013-06-10 16:18:04 -0700 | [diff] [blame] | 81 | mkdir $DEX_LOCATION/dalvik-cache |
Mark Mendell | ea6404e | 2013-12-20 06:07:51 -0800 | [diff] [blame] | 82 | if [ $? -ne 0 ]; then |
| 83 | exit |
| 84 | fi |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 85 | |
| 86 | export ANDROID_PRINTF_LOG=brief |
| 87 | if [ "$DEV_MODE" = "y" ]; then |
| 88 | export ANDROID_LOG_TAGS='*:d' |
| 89 | else |
| 90 | export ANDROID_LOG_TAGS='*:s' |
| 91 | fi |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 92 | export ANDROID_DATA="$DEX_LOCATION" |
Elliott Hughes | e7fb2a6 | 2012-04-23 12:39:12 -0700 | [diff] [blame] | 93 | export ANDROID_ROOT="${ANDROID_HOST_OUT}" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 94 | export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib" |
| 95 | export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib" |
| 96 | |
Brian Carlstrom | fa42b44 | 2013-06-17 12:53:45 -0700 | [diff] [blame] | 97 | exe="${ANDROID_ROOT}/bin/dalvikvm" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 98 | |
Brian Carlstrom | fa42b44 | 2013-06-17 12:53:45 -0700 | [diff] [blame] | 99 | if [ "$DEBUGGER" = "y" ]; then |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 100 | PORT=8000 |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame] | 101 | msg "Waiting for jdb to connect:" |
| 102 | msg " jdb -attach localhost:$PORT" |
Brian Carlstrom | fa42b44 | 2013-06-17 12:53:45 -0700 | [diff] [blame] | 103 | DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 104 | fi |
| 105 | |
| 106 | if [ "$GDB" = "y" ]; then |
| 107 | gdb=gdb |
Brian Carlstrom | ebf7eab | 2013-03-06 15:22:27 -0800 | [diff] [blame] | 108 | gdbargs="--args $exe" |
| 109 | # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line. |
| 110 | # gdbargs="--annotate=3 $gdbargs" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 111 | fi |
| 112 | |
jeffhao | 0dff3f4 | 2012-11-20 15:13:43 -0800 | [diff] [blame] | 113 | if [ "$INTERPRETER" = "y" ]; then |
| 114 | INT_OPTS="-Xint" |
| 115 | fi |
| 116 | |
Mathieu Chartier | dbe6f46 | 2012-09-25 16:54:50 -0700 | [diff] [blame] | 117 | JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni" |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame] | 118 | |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 119 | if [ "$DEV_MODE" = "y" ]; then |
| 120 | echo $cmdline "$@" |
| 121 | fi |
| 122 | |
Brian Carlstrom | 4855cd5 | 2012-04-03 21:38:13 -0700 | [diff] [blame] | 123 | cd $ANDROID_BUILD_TOP |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 124 | $INVOKE_WITH $gdb $exe $gdbargs -XXlib:$LIB $JNI_OPTS $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@" |