blob: 58165cd57ed057b66cd4e168659322a4e39511bb [file] [log] [blame]
Mads Ager418d1ca2017-05-22 09:35:49 +02001#! /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
18set -e
19
20ANDROID_CHECKOUT=~/android/master
21ANDROID_PRODUCT=angler
22ART_DIR=art
23DEST_ROOT=tools/linux
24
25function 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.
61while [ $# -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
88done
89
90ANDROID_HOST_BUILD=$ANDROID_CHECKOUT/out/host/linux-x86
91ANDROID_TARGET_BUILD=$ANDROID_CHECKOUT/out/target
92DEST=$DEST_ROOT/$ART_DIR
93
94# Clean out the previous version of Art
95rm -rf $DEST
96
97# Required binaries and scripts.
98mkdir -p $DEST/bin
99if [ -f $ANDROID_HOST_BUILD/bin/art ]; then
100 cp $ANDROID_HOST_BUILD/bin/art $DEST/bin
101else
102 cp $ANDROID_CHECKOUT/art/tools/art $DEST/bin
103fi
104
105cp $ANDROID_HOST_BUILD/bin/dalvikvm64 $DEST/bin
106cp $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).
110cp $ANDROID_HOST_BUILD/bin/dalvikvm $DEST/bin
111cp $ANDROID_HOST_BUILD/bin/dex2oat $DEST/bin
Søren Gjesse953f7c42021-08-18 16:42:06 +0200112if [ -e $ANDROID_HOST_BUILD/bin/dex2oat64 ]
113 then cp $ANDROID_HOST_BUILD/bin/dex2oat64 $DEST/bin
114fi
clementbera97d5cce2019-11-22 15:09:27 +0100115if [ -e $ANDROID_HOST_BUILD/bin/patchoat ]
116 # File patchoat does not exist on Q anymore.
117 then cp $ANDROID_HOST_BUILD/bin/patchoat $DEST/bin
118fi
Mads Ager418d1ca2017-05-22 09:35:49 +0200119
Søren Gjesse953f7c42021-08-18 16:42:06 +0200120
Mads Ager418d1ca2017-05-22 09:35:49 +0200121# Required framework files.
122mkdir -p $DEST/framework
123cp -R $ANDROID_HOST_BUILD/framework/* $DEST/framework
124
125# Required library files.
126mkdir -p $DEST/lib64
127cp -r $ANDROID_HOST_BUILD/lib64/* $DEST/lib64
128mkdir -p $DEST/lib
129cp -r $ANDROID_HOST_BUILD/lib/* $DEST/lib
130
131# Image files required for dex2oat of actual android apps. We need an actual android product
132# image containing framework classes to verify the code against.
133mkdir -p $DEST/product/$ANDROID_PRODUCT/system/framework
Søren Gjesse953f7c42021-08-18 16:42:06 +0200134cp -rL $ANDROID_TARGET_BUILD/product/$ANDROID_PRODUCT/system/framework/* $DEST/product/$ANDROID_PRODUCT/system/framework
Mads Ager418d1ca2017-05-22 09:35:49 +0200135
136# Required auxillary files.
Søren Gjesse953f7c42021-08-18 16:42:06 +0200137if [ -e $ANDROID_HOST_BUILD/apex ]; then
138 mkdir -p $DEST/apex
139 cp -rL $ANDROID_HOST_BUILD/apex/* $DEST/apex
140 if [ -e $ANDROID_HOST_BUILD/com.android.i18n ]; then
141 mkdir -p $DEST/com.android.i18n
142 cp -r $ANDROID_HOST_BUILD/com.android.i18n/* $DEST/com.android.i18n
143 fi
144 if [ -e $ANDROID_HOST_BUILD/com.android.tzdata ]; then
145 mkdir -p $DEST/com.android.tzdata
146 cp -r $ANDROID_HOST_BUILD/com.android.tzdata/* $DEST/com.android.tzdata
147 fi
148 if [ -e $ANDROID_HOST_BUILD/usr ]; then
149 mkdir -p $DEST/usr
150 cp -r $ANDROID_HOST_BUILD/usr/* $DEST/usr
151 fi
clementbera97d5cce2019-11-22 15:09:27 +0100152else
Søren Gjesse953f7c42021-08-18 16:42:06 +0200153 if [ -e $ANDROID_HOST_BUILD/usr/icu ]; then
154 mkdir -p $DEST/usr/icu
155 cp -r $ANDROID_HOST_BUILD/usr/icu/* $DEST/usr/icu
156 else
157 mkdir -p $DEST/com.android.runtime/etc/icu/
158 cp -r $ANDROID_HOST_BUILD/com.android.runtime/etc/icu/* $DEST/com.android.runtime/etc/icu/
159 fi
clementbera97d5cce2019-11-22 15:09:27 +0100160fi
Mads Ager418d1ca2017-05-22 09:35:49 +0200161
Søren Gjessefe7c0112018-12-03 12:33:12 +0100162# Update links for vdex files for Android P and later.
163if [ -f $DEST/product/$ANDROID_PRODUCT/system/framework/boot.vdex ]; then
164 for VDEXFILE in $DEST/product/$ANDROID_PRODUCT/system/framework/*.vdex; do
165 VDEXNAME=$(basename ${VDEXFILE});
166 for ARCH in arm arm64; do
167 rm $DEST/product/$ANDROID_PRODUCT/system/framework/$ARCH/${VDEXNAME};
168 # This relative link command will create a symbolic link of the form
169 # ../${VDEXNAME} for each architecture.
Søren Gjesse83947cf2018-12-03 14:49:22 +0100170 # ln -r -s $DEST/product/$ANDROID_PRODUCT/system/framework/${VDEXNAME} $DEST/product/$ANDROID_PRODUCT/system/framework/$ARCH/${VDEXNAME};
171 # The Cloud Storage dependency tool (download_from_google_storage.py) does
172 # not allow synlinks at all, so instad of the ln in the comment above just
173 # copy the ${VDEXNAME} files.
174 cp $DEST/product/$ANDROID_PRODUCT/system/framework/${VDEXNAME} $DEST/product/$ANDROID_PRODUCT/system/framework/$ARCH/${VDEXNAME};
Søren Gjessefe7c0112018-12-03 12:33:12 +0100175 done
176 done
177fi
178
Mads Ager418d1ca2017-05-22 09:35:49 +0200179# Allow failure for strip commands below.
180set +e
181
182strip $DEST/bin/* 2> /dev/null
183strip $DEST/lib/*
184strip $DEST/lib64/*
185strip $DEST/framework/x86/* 2> /dev/null
186strip $DEST/framework/x86_64/* 2> /dev/null
187
188echo "Now run"
189echo "(cd $DEST_ROOT; upload_to_google_storage.py -a --bucket r8-deps $ART_DIR)"
Søren Gjesse953f7c42021-08-18 16:42:06 +0200190echo "NOTE; If $ART_DIR has several directory elements adjust accordingly."