blob: a84c9465c833754185254f8cc3956fc2c2a14c21 [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
Søren Gjesse76a5e332022-08-16 13:26:46 +020094# Clean out the previous version of Art.
Mads Ager418d1ca2017-05-22 09:35:49 +020095rm -rf $DEST
96
Søren Gjesse76a5e332022-08-16 13:26:46 +020097# Copy build_spec.xml for documentation.
98mkdir -p $DEST
99if [ -f $ANDROID_CHECKOUT/build_spec.xml ]; then
100 cp $ANDROID_CHECKOUT/build_spec.xml $DEST
101 # Remove the build spec to ensure it is created anew for a new build.
102 rm $ANDROID_CHECKOUT/build_spec.xml
103else
104 echo "File $ANDROID_CHECKOUT/build_spec.xml not found. Please run"
105 echo
106 echo " repo manifest -r -o build_spec.xml"
107 echo
108 echo "in $ANDROID_CHECKOUT"
109 exit 1
110fi
111
Mads Ager418d1ca2017-05-22 09:35:49 +0200112# Required binaries and scripts.
113mkdir -p $DEST/bin
114if [ -f $ANDROID_HOST_BUILD/bin/art ]; then
115 cp $ANDROID_HOST_BUILD/bin/art $DEST/bin
116else
117 cp $ANDROID_CHECKOUT/art/tools/art $DEST/bin
118fi
119
120cp $ANDROID_HOST_BUILD/bin/dalvikvm64 $DEST/bin
121cp $ANDROID_HOST_BUILD/bin/dalvikvm32 $DEST/bin
122# Copy the dalvikvm link creating a regular file instead, as download_from_google_stroage.py does
123# not allow tar files with symbolic links (depending on Android/Art version dalvikvm links to
124# dalvikvm32 or dalvikvm64).
125cp $ANDROID_HOST_BUILD/bin/dalvikvm $DEST/bin
126cp $ANDROID_HOST_BUILD/bin/dex2oat $DEST/bin
Søren Gjesse953f7c42021-08-18 16:42:06 +0200127if [ -e $ANDROID_HOST_BUILD/bin/dex2oat64 ]
128 then cp $ANDROID_HOST_BUILD/bin/dex2oat64 $DEST/bin
129fi
clementbera97d5cce2019-11-22 15:09:27 +0100130if [ -e $ANDROID_HOST_BUILD/bin/patchoat ]
131 # File patchoat does not exist on Q anymore.
132 then cp $ANDROID_HOST_BUILD/bin/patchoat $DEST/bin
133fi
Mads Ager418d1ca2017-05-22 09:35:49 +0200134
Søren Gjesse953f7c42021-08-18 16:42:06 +0200135
Mads Ager418d1ca2017-05-22 09:35:49 +0200136# Required framework files.
137mkdir -p $DEST/framework
Rico Wind450a9b12023-09-20 07:17:15 +0200138mkdir -p $DEST/out/host/linux-x86/framework
Mads Ager418d1ca2017-05-22 09:35:49 +0200139cp -R $ANDROID_HOST_BUILD/framework/* $DEST/framework
Rico Wind450a9b12023-09-20 07:17:15 +0200140cp $ANDROID_HOST_BUILD/framework/*.jar $DEST/out/host/linux-x86/framework
Mads Ager418d1ca2017-05-22 09:35:49 +0200141
142# Required library files.
143mkdir -p $DEST/lib64
144cp -r $ANDROID_HOST_BUILD/lib64/* $DEST/lib64
145mkdir -p $DEST/lib
146cp -r $ANDROID_HOST_BUILD/lib/* $DEST/lib
147
148# Image files required for dex2oat of actual android apps. We need an actual android product
149# image containing framework classes to verify the code against.
150mkdir -p $DEST/product/$ANDROID_PRODUCT/system/framework
Søren Gjesse953f7c42021-08-18 16:42:06 +0200151cp -rL $ANDROID_TARGET_BUILD/product/$ANDROID_PRODUCT/system/framework/* $DEST/product/$ANDROID_PRODUCT/system/framework
Mads Ager418d1ca2017-05-22 09:35:49 +0200152
153# Required auxillary files.
Søren Gjesse953f7c42021-08-18 16:42:06 +0200154if [ -e $ANDROID_HOST_BUILD/apex ]; then
155 mkdir -p $DEST/apex
156 cp -rL $ANDROID_HOST_BUILD/apex/* $DEST/apex
157 if [ -e $ANDROID_HOST_BUILD/com.android.i18n ]; then
158 mkdir -p $DEST/com.android.i18n
159 cp -r $ANDROID_HOST_BUILD/com.android.i18n/* $DEST/com.android.i18n
160 fi
161 if [ -e $ANDROID_HOST_BUILD/com.android.tzdata ]; then
162 mkdir -p $DEST/com.android.tzdata
163 cp -r $ANDROID_HOST_BUILD/com.android.tzdata/* $DEST/com.android.tzdata
164 fi
165 if [ -e $ANDROID_HOST_BUILD/usr ]; then
166 mkdir -p $DEST/usr
167 cp -r $ANDROID_HOST_BUILD/usr/* $DEST/usr
168 fi
clementbera97d5cce2019-11-22 15:09:27 +0100169else
Søren Gjesse953f7c42021-08-18 16:42:06 +0200170 if [ -e $ANDROID_HOST_BUILD/usr/icu ]; then
171 mkdir -p $DEST/usr/icu
172 cp -r $ANDROID_HOST_BUILD/usr/icu/* $DEST/usr/icu
173 else
174 mkdir -p $DEST/com.android.runtime/etc/icu/
175 cp -r $ANDROID_HOST_BUILD/com.android.runtime/etc/icu/* $DEST/com.android.runtime/etc/icu/
176 fi
clementbera97d5cce2019-11-22 15:09:27 +0100177fi
Mads Ager418d1ca2017-05-22 09:35:49 +0200178
Søren Gjessefe7c0112018-12-03 12:33:12 +0100179# Update links for vdex files for Android P and later.
180if [ -f $DEST/product/$ANDROID_PRODUCT/system/framework/boot.vdex ]; then
181 for VDEXFILE in $DEST/product/$ANDROID_PRODUCT/system/framework/*.vdex; do
182 VDEXNAME=$(basename ${VDEXFILE});
Søren Gjesse29b639d2024-05-28 14:39:56 +0200183 # Maybe remove arm here.
Søren Gjessefe7c0112018-12-03 12:33:12 +0100184 for ARCH in arm arm64; do
185 rm $DEST/product/$ANDROID_PRODUCT/system/framework/$ARCH/${VDEXNAME};
186 # This relative link command will create a symbolic link of the form
187 # ../${VDEXNAME} for each architecture.
Søren Gjesse83947cf2018-12-03 14:49:22 +0100188 # ln -r -s $DEST/product/$ANDROID_PRODUCT/system/framework/${VDEXNAME} $DEST/product/$ANDROID_PRODUCT/system/framework/$ARCH/${VDEXNAME};
189 # The Cloud Storage dependency tool (download_from_google_storage.py) does
190 # not allow synlinks at all, so instad of the ln in the comment above just
191 # copy the ${VDEXNAME} files.
192 cp $DEST/product/$ANDROID_PRODUCT/system/framework/${VDEXNAME} $DEST/product/$ANDROID_PRODUCT/system/framework/$ARCH/${VDEXNAME};
Søren Gjessefe7c0112018-12-03 12:33:12 +0100193 done
194 done
195fi
196
Mads Ager418d1ca2017-05-22 09:35:49 +0200197# Allow failure for strip commands below.
198set +e
199
200strip $DEST/bin/* 2> /dev/null
201strip $DEST/lib/*
202strip $DEST/lib64/*
203strip $DEST/framework/x86/* 2> /dev/null
204strip $DEST/framework/x86_64/* 2> /dev/null
205
206echo "Now run"
207echo "(cd $DEST_ROOT; upload_to_google_storage.py -a --bucket r8-deps $ART_DIR)"
Rico Wind450a9b12023-09-20 07:17:15 +0200208echo "NOTE; If $ART_DIR has several directory elements adjust accordingly."