Eric Holk | 8ee6d8f | 2020-02-07 09:46:12 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2020 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 | |
| 17 | # |
| 18 | # This script compiles Java Language source files into arm64 odex files. |
| 19 | # |
| 20 | # Before running this script, do lunch and build for an arm64 device. |
| 21 | # |
| 22 | # Usage: |
| 23 | # compile-classes.sh Scratch.java |
| 24 | |
| 25 | set -e |
| 26 | |
| 27 | SCRATCH=`mktemp -d` |
| 28 | DEX_FILE=classes.dex |
| 29 | ODEX_FILE=classes.odex |
| 30 | |
| 31 | javac -d $SCRATCH $1 |
| 32 | d8 $SCRATCH/*.class |
| 33 | |
| 34 | $ANDROID_BUILD_TOP/art/tools/compile-jar.sh $DEX_FILE $ODEX_FILE arm64 \ |
| 35 | --generate-debug-info \ |
| 36 | --dump-cfg=classes.cfg |
| 37 | |
| 38 | rm -rf $SCRATCH |
| 39 | |
| 40 | echo |
| 41 | echo "OAT file is at $ODEX_FILE" |
| 42 | echo |
| 43 | echo "View it with one of the following commands:" |
| 44 | echo |
| 45 | echo " oatdump --oat-file=$ODEX_FILE" |
| 46 | echo |
| 47 | echo " aarch64-linux-android-objdump -d $ODEX_FILE" |
| 48 | echo |
| 49 | echo "The CFG is dumped to output.cfg for inspection of individual compiler passes." |
| 50 | echo |