Nicolas Geoffray | d2f6f77 | 2014-03-17 18:26:00 +0000 | [diff] [blame] | 1 | #!/bin/bash |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2 | # |
| 3 | # Copyright (C) 2011 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Brian Carlstrom | fa42b44 | 2013-06-17 12:53:45 -0700 | [diff] [blame] | 17 | lib=-XXlib:libart.so |
Elliott Hughes | 4b3b727 | 2011-08-18 09:52:17 -0700 | [diff] [blame] | 18 | invoke_with= |
| 19 | |
| 20 | while true; do |
| 21 | if [ "$1" = "--invoke-with" ]; then |
| 22 | shift |
| 23 | invoke_with="$1" |
| 24 | shift |
| 25 | elif [ "$1" = "-d" ]; then |
Brian Carlstrom | fa42b44 | 2013-06-17 12:53:45 -0700 | [diff] [blame] | 26 | lib="-XXlib:libartd.so" |
Elliott Hughes | 4b3b727 | 2011-08-18 09:52:17 -0700 | [diff] [blame] | 27 | shift |
| 28 | elif expr "$1" : "--" >/dev/null 2>&1; then |
| 29 | echo "unknown option: $1" 1>&2 |
| 30 | exit 1 |
| 31 | else |
| 32 | break |
| 33 | fi |
| 34 | done |
| 35 | |
Nicolas Geoffray | 9583fbc | 2014-02-28 15:21:07 +0000 | [diff] [blame] | 36 | function follow_links() { |
| 37 | file="$1" |
| 38 | while [ -h "$file" ]; do |
| 39 | # On Mac OS, readlink -f doesn't work. |
| 40 | file="$(readlink "$file")" |
| 41 | done |
| 42 | echo "$file" |
| 43 | } |
| 44 | |
Nicolas Geoffray | 6354bb8 | 2014-07-02 16:25:12 +0100 | [diff] [blame] | 45 | PROG_NAME="$(follow_links "$BASH_SOURCE")" |
| 46 | PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" |
| 47 | ANDROID_BUILD_TOP="$(cd "${PROG_DIR}/../../../../" ; pwd -P)/" |
| 48 | ANDROID_HOST_OUT=$PROG_DIR/.. |
| 49 | ANDROID_DATA=$PWD/android-data$$ |
Nicolas Geoffray | fc3c67a | 2014-07-02 14:57:53 +0100 | [diff] [blame] | 50 | DALVIKVM_EXECUTABLE=$ANDROID_HOST_OUT/bin/dalvikvm |
| 51 | |
| 52 | function find_libdir() { |
| 53 | if [ "$(readlink "$DALVIKVM_EXECUTABLE")" = "dalvikvm64" ]; then |
| 54 | echo "lib64" |
| 55 | else |
| 56 | echo "lib" |
| 57 | fi |
| 58 | } |
| 59 | |
Nicolas Geoffray | fc3c67a | 2014-07-02 14:57:53 +0100 | [diff] [blame] | 60 | LD_LIBRARY_PATH=$ANDROID_HOST_OUT/"$(find_libdir)" |
Nicolas Geoffray | 9583fbc | 2014-02-28 15:21:07 +0000 | [diff] [blame] | 61 | |
Hiroshi Yamauchi | f5656ce | 2014-05-01 15:14:34 -0700 | [diff] [blame] | 62 | mkdir -p $ANDROID_DATA/dalvik-cache/{x86,x86_64} |
Nicolas Geoffray | 89c4e28 | 2014-03-24 09:33:30 +0000 | [diff] [blame] | 63 | ANDROID_DATA=$ANDROID_DATA \ |
Elliott Hughes | addf1a8 | 2013-02-19 10:50:50 -0800 | [diff] [blame] | 64 | ANDROID_ROOT=$ANDROID_HOST_OUT \ |
Nicolas Geoffray | fc3c67a | 2014-07-02 14:57:53 +0100 | [diff] [blame] | 65 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH \ |
| 66 | $invoke_with $DALVIKVM_EXECUTABLE $lib \ |
Elliott Hughes | addf1a8 | 2013-02-19 10:50:50 -0800 | [diff] [blame] | 67 | -Ximage:$ANDROID_HOST_OUT/framework/core.art \ |
| 68 | "$@" |
Nicolas Geoffray | 89c4e28 | 2014-03-24 09:33:30 +0000 | [diff] [blame] | 69 | EXIT_STATUS=$? |
| 70 | rm -rf $ANDROID_DATA |
| 71 | exit $EXIT_STATUS |