blob: 9ba0a99ac443c206bc092f918c9a8ca90afeab9d [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
jeffhao5d1ac922011-09-29 17:41:15 -070012DEBUG="n"
13GDB="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"
Ian Rogers6950e652012-08-28 18:20:00 -070020OATEXEC="oatexecd"
jeffhao5d1ac922011-09-29 17:41:15 -070021
22while true; do
23 if [ "x$1" = "x--quiet" ]; then
24 QUIET="y"
25 shift
Ian Rogers6950e652012-08-28 18:20:00 -070026 elif [ "x$1" = "x-O" ]; then
27 OATEXEC="oatexec"
28 shift
jeffhao5d1ac922011-09-29 17:41:15 -070029 elif [ "x$1" = "x--debug" ]; then
30 DEBUG="y"
31 shift
32 elif [ "x$1" = "x--gdb" ]; then
33 GDB="y"
Ian Rogers6030ef42013-02-20 14:15:53 -080034 DEV_MODE="y"
jeffhao5d1ac922011-09-29 17:41:15 -070035 shift
Elliott Hughes7c046102011-10-19 18:16:03 -070036 elif [ "x$1" = "x--invoke-with" ]; then
37 shift
38 INVOKE_WITH="$1"
jeffhao5d1ac922011-09-29 17:41:15 -070039 shift
40 elif [ "x$1" = "x--dev" ]; then
41 DEV_MODE="y"
42 shift
jeffhao0dff3f42012-11-20 15:13:43 -080043 elif [ "x$1" = "x--interpreter" ]; then
44 INTERPRETER="y"
45 shift
jeffhao5d1ac922011-09-29 17:41:15 -070046 elif [ "x$1" = "x--no-verify" ]; then
47 VERIFY="n"
48 shift
49 elif [ "x$1" = "x--no-optimize" ]; then
50 OPTIMIZE="n"
51 shift
jeffhao5d1ac922011-09-29 17:41:15 -070052 elif [ "x$1" = "x--" ]; then
53 shift
54 break
55 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -070056 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -070057 exit 1
58 else
59 break
60 fi
61done
62
jeffhao5d1ac922011-09-29 17:41:15 -070063msg "------------------------------"
64
Brian Carlstrom105215d2012-06-14 12:50:44 -070065mkdir $DEX_LOCATION/art-cache
66[[ $? -ne 0 ]] && exit
jeffhao5d1ac922011-09-29 17:41:15 -070067
68export ANDROID_PRINTF_LOG=brief
69if [ "$DEV_MODE" = "y" ]; then
70 export ANDROID_LOG_TAGS='*:d'
71else
72 export ANDROID_LOG_TAGS='*:s'
73fi
Brian Carlstrom105215d2012-06-14 12:50:44 -070074export ANDROID_DATA="$DEX_LOCATION"
Elliott Hughese7fb2a62012-04-23 12:39:12 -070075export ANDROID_ROOT="${ANDROID_HOST_OUT}"
jeffhao5d1ac922011-09-29 17:41:15 -070076export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
77export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
Brian Carlstrom2ab7f482012-06-04 15:37:25 -070078unset ANDROID_PRODUCT_OUT # avoid defaulting dex2oat --host-prefix to target output
jeffhao5d1ac922011-09-29 17:41:15 -070079
Ian Rogers6950e652012-08-28 18:20:00 -070080exe="${ANDROID_ROOT}/bin/${OATEXEC}"
jeffhao5d1ac922011-09-29 17:41:15 -070081
82if [ "$DEBUG" = "y" ]; then
83 PORT=8000
Elliott Hughes72395bf2012-04-24 13:45:26 -070084 msg "Waiting for jdb to connect:"
85 msg " jdb -attach localhost:$PORT"
86 DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
jeffhao5d1ac922011-09-29 17:41:15 -070087fi
88
89if [ "$GDB" = "y" ]; then
90 gdb=gdb
Brian Carlstromebf7eab2013-03-06 15:22:27 -080091 gdbargs="--args $exe"
92 # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line.
93 # gdbargs="--annotate=3 $gdbargs"
jeffhao5d1ac922011-09-29 17:41:15 -070094fi
95
jeffhao0dff3f42012-11-20 15:13:43 -080096if [ "$INTERPRETER" = "y" ]; then
97 INT_OPTS="-Xint"
98fi
99
Mathieu Chartierdbe6f462012-09-25 16:54:50 -0700100JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"
Elliott Hughes72395bf2012-04-24 13:45:26 -0700101
Brian Carlstrom4855cd52012-04-03 21:38:13 -0700102cd $ANDROID_BUILD_TOP
103$INVOKE_WITH $gdb $exe $gdbargs -Ximage:$ANDROID_ROOT/framework/core.art \
jeffhao0dff3f42012-11-20 15:13:43 -0800104 $JNI_OPTS $INT_OPTS $DEBUG_OPTS \
TDYa127b92bcab2012-04-08 00:09:51 -0700105 -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@"