Home | History | Annotate | Download | only in etc
      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.
      5 
      6 msg() {
      7     if [ "$QUIET" = "n" ]; then
      8         echo "$@"
      9     fi
     10 }
     11 
     12 LIB="libartd.so"
     13 DEBUGGER="n"
     14 GDB="n"
     15 INTERPRETER="n"
     16 VERIFY="y"
     17 OPTIMIZE="y"
     18 INVOKE_WITH=""
     19 DEV_MODE="n"
     20 QUIET="n"
     21 
     22 while true; do
     23     if [ "x$1" = "x--quiet" ]; then
     24         QUIET="y"
     25         shift
     26     elif [ "x$1" = "x-lib" ]; then
     27         shift
     28         LIB="$1"
     29     elif [ "x$1" = "x-O" ]; then
     30         LIB="libart.so"
     31         shift
     32     elif [ "x$1" = "x--debug" ]; then
     33         DEBUGGER="y"
     34         shift
     35     elif [ "x$1" = "x--gdb" ]; then
     36         GDB="y"
     37         DEV_MODE="y"
     38         shift
     39     elif [ "x$1" = "x--invoke-with" ]; then
     40         shift
     41         if [ "x$INVOKE_WITH" = "x" ]; then
     42             INVOKE_WITH="$1"
     43         else
     44             INVOKE_WITH="$INVOKE_WITH $1"
     45         fi
     46         shift
     47     elif [ "x$1" = "x--dev" ]; then
     48         DEV_MODE="y"
     49         shift
     50     elif [ "x$1" = "x--interpreter" ]; then
     51         INTERPRETER="y"
     52         shift
     53     elif [ "x$1" = "x--no-verify" ]; then
     54         VERIFY="n"
     55         shift
     56     elif [ "x$1" = "x--no-optimize" ]; then
     57         OPTIMIZE="n"
     58         shift
     59     elif [ "x$1" = "x--" ]; then
     60         shift
     61         break
     62     elif expr "x$1" : "x--" >/dev/null 2>&1; then
     63         echo "unknown $0 option: $1" 1>&2
     64         exit 1
     65     else
     66         break
     67     fi
     68 done
     69 
     70 msg "------------------------------"
     71 
     72 mkdir $DEX_LOCATION/dalvik-cache
     73 [[ $? -ne 0 ]] && exit
     74 
     75 export ANDROID_PRINTF_LOG=brief
     76 if [ "$DEV_MODE" = "y" ]; then
     77     export ANDROID_LOG_TAGS='*:d'
     78 else
     79     export ANDROID_LOG_TAGS='*:s'
     80 fi
     81 export ANDROID_DATA="$DEX_LOCATION"
     82 export ANDROID_ROOT="${ANDROID_HOST_OUT}"
     83 export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
     84 export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
     85 unset ANDROID_PRODUCT_OUT # avoid defaulting dex2oat --host-prefix to target output
     86 
     87 exe="${ANDROID_ROOT}/bin/dalvikvm"
     88 
     89 if [ "$DEBUGGER" = "y" ]; then
     90     PORT=8000
     91     msg "Waiting for jdb to connect:"
     92     msg "    jdb -attach localhost:$PORT"
     93     DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
     94 fi
     95 
     96 if [ "$GDB" = "y" ]; then
     97     gdb=gdb
     98     gdbargs="--args $exe"
     99     # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line.
    100     # gdbargs="--annotate=3 $gdbargs"
    101 fi
    102 
    103 if [ "$INTERPRETER" = "y" ]; then
    104     INT_OPTS="-Xint"
    105 fi
    106 
    107 JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"
    108 
    109 cd $ANDROID_BUILD_TOP
    110 $INVOKE_WITH $gdb $exe $gdbargs -XXlib:$LIB -Ximage:$ANDROID_ROOT/framework/core.art \
    111     $JNI_OPTS $INT_OPTS $DEBUGGER_OPTS \
    112     -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@"
    113