blob: 4265f1cbe8b44e2ce29dddefce45fc3c862cb1d5 [file] [log] [blame]
jeffhao5d1ac922011-09-29 17:41:15 -07001#!/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.
jeffhao5d1ac922011-09-29 17:41:15 -07005
6msg() {
7 if [ "$QUIET" = "n" ]; then
8 echo "$@"
9 fi
10}
11
Brian Carlstromfa42b442013-06-17 12:53:45 -070012DEBUGGER="n"
jeffhao5d1ac922011-09-29 17:41:15 -070013GDB="n"
jeffhao0dff3f42012-11-20 15:13:43 -080014INTERPRETER="n"
jeffhao5d1ac922011-09-29 17:41:15 -070015VERIFY="y"
16OPTIMIZE="y"
Elliott Hughes7c046102011-10-19 18:16:03 -070017INVOKE_WITH=""
jeffhao5d1ac922011-09-29 17:41:15 -070018DEV_MODE="n"
19QUIET="n"
Mathieu Chartier769a5ad2014-05-18 15:30:10 -070020FLAGS=""
Ian Rogersafd9acc2014-06-17 08:21:54 -070021exe="${ANDROID_HOST_OUT}/bin/dalvikvm32"
jeffhao5d1ac922011-09-29 17:41:15 -070022
23while true; do
24 if [ "x$1" = "x--quiet" ]; then
25 QUIET="y"
26 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -070027 elif [ "x$1" = "x--lib" ]; then
Brian Carlstromfa42b442013-06-17 12:53:45 -070028 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -070029 if [ "x$1" = "x" ]; then
30 echo "$0 missing argument to --lib" 1>&2
31 exit 1
32 fi
Brian Carlstromfa42b442013-06-17 12:53:45 -070033 LIB="$1"
Ian Rogers2a65d4b2014-06-16 22:16:21 -070034 if [ `uname` = "Darwin" ]; then
35 LIB=${LIB/%so/dylib}
36 fi
Brian Carlstromdc959ea2013-10-28 00:44:49 -070037 shift
38 elif [ "x$1" = "x--boot" ]; then
39 shift
40 BOOT_OPT="$1"
Ian Rogers6950e652012-08-28 18:20:00 -070041 shift
jeffhao5d1ac922011-09-29 17:41:15 -070042 elif [ "x$1" = "x--debug" ]; then
Brian Carlstromfa42b442013-06-17 12:53:45 -070043 DEBUGGER="y"
jeffhao5d1ac922011-09-29 17:41:15 -070044 shift
45 elif [ "x$1" = "x--gdb" ]; then
46 GDB="y"
Ian Rogers6030ef42013-02-20 14:15:53 -080047 DEV_MODE="y"
jeffhao5d1ac922011-09-29 17:41:15 -070048 shift
Elliott Hughes7c046102011-10-19 18:16:03 -070049 elif [ "x$1" = "x--invoke-with" ]; then
50 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -070051 if [ "x$1" = "x" ]; then
52 echo "$0 missing argument to --invoke-with" 1>&2
53 exit 1
54 fi
Ian Rogers0e033672013-04-19 10:22:46 -070055 if [ "x$INVOKE_WITH" = "x" ]; then
56 INVOKE_WITH="$1"
57 else
58 INVOKE_WITH="$INVOKE_WITH $1"
59 fi
jeffhao5d1ac922011-09-29 17:41:15 -070060 shift
61 elif [ "x$1" = "x--dev" ]; then
62 DEV_MODE="y"
63 shift
jeffhao0dff3f42012-11-20 15:13:43 -080064 elif [ "x$1" = "x--interpreter" ]; then
65 INTERPRETER="y"
66 shift
Ian Rogersafd9acc2014-06-17 08:21:54 -070067 elif [ "x$1" = "x--64" ]; then
68 exe="${ANDROID_HOST_OUT}/bin/dalvikvm64"
69 shift
jeffhao5d1ac922011-09-29 17:41:15 -070070 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 Geoffray92cf83e2014-03-18 17:59:20 +000076 elif [ "x$1" = "x-Xcompiler-option" ]; then
77 shift
78 option="$1"
Mathieu Chartier769a5ad2014-05-18 15:30:10 -070079 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 Geoffray92cf83e2014-03-18 17:59:20 +000085 shift
jeffhao5d1ac922011-09-29 17:41:15 -070086 elif [ "x$1" = "x--" ]; then
87 shift
88 break
89 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -070090 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -070091 exit 1
92 else
93 break
94 fi
95done
96
jeffhao5d1ac922011-09-29 17:41:15 -070097msg "------------------------------"
98
jeffhao5d1ac922011-09-29 17:41:15 -070099export ANDROID_PRINTF_LOG=brief
100if [ "$DEV_MODE" = "y" ]; then
101 export ANDROID_LOG_TAGS='*:d'
102else
103 export ANDROID_LOG_TAGS='*:s'
104fi
Brian Carlstrom105215d2012-06-14 12:50:44 -0700105export ANDROID_DATA="$DEX_LOCATION"
Elliott Hughese7fb2a62012-04-23 12:39:12 -0700106export ANDROID_ROOT="${ANDROID_HOST_OUT}"
jeffhao5d1ac922011-09-29 17:41:15 -0700107export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
108export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
109
Brian Carlstromfa42b442013-06-17 12:53:45 -0700110if [ "$DEBUGGER" = "y" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -0700111 PORT=8000
Elliott Hughes72395bf2012-04-24 13:45:26 -0700112 msg "Waiting for jdb to connect:"
113 msg " jdb -attach localhost:$PORT"
Brian Carlstromfa42b442013-06-17 12:53:45 -0700114 DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
jeffhao5d1ac922011-09-29 17:41:15 -0700115fi
116
117if [ "$GDB" = "y" ]; then
Ian Rogers2a65d4b2014-06-16 22:16:21 -0700118 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
jeffhao5d1ac922011-09-29 17:41:15 -0700128fi
129
jeffhao0dff3f42012-11-20 15:13:43 -0800130if [ "$INTERPRETER" = "y" ]; then
131 INT_OPTS="-Xint"
132fi
133
Mathieu Chartierdbe6f462012-09-25 16:54:50 -0700134JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"
Elliott Hughes72395bf2012-04-24 13:45:26 -0700135
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700136if [ "$DEV_MODE" = "y" ]; then
137 echo $cmdline "$@"
138fi
139
Brian Carlstrom4855cd52012-04-03 21:38:13 -0700140cd $ANDROID_BUILD_TOP
Mathieu Chartier769a5ad2014-05-18 15:30:10 -0700141$INVOKE_WITH $gdb $exe $gdbargs -XXlib:$LIB $JNI_OPTS $FLAGS $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@"