Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | # Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file |
| 3 | # for details. All rights reserved. Use of this source code is governed by a |
| 4 | # BSD-style license that can be found in the LICENSE file. |
| 5 | |
| 6 | # This script will update the host art VM in tools/linux/art |
| 7 | |
| 8 | # Before running this script make sure that you have a full android build |
| 9 | # and that the host Art version required is build in ~/android/master: |
| 10 | # |
| 11 | # m -j24 |
| 12 | # m -j24 build-art |
| 13 | # |
| 14 | # Maybe also run the Art host tests: |
| 15 | # |
| 16 | # m -j24 test-art-host |
| 17 | |
| 18 | set -e |
| 19 | |
| 20 | ANDROID_CHECKOUT=~/android/master |
| 21 | ANDROID_PRODUCT=angler |
| 22 | ART_DIR=art |
| 23 | DEST_ROOT=tools/linux |
| 24 | |
| 25 | function usage { |
| 26 | echo "Usage: $(basename $0)" |
| 27 | echo " [--android-checkout <android repo root>]" |
| 28 | echo " [--art-dir <destination directory>]" |
| 29 | echo " [--android-product <product name>]" |
| 30 | echo " [--destination-dir <destination directory>]" |
| 31 | echo "" |
| 32 | echo " --android-checkout specifies the Android repo root" |
| 33 | echo " Defaults to: $ANDROID_CHECKOUT" |
| 34 | echo "" |
| 35 | echo " --art-dir specifies the directory name inside the root destination" |
| 36 | echo " directory for the art bundle" |
| 37 | echo " Defaults to: $ART_DIR" |
| 38 | echo "" |
| 39 | echo " --android-product specifies the Android product for the framework to include" |
| 40 | echo " Defaults to: $ANDROID_PRODUCT" |
| 41 | echo "" |
| 42 | echo " --destination-dir specifies the root destination directory for the art bundle" |
| 43 | echo " Defaults to: $DEST_ROOT" |
| 44 | echo "" |
| 45 | echo "Update the master version of art from ~/android/master:" |
| 46 | echo " " |
| 47 | echo " $(basename $0)" |
| 48 | echo " " |
| 49 | echo "Update a specific version of art:" |
| 50 | echo " " |
| 51 | echo " $(basename $0) --android-checkout ~/android/5.1.1_r19 --art-dir 5.1.1" |
| 52 | echo " " |
| 53 | echo "Test the Art bundle in a temporary directory:" |
| 54 | echo " " |
| 55 | echo " $(basename $0) --android-checkout ~/android/5.1.1_r19 --art-dir art-5.1.1 --android-product mako --destination-dir /tmp/art" |
| 56 | echo " " |
| 57 | exit 1 |
| 58 | } |
| 59 | |
| 60 | # Process options. |
| 61 | while [ $# -gt 0 ]; do |
| 62 | case $1 in |
| 63 | --android-checkout) |
| 64 | ANDROID_CHECKOUT="$2" |
| 65 | shift 2 |
| 66 | ;; |
| 67 | --art-dir) |
| 68 | ART_DIR="$2" |
| 69 | shift 2 |
| 70 | ;; |
| 71 | --android-product) |
| 72 | ANDROID_PRODUCT="$2" |
| 73 | shift 2 |
| 74 | ;; |
| 75 | --destination-dir) |
| 76 | DEST_ROOT="$2" |
| 77 | shift 2 |
| 78 | ;; |
| 79 | --help|-h|-H|-\?) |
| 80 | usage |
| 81 | ;; |
| 82 | *) |
| 83 | echo "Unkonwn option $1" |
| 84 | echo "" |
| 85 | usage |
| 86 | ;; |
| 87 | esac |
| 88 | done |
| 89 | |
| 90 | ANDROID_HOST_BUILD=$ANDROID_CHECKOUT/out/host/linux-x86 |
| 91 | ANDROID_TARGET_BUILD=$ANDROID_CHECKOUT/out/target |
| 92 | DEST=$DEST_ROOT/$ART_DIR |
| 93 | |
| 94 | # Clean out the previous version of Art |
| 95 | rm -rf $DEST |
| 96 | |
| 97 | # Required binaries and scripts. |
| 98 | mkdir -p $DEST/bin |
| 99 | if [ -f $ANDROID_HOST_BUILD/bin/art ]; then |
| 100 | cp $ANDROID_HOST_BUILD/bin/art $DEST/bin |
| 101 | else |
| 102 | cp $ANDROID_CHECKOUT/art/tools/art $DEST/bin |
| 103 | fi |
| 104 | |
| 105 | cp $ANDROID_HOST_BUILD/bin/dalvikvm64 $DEST/bin |
| 106 | cp $ANDROID_HOST_BUILD/bin/dalvikvm32 $DEST/bin |
| 107 | # Copy the dalvikvm link creating a regular file instead, as download_from_google_stroage.py does |
| 108 | # not allow tar files with symbolic links (depending on Android/Art version dalvikvm links to |
| 109 | # dalvikvm32 or dalvikvm64). |
| 110 | cp $ANDROID_HOST_BUILD/bin/dalvikvm $DEST/bin |
| 111 | cp $ANDROID_HOST_BUILD/bin/dex2oat $DEST/bin |
| 112 | cp $ANDROID_HOST_BUILD/bin/patchoat $DEST/bin |
| 113 | |
| 114 | # Required framework files. |
| 115 | mkdir -p $DEST/framework |
| 116 | cp -R $ANDROID_HOST_BUILD/framework/* $DEST/framework |
| 117 | |
| 118 | # Required library files. |
| 119 | mkdir -p $DEST/lib64 |
| 120 | cp -r $ANDROID_HOST_BUILD/lib64/* $DEST/lib64 |
| 121 | mkdir -p $DEST/lib |
| 122 | cp -r $ANDROID_HOST_BUILD/lib/* $DEST/lib |
| 123 | |
| 124 | # Image files required for dex2oat of actual android apps. We need an actual android product |
| 125 | # image containing framework classes to verify the code against. |
| 126 | mkdir -p $DEST/product/$ANDROID_PRODUCT/system/framework |
| 127 | cp -r $ANDROID_TARGET_BUILD/product/$ANDROID_PRODUCT/system/framework/* $DEST/product/$ANDROID_PRODUCT/system/framework |
| 128 | |
| 129 | # Required auxillary files. |
| 130 | mkdir -p $DEST/usr/icu |
| 131 | cp -r $ANDROID_HOST_BUILD/usr/icu/* $DEST/usr/icu |
| 132 | |
| 133 | # Allow failure for strip commands below. |
| 134 | set +e |
| 135 | |
| 136 | strip $DEST/bin/* 2> /dev/null |
| 137 | strip $DEST/lib/* |
| 138 | strip $DEST/lib64/* |
| 139 | strip $DEST/framework/x86/* 2> /dev/null |
| 140 | strip $DEST/framework/x86_64/* 2> /dev/null |
| 141 | |
| 142 | echo "Now run" |
| 143 | echo "(cd $DEST_ROOT; upload_to_google_storage.py -a --bucket r8-deps $ART_DIR)" |