• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
7set -e
8
9if [ -z "$R8_HOME" ]; then
10  R8_HOME="$(realpath $(dirname ${BASH_SOURCE[0]})/..)"
11fi
12
13TOOLSDIR=$R8_HOME/tools/linux
14
15function usage {
16  echo "Usage: $(basename $0) <dex files>"
17  exit 1
18}
19
20# Process options.
21while [ $# -gt 0 ]; do
22  case $1 in
23    -h)
24      usage
25      ;;
26    *)
27      break
28      ;;
29  esac
30done
31
32if [ $# -eq 0 ]; then
33  usage
34fi
35
36TMPDIR=$(mktemp -d "${TMP:-/tmp/}$(basename $0).XXXXXXXXXXXX")
37OATFILE=$TMPDIR/all.oat
38
39if [ $# -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
51else
52  JARFILE="$1"
53fi
54
55LD_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
64rm -rf $TMPDIR
65