diff options
Diffstat (limited to 'tools/art')
-rw-r--r-- | tools/art | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -1,5 +1,3 @@ -#!/bin/bash -# # Copyright (C) 2011 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +# This script is used on host and device. It uses a common subset +# shell dialect that should work on the host (e.g. bash), and +# Android (e.g. mksh). + function follow_links() { if [ z"$BASH_SOURCE" != z ]; then file="$BASH_SOURCE" @@ -28,7 +30,8 @@ function follow_links() { } function find_libdir() { - if [ "$(readlink "$ANDROID_ROOT/bin/$DALVIKVM")" = "dalvikvm64" ]; then + # Use realpath instead of readlink because Android does not have a readlink. + if [ "$(realpath "$ANDROID_ROOT/bin/$DALVIKVM")" = "$(realpath "$ANDROID_ROOT/bin/dalvikvm64")" ]; then echo "lib64" else echo "lib" @@ -70,16 +73,22 @@ done PROG_NAME="$(follow_links)" PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" ANDROID_ROOT=$PROG_DIR/.. -ANDROID_DATA=$PWD/android-data$$ LIBDIR=$(find_libdir) LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBDIR - if [ z"$PERF" != z ]; then invoke_with="perf record -o $ANDROID_DATA/perf.data -e cycles:u $invoke_with" fi -mkdir -p $ANDROID_DATA/dalvik-cache/{arm,arm64,x86,x86_64} +DELETE_ANDROID_DATA=false +# If ANDROID_DATA is the system ANDROID_DATA or is not set, use our own, +# and ensure we delete it at the end. +if [ "$ANDROID_DATA" = "/data" ] || [ "$ANDROID_DATA" = "" ]; then + ANDROID_DATA=$PWD/android-data$$ + mkdir -p $ANDROID_DATA/dalvik-cache/{arm,arm64,x86,x86_64} + DELETE_ANDROID_DATA=true +fi + ANDROID_DATA=$ANDROID_DATA \ ANDROID_ROOT=$ANDROID_ROOT \ LD_LIBRARY_PATH=$LD_LIBRARY_PATH \ @@ -97,7 +106,9 @@ if [ z"$PERF" != z ]; then fi echo "Perf data saved in: $ANDROID_DATA/perf.data" else - rm -rf $ANDROID_DATA + if [ "$DELETE_ANDROID_DATA" = "true" ]; then + rm -rf $ANDROID_DATA + fi fi exit $EXIT_STATUS |