blob: c9c0d4fe5913ee5db1b5bae3cca71a6eb28672d5 [file] [log] [blame]
Nicolas Geoffrayd2f6f772014-03-17 18:26:00 +00001#!/bin/bash
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002#
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 Carlstromfa42b442013-06-17 12:53:45 -070017lib=-XXlib:libart.so
Elliott Hughes4b3b7272011-08-18 09:52:17 -070018invoke_with=
19
20while true; do
21 if [ "$1" = "--invoke-with" ]; then
22 shift
23 invoke_with="$1"
24 shift
25 elif [ "$1" = "-d" ]; then
Brian Carlstromfa42b442013-06-17 12:53:45 -070026 lib="-XXlib:libartd.so"
Elliott Hughes4b3b7272011-08-18 09:52:17 -070027 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
34done
35
Nicolas Geoffray9583fbc2014-02-28 15:21:07 +000036function 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
45PROG_NAME="$(follow_links "$BASH_SOURCE")"
46PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
47ANDROID_BUILD_TOP="$(cd "${PROG_DIR}/../../../../" ; pwd -P)/"
48ANDROID_HOST_OUT=$PROG_DIR/..
Nicolas Geoffray89c4e282014-03-24 09:33:30 +000049ANDROID_DATA=$PWD/android-data$$
Nicolas Geoffray9583fbc2014-02-28 15:21:07 +000050
Nicolas Geoffray89c4e282014-03-24 09:33:30 +000051mkdir -p $ANDROID_DATA/dalvik-cache
52ANDROID_DATA=$ANDROID_DATA \
Elliott Hughesaddf1a82013-02-19 10:50:50 -080053 ANDROID_ROOT=$ANDROID_HOST_OUT \
54 LD_LIBRARY_PATH=$ANDROID_HOST_OUT/lib \
Nicolas Geoffray89c4e282014-03-24 09:33:30 +000055 $invoke_with $ANDROID_HOST_OUT/bin/dalvikvm $lib \
Elliott Hughesaddf1a82013-02-19 10:50:50 -080056 -Ximage:$ANDROID_HOST_OUT/framework/core.art \
57 "$@"
Nicolas Geoffray89c4e282014-03-24 09:33:30 +000058EXIT_STATUS=$?
59rm -rf $ANDROID_DATA
60exit $EXIT_STATUS