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