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