| #!/usr/bin/env bash |
| |
| # Copyright (C) 2016 The Android Open Source Project |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| |
| |
| ### |
| ### Change the BOOTCLASSPATH to pick up bootlib classes. |
| ### Export ANDROID_DATA=something else (it should have dalvik-cache dir in it) |
| ### Point the image to something else that's not existing. |
| ### |
| ### Actually run dalvikvm now... |
| ### |
| |
| if [[ -z $ANDROID_BUILD_TOP ]]; then |
| echo "Run source build/envsetup.sh first" >& 2 |
| exit 1 |
| fi |
| |
| invoke_with= |
| DALVIKVM=dalvikvm |
| LIBART=libart.so |
| |
| function follow_links() { |
| if [ z"$BASH_SOURCE" != z ]; then |
| file="$BASH_SOURCE" |
| else |
| file="$0" |
| fi |
| while [ -h "$file" ]; do |
| # On Mac OS, readlink -f doesn't work. |
| file="$(readlink "$file")" |
| done |
| echo "$file" |
| } |
| |
| function find_libdir() { |
| # 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" |
| fi |
| } |
| |
| function join { local IFS="$1"; shift; echo "$*"; } |
| |
| PROG_NAME="$(follow_links)" |
| PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" |
| |
| if [[ -z $ANDROID_ROOT ]]; then |
| # Already set to /system for actual android devices |
| ANDROID_ROOT=$ANDROID_HOST_OUT |
| fi |
| LIBDIR=$(find_libdir) |
| LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBDIR |
| DEBUG_OPTION="" |
| |
| |
| 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$$ |
| IMAGE_DIRECTORY=$ANDROID_DATA/image |
| mkdir -p $ANDROID_DATA/dalvik-cache/{arm,arm64,x86,x86_64} |
| mkdir -p $IMAGE_DIRECTORY |
| DELETE_ANDROID_DATA=true |
| fi |
| |
| |
| IMAGE_LOCATION=$IMAGE_DIRECTORY/core-extrabootclasspath.art |
| |
| BOOT_DEXJARS=( |
| bouncycastle-hostdex.jar |
| apache-xml-hostdex.jar |
| core-tests-hostdex.jar |
| core-libart-hostdex.jar |
| core-lambda-stubs-hostdex.jar |
| conscrypt-hostdex.jar |
| core-ojtests-hostdex.jar |
| core-oj-hostdex.jar |
| okhttp-hostdex.jar) |
| |
| BOOT_DEXJAR_PREFIX="$ANDROID_ROOT/framework" |
| |
| BOOT_DEXJARS_ABS=() |
| for dexjar in ${BOOT_DEXJARS[@]}; do |
| BOOT_DEXJARS_ABS=(${BOOT_DEXJARS_ABS[@]} $BOOT_DEXJAR_PREFIX/$dexjar) |
| done |
| |
| export BOOTCLASSPATH=$(join ":" "${BOOT_DEXJARS_ABS[@]}") # a,b,c |
| |
| echo "BOOTCLASSPATH=$BOOTCLASSPATH" |
| echo "PROG_NAME=$PROG_NAME" |
| echo "PROG_DIR=$PROG_DIR" |
| echo "ANDROID_ROOT=$ANDROID_ROOT" |
| echo "LIBDIR=$LIBDIR" |
| echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" |
| echo "DEBUG_OPTION=$DEBUG_OPTION" |
| |
| echo "export BOOTCLASSPATH=$BOOTCLASSPATH" |
| echo export ANDROID_ROOT="$ANDROID_ROOT" |
| ANDROID_DATA=$ANDROID_DATA \ |
| ANDROID_ROOT=$ANDROID_ROOT \ |
| LD_LIBRARY_PATH=$LD_LIBRARY_PATH \ |
| PATH=$ANDROID_ROOT/bin:$PATH \ |
| LD_USE_LOAD_BIAS=1 \ |
| $invoke_with $ANDROID_ROOT/bin/$DALVIKVM $lib \ |
| -XXlib:$LIBART \ |
| -Xnorelocate \ |
| -Ximage:$IMAGE_LOCATION \ |
| $DEBUG_OPTION \ |
| "$@" |