blob: 9462c3b885e6fc5007683774282a51718d1f5d39 [file] [log] [blame]
Andreas Gampe29c111e2019-02-28 13:58:07 -08001#!/system/bin/sh
2
3# Copyright (C) 2019 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. `dirname $0`/art_prepostinstall_utils || exit 100
19
20function dalvik_cache_name {
21 local input=$1
22 # Strip first /, replace rest with @.
23 DALVIK_CACHE_NAME=`echo $input | sed -e 's,^/,,' -e 's,/,@,g'`
24 # Append @classes.dex.
25 DALVIK_CACHE_NAME="${DALVIK_CACHE_NAME}@classes.dex"
26}
27
28log_info "Preparing system server compilation parameters"
29
30if [ "x$SYSTEMSERVERCLASSPATH" = "x" ] ; then
31 log_info "SYSTEMSERVERCLASSPATH is not set! Trying to retrieve from init.environ.rc."
32 SYSTEMSERVERCLASSPATH=`grep "export SYSTEMSERVERCLASSPATH" init.environ.rc | sed -e "s/.* //"`
33 if [ "x$SYSTEMSERVERCLASSPATH" = "x" ] ; then
34 log_error "Could not find SYSTEMSERVERCLASSPATH"
35 exit 101
36 fi
37fi
38SYSCP=`echo $SYSTEMSERVERCLASSPATH | tr ":" "\n"`
39
40BOOTCPPARAM=
41if [ ! -z "$DEX2OATBOOTCLASSPATH" ] ; then
42 BOOTCPPARAM="--runtime-arg -Xbootclasspath:$DEX2OATBOOTCLASSPATH"
43fi
44
45DEX2OAT_IMAGE_XMX=`getprop dalvik.vm.dex2oat-Xmx`
46
47DEX2OAT_TARGET_ARCH=$1
48DEX2OAT_TARGET_CPU_VARIANT=`getprop dalvik.vm.isa.${DEX2OAT_TARGET_ARCH}.variant`
49DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES=`getprop dalvik.vm.isa.${DEX2OAT_TARGET_ARCH}.features`
50
51# Do this like preopt: speed compile, no classpath, possibly pick up profiles.
52
53# TODO: App image? Would have to scan /system for an existing image.
54
55for COMPONENT in $SYSCP ; do
56 log_info "Compiling $COMPONENT"
57 dalvik_cache_name $COMPONENT
58 PROFILING=
59 if [ -f "${COMPONENT}.prof" ] ; then
60 PROFILING="--profile-file=${COMPONENT}.prof"
61 fi
62 dex2oat \
63 --avoid-storing-invocation \
64 --runtime-arg -Xmx$DEX2OAT_IMAGE_XMX \
65 $BOOTCPPARAM \
66 --class-loader-context=\& \
67 --boot-image=/data/dalvik-cache/system@framework@boot.art \
68 --dex-file=$COMPONENT \
69 --dex-location=$COMPONENT \
70 --oat-file=/data/dalvik-cache/$DEX2OAT_TARGET_ARCH/$DALVIK_CACHE_NAME \
71 --android-root=/system \
72 --instruction-set=$DEX2OAT_TARGET_ARCH \
73 --instruction-set-variant=$DEX2OAT_TARGET_CPU_VARIANT \
74 --instruction-set-features=$DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES \
75 --no-generate-debug-info \
76 --abort-on-hard-verifier-error \
77 --force-determinism \
78 --no-inline-from=core-oj.jar \
79 --copy-dex-files=false \
80 --compiler-filter=speed \
81 --generate-mini-debug-info \
82 $PROFILING \
83 || { log_error "Dex2oat failed" ; exit 102 ; }
84done