Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | # |
| 3 | # Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file |
| 4 | # for details. All rights reserved. Use of this source code is governed by a |
| 5 | # BSD-style license that can be found in the LICENSE file. |
| 6 | |
| 7 | set -e |
| 8 | |
| 9 | if [ -z "$R8_HOME" ]; then |
| 10 | R8_HOME="$(realpath $(dirname ${BASH_SOURCE[0]})/..)" |
| 11 | fi |
| 12 | |
| 13 | TOOLSDIR=$R8_HOME/tools/linux |
| 14 | |
| 15 | function usage { |
| 16 | echo "Usage: $(basename $0) <dex files>" |
| 17 | exit 1 |
| 18 | } |
| 19 | |
| 20 | # Process options. |
| 21 | while [ $# -gt 0 ]; do |
| 22 | case $1 in |
| 23 | -h) |
| 24 | usage |
| 25 | ;; |
| 26 | *) |
| 27 | break |
| 28 | ;; |
| 29 | esac |
| 30 | done |
| 31 | |
| 32 | if [ $# -eq 0 ]; then |
| 33 | usage |
| 34 | fi |
| 35 | |
| 36 | TMPDIR=$(mktemp -d "${TMP:-/tmp/}$(basename $0).XXXXXXXXXXXX") |
| 37 | OATFILE=$TMPDIR/all.oat |
| 38 | |
| 39 | if [ $# -gt 1 ]; then |
| 40 | JARFILE="$TMPDIR/all.jar" |
| 41 | for f in "$@"; do |
| 42 | IR=$(dirname "$f") |
| 43 | BASE=$(basename "$f") |
| 44 | EXT=$(echo "$BASE" | cut -d '.' -f 2) |
| 45 | if [ "$EXT" = "dex" ]; then |
| 46 | (cd "$DIR" && zip "$JARFILE" "$BASE") |
| 47 | else |
| 48 | echo "Warning: ignoring non-dex file argument when dex2oat'ing multiple files." |
| 49 | fi |
| 50 | done |
| 51 | else |
| 52 | JARFILE="$1" |
| 53 | fi |
| 54 | |
| 55 | LD_LIBRARY_PATH=$TOOLSDIR/art/lib $TOOLSDIR/art/bin/dex2oat \ |
| 56 | --android-root=$TOOLSDIR/art/product/angler \ |
| 57 | --runtime-arg -Xnorelocate \ |
| 58 | --boot-image=$TOOLSDIR/art/product/angler/system/framework/boot.art \ |
| 59 | --dex-file=$JARFILE \ |
| 60 | --oat-file=$OATFILE \ |
| 61 | --instruction-set=arm64 \ |
| 62 | --compiler-filter=interpret-only |
| 63 | |
| 64 | rm -rf $TMPDIR |