blob: a844e82bc6cd3b22580127eaeb28a680526b655b [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"
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +000020COMPILER_OPTIONS=""
jeffhao5d1ac922011-09-29 17:41:15 -070021
22while true; do
23 if [ "x$1" = "x--quiet" ]; then
24 QUIET="y"
25 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -070026 elif [ "x$1" = "x--lib" ]; then
Brian Carlstromfa42b442013-06-17 12:53:45 -070027 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -070028 if [ "x$1" = "x" ]; then
29 echo "$0 missing argument to --lib" 1>&2
30 exit 1
31 fi
Brian Carlstromfa42b442013-06-17 12:53:45 -070032 LIB="$1"
Brian Carlstromdc959ea2013-10-28 00:44:49 -070033 shift
34 elif [ "x$1" = "x--boot" ]; then
35 shift
36 BOOT_OPT="$1"
Ian Rogers6950e652012-08-28 18:20:00 -070037 shift
jeffhao5d1ac922011-09-29 17:41:15 -070038 elif [ "x$1" = "x--debug" ]; then
Brian Carlstromfa42b442013-06-17 12:53:45 -070039 DEBUGGER="y"
jeffhao5d1ac922011-09-29 17:41:15 -070040 shift
41 elif [ "x$1" = "x--gdb" ]; then
42 GDB="y"
Ian Rogers6030ef42013-02-20 14:15:53 -080043 DEV_MODE="y"
jeffhao5d1ac922011-09-29 17:41:15 -070044 shift
Elliott Hughes7c046102011-10-19 18:16:03 -070045 elif [ "x$1" = "x--invoke-with" ]; then
46 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -070047 if [ "x$1" = "x" ]; then
48 echo "$0 missing argument to --invoke-with" 1>&2
49 exit 1
50 fi
Ian Rogers0e033672013-04-19 10:22:46 -070051 if [ "x$INVOKE_WITH" = "x" ]; then
52 INVOKE_WITH="$1"
53 else
54 INVOKE_WITH="$INVOKE_WITH $1"
55 fi
jeffhao5d1ac922011-09-29 17:41:15 -070056 shift
57 elif [ "x$1" = "x--dev" ]; then
58 DEV_MODE="y"
59 shift
jeffhao0dff3f42012-11-20 15:13:43 -080060 elif [ "x$1" = "x--interpreter" ]; then
61 INTERPRETER="y"
62 shift
jeffhao5d1ac922011-09-29 17:41:15 -070063 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 Geoffray92cf83e2014-03-18 17:59:20 +000069 elif [ "x$1" = "x-Xcompiler-option" ]; then
70 shift
71 option="$1"
72 COMPILER_OPTIONS="${COMPILER_OPTIONS} -Xcompiler-option $option"
73 shift
jeffhao5d1ac922011-09-29 17:41:15 -070074 elif [ "x$1" = "x--" ]; then
75 shift
76 break
77 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -070078 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -070079 exit 1
80 else
81 break
82 fi
83done
84
jeffhao5d1ac922011-09-29 17:41:15 -070085msg "------------------------------"
86
Brian Carlstrom7675e162013-06-10 16:18:04 -070087mkdir $DEX_LOCATION/dalvik-cache
Mark Mendellea6404e2013-12-20 06:07:51 -080088if [ $? -ne 0 ]; then
89 exit
90fi
jeffhao5d1ac922011-09-29 17:41:15 -070091
92export ANDROID_PRINTF_LOG=brief
93if [ "$DEV_MODE" = "y" ]; then
94 export ANDROID_LOG_TAGS='*:d'
95else
96 export ANDROID_LOG_TAGS='*:s'
97fi
Brian Carlstrom105215d2012-06-14 12:50:44 -070098export ANDROID_DATA="$DEX_LOCATION"
Elliott Hughese7fb2a62012-04-23 12:39:12 -070099export ANDROID_ROOT="${ANDROID_HOST_OUT}"
jeffhao5d1ac922011-09-29 17:41:15 -0700100export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
101export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
102
Brian Carlstromfa42b442013-06-17 12:53:45 -0700103exe="${ANDROID_ROOT}/bin/dalvikvm"
jeffhao5d1ac922011-09-29 17:41:15 -0700104
Brian Carlstromfa42b442013-06-17 12:53:45 -0700105if [ "$DEBUGGER" = "y" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -0700106 PORT=8000
Elliott Hughes72395bf2012-04-24 13:45:26 -0700107 msg "Waiting for jdb to connect:"
108 msg " jdb -attach localhost:$PORT"
Brian Carlstromfa42b442013-06-17 12:53:45 -0700109 DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
jeffhao5d1ac922011-09-29 17:41:15 -0700110fi
111
112if [ "$GDB" = "y" ]; then
113 gdb=gdb
Brian Carlstromebf7eab2013-03-06 15:22:27 -0800114 gdbargs="--args $exe"
115 # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line.
116 # gdbargs="--annotate=3 $gdbargs"
jeffhao5d1ac922011-09-29 17:41:15 -0700117fi
118
jeffhao0dff3f42012-11-20 15:13:43 -0800119if [ "$INTERPRETER" = "y" ]; then
120 INT_OPTS="-Xint"
121fi
122
Mathieu Chartierdbe6f462012-09-25 16:54:50 -0700123JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"
Elliott Hughes72395bf2012-04-24 13:45:26 -0700124
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700125if [ "$DEV_MODE" = "y" ]; then
126 echo $cmdline "$@"
127fi
128
Brian Carlstrom4855cd52012-04-03 21:38:13 -0700129cd $ANDROID_BUILD_TOP
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000130$INVOKE_WITH $gdb $exe $gdbargs -XXlib:$LIB $JNI_OPTS $COMPILER_OPTIONS $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@"