1*795d594fSAndroid Build Coastguard Worker#! /bin/bash 2*795d594fSAndroid Build Coastguard Worker# 3*795d594fSAndroid Build Coastguard Worker# Copyright (C) 2015 The Android Open Source Project 4*795d594fSAndroid Build Coastguard Worker# 5*795d594fSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 6*795d594fSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 7*795d594fSAndroid Build Coastguard Worker# You may obtain a copy of the License at 8*795d594fSAndroid Build Coastguard Worker# 9*795d594fSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 10*795d594fSAndroid Build Coastguard Worker# 11*795d594fSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 12*795d594fSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 13*795d594fSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*795d594fSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 15*795d594fSAndroid Build Coastguard Worker# limitations under the License. 16*795d594fSAndroid Build Coastguard Worker 17*795d594fSAndroid Build Coastguard Workerset -e 18*795d594fSAndroid Build Coastguard Worker 19*795d594fSAndroid Build Coastguard Worker. "$(dirname $0)/buildbot-utils.sh" 20*795d594fSAndroid Build Coastguard Worker 21*795d594fSAndroid Build Coastguard Workershopt -s failglob 22*795d594fSAndroid Build Coastguard Worker 23*795d594fSAndroid Build Coastguard Workerif [ ! -d art ]; then 24*795d594fSAndroid Build Coastguard Worker msgerror "Script needs to be run at the root of the Android tree" 25*795d594fSAndroid Build Coastguard Worker exit 1 26*795d594fSAndroid Build Coastguard Workerfi 27*795d594fSAndroid Build Coastguard Worker 28*795d594fSAndroid Build Coastguard Worker# Logic for setting out_dir from build/make/core/envsetup.mk: 29*795d594fSAndroid Build Coastguard Workerif [[ -z $OUT_DIR ]]; then 30*795d594fSAndroid Build Coastguard Worker if [[ -z $OUT_DIR_COMMON_BASE ]]; then 31*795d594fSAndroid Build Coastguard Worker out_dir=out 32*795d594fSAndroid Build Coastguard Worker else 33*795d594fSAndroid Build Coastguard Worker out_dir=${OUT_DIR_COMMON_BASE}/${PWD##*/} 34*795d594fSAndroid Build Coastguard Worker fi 35*795d594fSAndroid Build Coastguard Workerelse 36*795d594fSAndroid Build Coastguard Worker out_dir=${OUT_DIR} 37*795d594fSAndroid Build Coastguard Workerfi 38*795d594fSAndroid Build Coastguard Worker 39*795d594fSAndroid Build Coastguard Worker# On master-art, we need to copy ART-local riscv64 prebuilts for conscrypt and 40*795d594fSAndroid Build Coastguard Worker# statsd into their own repositories, as mainline doesn't support riscv64 yet. 41*795d594fSAndroid Build Coastguard Worker# Android.bp file changes are stored as patch files which need to be applied 42*795d594fSAndroid Build Coastguard Worker# afterwards. 43*795d594fSAndroid Build Coastguard Worker# 44*795d594fSAndroid Build Coastguard Worker# TODO(b/286551985): Remove this after riscv64 support is added to mainline. 45*795d594fSAndroid Build Coastguard Workerif [[ $TARGET_ARCH = "riscv64" && ! ( -d frameworks/base ) ]]; then 46*795d594fSAndroid Build Coastguard Worker msginfo "Copying prebuilt dependencies for riscv64" 47*795d594fSAndroid Build Coastguard Worker cp -u -r prebuilts/runtime/mainline/local_riscv64/prebuilts/module_sdk/conscrypt \ 48*795d594fSAndroid Build Coastguard Worker prebuilts/module_sdk 49*795d594fSAndroid Build Coastguard Worker cp -u -r prebuilts/runtime/mainline/local_riscv64/prebuilts/module_sdk/StatsD \ 50*795d594fSAndroid Build Coastguard Worker prebuilts/module_sdk 51*795d594fSAndroid Build Coastguard Worker for patch_file in $(find prebuilts/module_sdk -name Android.bp.patch) ; do 52*795d594fSAndroid Build Coastguard Worker bp_file=${patch_file%.patch} 53*795d594fSAndroid Build Coastguard Worker # Only apply the patches if they haven't been applied already. Assume the 54*795d594fSAndroid Build Coastguard Worker # patch files contain the bug number, and look for that. 55*795d594fSAndroid Build Coastguard Worker if grep -q b/286551985 $bp_file ; then 56*795d594fSAndroid Build Coastguard Worker msginfo "Patch for riscv64 already present in $bp_file" 57*795d594fSAndroid Build Coastguard Worker else 58*795d594fSAndroid Build Coastguard Worker patch -f $bp_file < $patch_file 59*795d594fSAndroid Build Coastguard Worker fi 60*795d594fSAndroid Build Coastguard Worker done 61*795d594fSAndroid Build Coastguard Workerfi 62*795d594fSAndroid Build Coastguard Worker 63*795d594fSAndroid Build Coastguard Workerjava_libraries_dir=${out_dir}/target/common/obj/JAVA_LIBRARIES 64*795d594fSAndroid Build Coastguard Workercommon_targets="vogar core-tests core-ojtests apache-harmony-jdwp-tests-hostdex jsr166-tests mockito-target" 65*795d594fSAndroid Build Coastguard Worker# These build targets have different names on device and host. 66*795d594fSAndroid Build Coastguard Workerspecific_targets="libjavacoretests libwrapagentproperties libwrapagentpropertiesd" 67*795d594fSAndroid Build Coastguard Workerbuild_host="no" 68*795d594fSAndroid Build Coastguard Workerbuild_target="no" 69*795d594fSAndroid Build Coastguard Workerinstallclean="no" 70*795d594fSAndroid Build Coastguard Workerskip_run_tests_build="no" 71*795d594fSAndroid Build Coastguard Workerj_arg="-j$(nproc)" 72*795d594fSAndroid Build Coastguard Workershowcommands= 73*795d594fSAndroid Build Coastguard Workermake_command= 74*795d594fSAndroid Build Coastguard Worker 75*795d594fSAndroid Build Coastguard Workerwhile true; do 76*795d594fSAndroid Build Coastguard Worker if [[ "$1" == "--host" ]]; then 77*795d594fSAndroid Build Coastguard Worker build_host="yes" 78*795d594fSAndroid Build Coastguard Worker shift 79*795d594fSAndroid Build Coastguard Worker elif [[ "$1" == "--target" ]]; then 80*795d594fSAndroid Build Coastguard Worker build_target="yes" 81*795d594fSAndroid Build Coastguard Worker shift 82*795d594fSAndroid Build Coastguard Worker elif [[ "$1" == "--installclean" ]]; then 83*795d594fSAndroid Build Coastguard Worker installclean="yes" 84*795d594fSAndroid Build Coastguard Worker shift 85*795d594fSAndroid Build Coastguard Worker elif [[ "$1" == "--skip-run-tests-build" ]]; then 86*795d594fSAndroid Build Coastguard Worker skip_run_tests_build="yes" 87*795d594fSAndroid Build Coastguard Worker shift 88*795d594fSAndroid Build Coastguard Worker elif [[ "$1" == -j* ]]; then 89*795d594fSAndroid Build Coastguard Worker j_arg=$1 90*795d594fSAndroid Build Coastguard Worker shift 91*795d594fSAndroid Build Coastguard Worker elif [[ "$1" == "--showcommands" ]]; then 92*795d594fSAndroid Build Coastguard Worker showcommands="showcommands" 93*795d594fSAndroid Build Coastguard Worker shift 94*795d594fSAndroid Build Coastguard Worker elif [[ "$1" == "--dist" ]]; then 95*795d594fSAndroid Build Coastguard Worker common_targets="$common_targets dist" 96*795d594fSAndroid Build Coastguard Worker shift 97*795d594fSAndroid Build Coastguard Worker elif [[ "$1" == "" ]]; then 98*795d594fSAndroid Build Coastguard Worker break 99*795d594fSAndroid Build Coastguard Worker else 100*795d594fSAndroid Build Coastguard Worker msgerror "Unknown options: $@" 101*795d594fSAndroid Build Coastguard Worker exit 1 102*795d594fSAndroid Build Coastguard Worker fi 103*795d594fSAndroid Build Coastguard Workerdone 104*795d594fSAndroid Build Coastguard Worker 105*795d594fSAndroid Build Coastguard Worker# If neither was selected, build both by default. 106*795d594fSAndroid Build Coastguard Workerif [[ $build_host == "no" ]] && [[ $build_target == "no" ]]; then 107*795d594fSAndroid Build Coastguard Worker build_host="yes" 108*795d594fSAndroid Build Coastguard Worker build_target="yes" 109*795d594fSAndroid Build Coastguard Workerfi 110*795d594fSAndroid Build Coastguard Worker 111*795d594fSAndroid Build Coastguard Workerif [ -d frameworks/base ]; then 112*795d594fSAndroid Build Coastguard Worker # In full manifest branches, build the implementation libraries from source 113*795d594fSAndroid Build Coastguard Worker # instead of using prebuilts. 114*795d594fSAndroid Build Coastguard Worker common_targets="$common_targets" 115*795d594fSAndroid Build Coastguard Workerelse 116*795d594fSAndroid Build Coastguard Worker # Necessary to build successfully in master-art. 117*795d594fSAndroid Build Coastguard Worker extra_args="SOONG_ALLOW_MISSING_DEPENDENCIES=true" 118*795d594fSAndroid Build Coastguard Worker # Switch the build system to unbundled mode in the reduced manifest branch. 119*795d594fSAndroid Build Coastguard Worker extra_args="$extra_args TARGET_BUILD_UNBUNDLED=true" 120*795d594fSAndroid Build Coastguard Workerfi 121*795d594fSAndroid Build Coastguard Worker 122*795d594fSAndroid Build Coastguard Workerapexes=( 123*795d594fSAndroid Build Coastguard Worker "com.android.art.testing" 124*795d594fSAndroid Build Coastguard Worker "com.android.conscrypt" 125*795d594fSAndroid Build Coastguard Worker "com.android.i18n" 126*795d594fSAndroid Build Coastguard Worker "com.android.runtime" 127*795d594fSAndroid Build Coastguard Worker "com.android.tzdata" 128*795d594fSAndroid Build Coastguard Worker "art_fake_com.android.os.statsd" 129*795d594fSAndroid Build Coastguard Worker) 130*795d594fSAndroid Build Coastguard Worker 131*795d594fSAndroid Build Coastguard Workeroverride_apex_name() { 132*795d594fSAndroid Build Coastguard Worker if [[ $1 == "com.android.art.testing" ]]; then 133*795d594fSAndroid Build Coastguard Worker echo "com.android.art" 134*795d594fSAndroid Build Coastguard Worker elif [[ $1 == "art_fake_com.android.os.statsd" ]]; then 135*795d594fSAndroid Build Coastguard Worker echo "com.android.os.statsd" 136*795d594fSAndroid Build Coastguard Worker else 137*795d594fSAndroid Build Coastguard Worker echo $1 138*795d594fSAndroid Build Coastguard Worker fi 139*795d594fSAndroid Build Coastguard Worker} 140*795d594fSAndroid Build Coastguard Worker 141*795d594fSAndroid Build Coastguard Workermake_command="build/soong/soong_ui.bash --make-mode $j_arg $extra_args $showcommands $common_targets" 142*795d594fSAndroid Build Coastguard Workerif [[ $build_host == "yes" ]]; then 143*795d594fSAndroid Build Coastguard Worker make_command+=" build-art-host-gtests" 144*795d594fSAndroid Build Coastguard Worker test $skip_run_tests_build == "yes" || make_command+=" build-art-host-run-tests" 145*795d594fSAndroid Build Coastguard Worker make_command+=" dx-tests junit-host libjdwp-host" 146*795d594fSAndroid Build Coastguard Worker for LIB in ${specific_targets} ; do 147*795d594fSAndroid Build Coastguard Worker make_command+=" $LIB-host" 148*795d594fSAndroid Build Coastguard Worker done 149*795d594fSAndroid Build Coastguard Workerfi 150*795d594fSAndroid Build Coastguard Workerif [[ $build_target == "yes" ]]; then 151*795d594fSAndroid Build Coastguard Worker if [[ -z "${ANDROID_PRODUCT_OUT}" ]]; then 152*795d594fSAndroid Build Coastguard Worker msgerror 'ANDROID_PRODUCT_OUT environment variable is empty; did you forget to run `lunch`?' 153*795d594fSAndroid Build Coastguard Worker exit 1 154*795d594fSAndroid Build Coastguard Worker fi 155*795d594fSAndroid Build Coastguard Worker make_command+=" build-art-target-gtests" 156*795d594fSAndroid Build Coastguard Worker test $skip_run_tests_build == "yes" || make_command+=" build-art-target-run-tests" 157*795d594fSAndroid Build Coastguard Worker make_command+=" debuggerd sh su toybox" 158*795d594fSAndroid Build Coastguard Worker make_command+=" libartpalette_fake art_fake_heapprofd_client_api" 159*795d594fSAndroid Build Coastguard Worker # Runtime dependencies in the platform. 160*795d594fSAndroid Build Coastguard Worker # These are built to go into system/lib(64) to be dlopen'ed. 161*795d594fSAndroid Build Coastguard Worker # "libnetd_client.so" is used by bionic to perform network operations, which 162*795d594fSAndroid Build Coastguard Worker # is needed in Libcore tests. 163*795d594fSAndroid Build Coastguard Worker make_command+=" libnetd_client-target" 164*795d594fSAndroid Build Coastguard Worker # Stubs for other APEX SDKs, for use by vogar. Referenced from DEVICE_JARS in 165*795d594fSAndroid Build Coastguard Worker # external/vogar/src/vogar/ModeId.java. 166*795d594fSAndroid Build Coastguard Worker # Note these go into out/target/common/obj/JAVA_LIBRARIES which isn't removed 167*795d594fSAndroid Build Coastguard Worker # by "m installclean". 168*795d594fSAndroid Build Coastguard Worker make_command+=" i18n.module.public.api.stubs conscrypt.module.public.api.stubs" 169*795d594fSAndroid Build Coastguard Worker # Targets required to generate a linker configuration for device within the 170*795d594fSAndroid Build Coastguard Worker # chroot environment. The *.libraries.txt targets are required by 171*795d594fSAndroid Build Coastguard Worker # the source linkerconfig but not included in the prebuilt one. 172*795d594fSAndroid Build Coastguard Worker make_command+=" linkerconfig conv_linker_config sanitizer.libraries.txt llndk.libraries.txt" 173*795d594fSAndroid Build Coastguard Worker # Additional targets needed for the chroot environment. 174*795d594fSAndroid Build Coastguard Worker make_command+=" event-log-tags" 175*795d594fSAndroid Build Coastguard Worker # Needed to extract prebuilt APEXes. 176*795d594fSAndroid Build Coastguard Worker make_command+=" deapexer" 177*795d594fSAndroid Build Coastguard Worker # Needed to generate the primary boot image for testing. 178*795d594fSAndroid Build Coastguard Worker make_command+=" generate-boot-image" 179*795d594fSAndroid Build Coastguard Worker # Build/install the required APEXes. 180*795d594fSAndroid Build Coastguard Worker make_command+=" ${apexes[*]}" 181*795d594fSAndroid Build Coastguard Worker make_command+=" ${specific_targets}" 182*795d594fSAndroid Build Coastguard Workerfi 183*795d594fSAndroid Build Coastguard Worker 184*795d594fSAndroid Build Coastguard Workerif [[ $installclean == "yes" ]]; then 185*795d594fSAndroid Build Coastguard Worker msginfo "Perform installclean" 186*795d594fSAndroid Build Coastguard Worker ANDROID_QUIET_BUILD=true build/soong/soong_ui.bash --make-mode $extra_args installclean 187*795d594fSAndroid Build Coastguard Worker # The common java library directory is not cleaned up by installclean. Do that 188*795d594fSAndroid Build Coastguard Worker # explicitly to not overcache them in incremental builds. 189*795d594fSAndroid Build Coastguard Worker rm -rf $java_libraries_dir 190*795d594fSAndroid Build Coastguard Workerelse 191*795d594fSAndroid Build Coastguard Worker msgwarning "Missing --installclean argument to buildbot-build.sh" 192*795d594fSAndroid Build Coastguard Worker msgwarning "This is usually ok, but may cause rare odd failures." 193*795d594fSAndroid Build Coastguard Worker echo "" 194*795d594fSAndroid Build Coastguard Workerfi 195*795d594fSAndroid Build Coastguard Worker 196*795d594fSAndroid Build Coastguard Workermsginfo "Executing" "$make_command" 197*795d594fSAndroid Build Coastguard Worker# Disable path restrictions to enable luci builds using vpython. 198*795d594fSAndroid Build Coastguard Workereval "$make_command" 199*795d594fSAndroid Build Coastguard Worker 200*795d594fSAndroid Build Coastguard Workerif [[ $build_target == "yes" ]]; then 201*795d594fSAndroid Build Coastguard Worker if [[ -z "${ANDROID_HOST_OUT}" ]]; then 202*795d594fSAndroid Build Coastguard Worker msgwarning "ANDROID_HOST_OUT environment variable is empty; using $out_dir/host/linux-x86" 203*795d594fSAndroid Build Coastguard Worker ANDROID_HOST_OUT=$out_dir/host/linux-x86 204*795d594fSAndroid Build Coastguard Worker fi 205*795d594fSAndroid Build Coastguard Worker 206*795d594fSAndroid Build Coastguard Worker # Use fake implementations to prevent chroot tests from talking to the platform (e.g., through 207*795d594fSAndroid Build Coastguard Worker # libartpalette). 208*795d594fSAndroid Build Coastguard Worker for l in lib lib64; do 209*795d594fSAndroid Build Coastguard Worker if [ ! -d "$ANDROID_PRODUCT_OUT/system/$l/art_fake" ]; then 210*795d594fSAndroid Build Coastguard Worker continue 211*795d594fSAndroid Build Coastguard Worker fi 212*795d594fSAndroid Build Coastguard Worker for lib in libartpalette-system heapprofd_client_api; do 213*795d594fSAndroid Build Coastguard Worker cmd="cp -p \"$ANDROID_PRODUCT_OUT/system/$l/art_fake/$lib.so\" \"$ANDROID_PRODUCT_OUT/system/$l/$lib.so\"" 214*795d594fSAndroid Build Coastguard Worker msginfo "Executing" "$cmd" 215*795d594fSAndroid Build Coastguard Worker eval "$cmd" 216*795d594fSAndroid Build Coastguard Worker done 217*795d594fSAndroid Build Coastguard Worker done 218*795d594fSAndroid Build Coastguard Worker 219*795d594fSAndroid Build Coastguard Worker # Extract prebuilt APEXes. 220*795d594fSAndroid Build Coastguard Worker debugfs=$ANDROID_HOST_OUT/bin/debugfs_static 221*795d594fSAndroid Build Coastguard Worker fsckerofs=$ANDROID_HOST_OUT/bin/fsck.erofs 222*795d594fSAndroid Build Coastguard Worker for apex in ${apexes[@]}; do 223*795d594fSAndroid Build Coastguard Worker dir="$ANDROID_PRODUCT_OUT/system/apex/${apex}" 224*795d594fSAndroid Build Coastguard Worker apexbase="$ANDROID_PRODUCT_OUT/system/apex/${apex}" 225*795d594fSAndroid Build Coastguard Worker unset file 226*795d594fSAndroid Build Coastguard Worker if [ -f "${apexbase}.apex" ]; then 227*795d594fSAndroid Build Coastguard Worker file="${apexbase}.apex" 228*795d594fSAndroid Build Coastguard Worker elif [ -f "${apexbase}.capex" ]; then 229*795d594fSAndroid Build Coastguard Worker file="${apexbase}.capex" 230*795d594fSAndroid Build Coastguard Worker fi 231*795d594fSAndroid Build Coastguard Worker if [ -n "${file}" ]; then 232*795d594fSAndroid Build Coastguard Worker msginfo "Extracting APEX file:" "${file}" 233*795d594fSAndroid Build Coastguard Worker rm -rf $dir 234*795d594fSAndroid Build Coastguard Worker mkdir -p $dir 235*795d594fSAndroid Build Coastguard Worker $ANDROID_HOST_OUT/bin/deapexer --debugfs_path $debugfs --fsckerofs_path $fsckerofs \ 236*795d594fSAndroid Build Coastguard Worker extract $file $dir 237*795d594fSAndroid Build Coastguard Worker fi 238*795d594fSAndroid Build Coastguard Worker done 239*795d594fSAndroid Build Coastguard Worker 240*795d594fSAndroid Build Coastguard Worker # Create canonical name -> file name symlink in the symbol directory for the 241*795d594fSAndroid Build Coastguard Worker # Testing ART APEX. 242*795d594fSAndroid Build Coastguard Worker # 243*795d594fSAndroid Build Coastguard Worker # This mimics the logic from `art/Android.mk`. We made the choice not to 244*795d594fSAndroid Build Coastguard Worker # implement this in `art/Android.mk`, as the Testing ART APEX is a test artifact 245*795d594fSAndroid Build Coastguard Worker # that should never ship with an actual product, and we try to keep it out of 246*795d594fSAndroid Build Coastguard Worker # standard build recipes 247*795d594fSAndroid Build Coastguard Worker # 248*795d594fSAndroid Build Coastguard Worker # TODO(b/141004137, b/129534335): Remove this, expose the Testing ART APEX in 249*795d594fSAndroid Build Coastguard Worker # the `art/Android.mk` build logic, and add absence checks (e.g. in 250*795d594fSAndroid Build Coastguard Worker # `build/make/core/main.mk`) to prevent the Testing ART APEX from ending up in a 251*795d594fSAndroid Build Coastguard Worker # system image. 252*795d594fSAndroid Build Coastguard Worker target_out_unstripped="$ANDROID_PRODUCT_OUT/symbols" 253*795d594fSAndroid Build Coastguard Worker link_name="$target_out_unstripped/apex/com.android.art" 254*795d594fSAndroid Build Coastguard Worker link_command="mkdir -p $(dirname "$link_name") && ln -sf com.android.art.testing \"$link_name\"" 255*795d594fSAndroid Build Coastguard Worker msginfo "Executing" "$link_command" 256*795d594fSAndroid Build Coastguard Worker eval "$link_command" 257*795d594fSAndroid Build Coastguard Worker 258*795d594fSAndroid Build Coastguard Worker # Temporary fix for libjavacrypto.so dependencies in libcore and jvmti tests (b/147124225). 259*795d594fSAndroid Build Coastguard Worker conscrypt_dir="$ANDROID_PRODUCT_OUT/system/apex/com.android.conscrypt" 260*795d594fSAndroid Build Coastguard Worker conscrypt_libs="libjavacrypto.so libcrypto.so libssl.so" 261*795d594fSAndroid Build Coastguard Worker if [ ! -d "${conscrypt_dir}" ]; then 262*795d594fSAndroid Build Coastguard Worker msgerror "Missing conscrypt APEX in build output: ${conscrypt_dir}" 263*795d594fSAndroid Build Coastguard Worker exit 1 264*795d594fSAndroid Build Coastguard Worker fi 265*795d594fSAndroid Build Coastguard Worker if [ ! -f "${conscrypt_dir}/javalib/conscrypt.jar" ]; then 266*795d594fSAndroid Build Coastguard Worker msgerror "Missing conscrypt jar in build output: ${conscrypt_dir}" 267*795d594fSAndroid Build Coastguard Worker exit 1 268*795d594fSAndroid Build Coastguard Worker fi 269*795d594fSAndroid Build Coastguard Worker for l in lib lib64; do 270*795d594fSAndroid Build Coastguard Worker if [ ! -d "$ANDROID_PRODUCT_OUT/system/$l" ]; then 271*795d594fSAndroid Build Coastguard Worker continue 272*795d594fSAndroid Build Coastguard Worker fi 273*795d594fSAndroid Build Coastguard Worker for so in $conscrypt_libs; do 274*795d594fSAndroid Build Coastguard Worker src="${conscrypt_dir}/${l}/${so}" 275*795d594fSAndroid Build Coastguard Worker dst="$ANDROID_PRODUCT_OUT/system/${l}/${so}" 276*795d594fSAndroid Build Coastguard Worker if [ "${src}" -nt "${dst}" ]; then 277*795d594fSAndroid Build Coastguard Worker cmd="cp -p \"${src}\" \"${dst}\"" 278*795d594fSAndroid Build Coastguard Worker msginfo "Executing" "$cmd" 279*795d594fSAndroid Build Coastguard Worker eval "$cmd" 280*795d594fSAndroid Build Coastguard Worker fi 281*795d594fSAndroid Build Coastguard Worker done 282*795d594fSAndroid Build Coastguard Worker done 283*795d594fSAndroid Build Coastguard Worker 284*795d594fSAndroid Build Coastguard Worker # TODO(b/159355595): Ensure there is a tzdata in system to avoid warnings on 285*795d594fSAndroid Build Coastguard Worker # stderr from Bionic. 286*795d594fSAndroid Build Coastguard Worker if [ ! -f $ANDROID_PRODUCT_OUT/system/usr/share/zoneinfo/tzdata ]; then 287*795d594fSAndroid Build Coastguard Worker mkdir -p $ANDROID_PRODUCT_OUT/system/usr/share/zoneinfo 288*795d594fSAndroid Build Coastguard Worker cp $ANDROID_PRODUCT_OUT/system/apex/com.android.tzdata/etc/tz/tzdata \ 289*795d594fSAndroid Build Coastguard Worker $ANDROID_PRODUCT_OUT/system/usr/share/zoneinfo/tzdata 290*795d594fSAndroid Build Coastguard Worker fi 291*795d594fSAndroid Build Coastguard Worker 292*795d594fSAndroid Build Coastguard Worker # Create system symlinks for the Runtime APEX. Normally handled by 293*795d594fSAndroid Build Coastguard Worker # installSymlinkToRuntimeApex in soong/cc/binary.go, but we have to replicate 294*795d594fSAndroid Build Coastguard Worker # it here since we don't run the install rules for the Runtime APEX. 295*795d594fSAndroid Build Coastguard Worker for b in linker{,_asan}{,64}; do 296*795d594fSAndroid Build Coastguard Worker msginfo "Symlinking" "/apex/com.android.runtime/bin/$b to /system/bin" 297*795d594fSAndroid Build Coastguard Worker ln -sf /apex/com.android.runtime/bin/$b $ANDROID_PRODUCT_OUT/system/bin/$b 298*795d594fSAndroid Build Coastguard Worker done 299*795d594fSAndroid Build Coastguard Worker for d in $ANDROID_PRODUCT_OUT/system/apex/com.android.runtime/lib{,64}/bionic; do 300*795d594fSAndroid Build Coastguard Worker if [ -d $d ]; then 301*795d594fSAndroid Build Coastguard Worker for p in $d/*; do 302*795d594fSAndroid Build Coastguard Worker lib_dir=$(expr $p : '.*/\(lib[0-9]*\)/.*') 303*795d594fSAndroid Build Coastguard Worker lib_file=$(basename $p) 304*795d594fSAndroid Build Coastguard Worker src=/apex/com.android.runtime/${lib_dir}/bionic/${lib_file} 305*795d594fSAndroid Build Coastguard Worker dst=$ANDROID_PRODUCT_OUT/system/${lib_dir}/${lib_file} 306*795d594fSAndroid Build Coastguard Worker msginfo "Symlinking" "$src into /system/${lib_dir}" 307*795d594fSAndroid Build Coastguard Worker mkdir -p $(dirname $dst) 308*795d594fSAndroid Build Coastguard Worker ln -sf $src $dst 309*795d594fSAndroid Build Coastguard Worker done 310*795d594fSAndroid Build Coastguard Worker fi 311*795d594fSAndroid Build Coastguard Worker done 312*795d594fSAndroid Build Coastguard Worker 313*795d594fSAndroid Build Coastguard Worker # Create linker config files. We run linkerconfig on host to avoid problems 314*795d594fSAndroid Build Coastguard Worker # building it statically for device in an unbundled tree. 315*795d594fSAndroid Build Coastguard Worker 316*795d594fSAndroid Build Coastguard Worker # temporary root for linkerconfig 317*795d594fSAndroid Build Coastguard Worker linkerconfig_root=$ANDROID_PRODUCT_OUT/art_linkerconfig_root 318*795d594fSAndroid Build Coastguard Worker 319*795d594fSAndroid Build Coastguard Worker rm -rf $linkerconfig_root 320*795d594fSAndroid Build Coastguard Worker 321*795d594fSAndroid Build Coastguard Worker # Linkerconfig reads files from /system/etc 322*795d594fSAndroid Build Coastguard Worker mkdir -p $linkerconfig_root/system 323*795d594fSAndroid Build Coastguard Worker cp -r $ANDROID_PRODUCT_OUT/system/etc $linkerconfig_root/system 324*795d594fSAndroid Build Coastguard Worker 325*795d594fSAndroid Build Coastguard Worker # Use our smaller public.libraries.txt that contains only the public libraries 326*795d594fSAndroid Build Coastguard Worker # pushed to the chroot directory. 327*795d594fSAndroid Build Coastguard Worker cp $ANDROID_BUILD_TOP/art/tools/public.libraries.buildbot.txt \ 328*795d594fSAndroid Build Coastguard Worker $linkerconfig_root/system/etc/public.libraries.txt 329*795d594fSAndroid Build Coastguard Worker 330*795d594fSAndroid Build Coastguard Worker # For linkerconfig to pick up the APEXes correctly we need to make them 331*795d594fSAndroid Build Coastguard Worker # available in $linkerconfig_root/apex. 332*795d594fSAndroid Build Coastguard Worker mkdir -p $linkerconfig_root/apex 333*795d594fSAndroid Build Coastguard Worker for apex in ${apexes[@]}; do 334*795d594fSAndroid Build Coastguard Worker src="$ANDROID_PRODUCT_OUT/system/apex/${apex}" 335*795d594fSAndroid Build Coastguard Worker dst="$linkerconfig_root/apex/$(override_apex_name $apex)" 336*795d594fSAndroid Build Coastguard Worker msginfo "Copying APEX directory" "from $src to $dst" 337*795d594fSAndroid Build Coastguard Worker rm -rf $dst 338*795d594fSAndroid Build Coastguard Worker cp -r $src $dst 339*795d594fSAndroid Build Coastguard Worker done 340*795d594fSAndroid Build Coastguard Worker 341*795d594fSAndroid Build Coastguard Worker # Linkerconfig also looks at /apex/apex-info-list.xml to check for system APEXes. 342*795d594fSAndroid Build Coastguard Worker apex_xml_file=$linkerconfig_root/apex/apex-info-list.xml 343*795d594fSAndroid Build Coastguard Worker msginfo "Creating" "$apex_xml_file" 344*795d594fSAndroid Build Coastguard Worker cat <<EOF > $apex_xml_file 345*795d594fSAndroid Build Coastguard Worker<?xml version="1.0" encoding="utf-8"?> 346*795d594fSAndroid Build Coastguard Worker<apex-info-list> 347*795d594fSAndroid Build Coastguard WorkerEOF 348*795d594fSAndroid Build Coastguard Worker for apex in ${apexes[@]}; do 349*795d594fSAndroid Build Coastguard Worker apex=$(override_apex_name $apex) 350*795d594fSAndroid Build Coastguard Worker cat <<EOF >> $apex_xml_file 351*795d594fSAndroid Build Coastguard Worker <apex-info moduleName="${apex}" modulePath="/system/apex/${apex}.apex" preinstalledModulePath="/system/apex/${apex}.apex" versionCode="1" versionName="" isFactory="true" isActive="true"> 352*795d594fSAndroid Build Coastguard Worker </apex-info> 353*795d594fSAndroid Build Coastguard WorkerEOF 354*795d594fSAndroid Build Coastguard Worker done 355*795d594fSAndroid Build Coastguard Worker cat <<EOF >> $apex_xml_file 356*795d594fSAndroid Build Coastguard Worker</apex-info-list> 357*795d594fSAndroid Build Coastguard WorkerEOF 358*795d594fSAndroid Build Coastguard Worker 359*795d594fSAndroid Build Coastguard Worker system_linker_config_pb=$linkerconfig_root/system/etc/linker.config.pb 360*795d594fSAndroid Build Coastguard Worker # This list needs to be synced with provideLibs in system/etc/linker.config.pb 361*795d594fSAndroid Build Coastguard Worker # in the targeted platform image. 362*795d594fSAndroid Build Coastguard Worker # TODO(b/186649223): Create a prebuilt for it in platform-mainline-sdk. 363*795d594fSAndroid Build Coastguard Worker system_provide_libs=( 364*795d594fSAndroid Build Coastguard Worker heapprofd_client_api.so 365*795d594fSAndroid Build Coastguard Worker libEGL.so 366*795d594fSAndroid Build Coastguard Worker libGLESv1_CM.so 367*795d594fSAndroid Build Coastguard Worker libGLESv2.so 368*795d594fSAndroid Build Coastguard Worker libGLESv3.so 369*795d594fSAndroid Build Coastguard Worker libOpenMAXAL.so 370*795d594fSAndroid Build Coastguard Worker libOpenSLES.so 371*795d594fSAndroid Build Coastguard Worker libRS.so 372*795d594fSAndroid Build Coastguard Worker libaaudio.so 373*795d594fSAndroid Build Coastguard Worker libadbd_auth.so 374*795d594fSAndroid Build Coastguard Worker libadbd_fs.so 375*795d594fSAndroid Build Coastguard Worker libamidi.so 376*795d594fSAndroid Build Coastguard Worker libandroid.so 377*795d594fSAndroid Build Coastguard Worker libandroid_net.so 378*795d594fSAndroid Build Coastguard Worker libartpalette-system.so 379*795d594fSAndroid Build Coastguard Worker libbinder_ndk.so 380*795d594fSAndroid Build Coastguard Worker libc.so 381*795d594fSAndroid Build Coastguard Worker libcamera2ndk.so 382*795d594fSAndroid Build Coastguard Worker libcgrouprc.so 383*795d594fSAndroid Build Coastguard Worker libclang_rt.asan-i686-android.so 384*795d594fSAndroid Build Coastguard Worker libclang_rt.asan-x86_64-android.so 385*795d594fSAndroid Build Coastguard Worker libdl.so 386*795d594fSAndroid Build Coastguard Worker libdl_android.so 387*795d594fSAndroid Build Coastguard Worker libft2.so 388*795d594fSAndroid Build Coastguard Worker libincident.so 389*795d594fSAndroid Build Coastguard Worker libjnigraphics.so 390*795d594fSAndroid Build Coastguard Worker liblog.so 391*795d594fSAndroid Build Coastguard Worker libm.so 392*795d594fSAndroid Build Coastguard Worker libmediametrics.so 393*795d594fSAndroid Build Coastguard Worker libmediandk.so 394*795d594fSAndroid Build Coastguard Worker libnativewindow.so 395*795d594fSAndroid Build Coastguard Worker libneuralnetworks_packageinfo.so 396*795d594fSAndroid Build Coastguard Worker libselinux.so 397*795d594fSAndroid Build Coastguard Worker libstdc++.so 398*795d594fSAndroid Build Coastguard Worker libsync.so 399*795d594fSAndroid Build Coastguard Worker libvndksupport.so 400*795d594fSAndroid Build Coastguard Worker libvulkan.so 401*795d594fSAndroid Build Coastguard Worker libz.so 402*795d594fSAndroid Build Coastguard Worker ) 403*795d594fSAndroid Build Coastguard Worker 404*795d594fSAndroid Build Coastguard Worker msginfo "Encoding linker.config.json" "to $system_linker_config_pb" 405*795d594fSAndroid Build Coastguard Worker $ANDROID_HOST_OUT/bin/conv_linker_config proto -s $ANDROID_BUILD_TOP/system/core/rootdir/etc/linker.config.json -o $system_linker_config_pb 406*795d594fSAndroid Build Coastguard Worker $ANDROID_HOST_OUT/bin/conv_linker_config append -s $system_linker_config_pb -o $system_linker_config_pb --key "provideLibs" --value "${system_provide_libs[*]}" 407*795d594fSAndroid Build Coastguard Worker 408*795d594fSAndroid Build Coastguard Worker # To avoid warnings from linkerconfig when it checks following two partitions 409*795d594fSAndroid Build Coastguard Worker mkdir -p $linkerconfig_root/product 410*795d594fSAndroid Build Coastguard Worker mkdir -p $linkerconfig_root/system_ext 411*795d594fSAndroid Build Coastguard Worker 412*795d594fSAndroid Build Coastguard Worker platform_version=$(build/soong/soong_ui.bash --dumpvar-mode PLATFORM_VERSION) 413*795d594fSAndroid Build Coastguard Worker linkerconfig_out=$ANDROID_PRODUCT_OUT/linkerconfig 414*795d594fSAndroid Build Coastguard Worker msginfo "Generating linkerconfig" "in $linkerconfig_out" 415*795d594fSAndroid Build Coastguard Worker rm -rf $linkerconfig_out 416*795d594fSAndroid Build Coastguard Worker mkdir -p $linkerconfig_out 417*795d594fSAndroid Build Coastguard Worker $ANDROID_HOST_OUT/bin/linkerconfig --target $linkerconfig_out --root $linkerconfig_root 418*795d594fSAndroid Build Coastguard Workerfi 419