Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1 | #! /bin/bash |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 2 | # |
| 3 | # Copyright (C) 2015 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 | |
Orion Hodson | 44ab2cd | 2019-10-08 10:17:05 +0100 | [diff] [blame] | 17 | set -e |
| 18 | |
Martin Stjernholm | fa37ba2 | 2020-09-01 18:54:06 +0100 | [diff] [blame] | 19 | shopt -s failglob |
| 20 | |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 21 | if [ ! -d art ]; then |
| 22 | echo "Script needs to be run at the root of the android tree" |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
Nicolas Geoffray | c631a24 | 2020-08-05 15:52:31 +0100 | [diff] [blame] | 26 | TARGET_ARCH=$(source build/envsetup.sh > /dev/null; get_build_var TARGET_ARCH) |
Colin Cross | e0ef0a8 | 2017-07-27 21:29:18 +0000 | [diff] [blame] | 27 | |
Fredrik Roubert | ad9c4a3 | 2016-11-11 19:28:18 -0800 | [diff] [blame] | 28 | # Logic for setting out_dir from build/make/core/envsetup.mk: |
| 29 | if [[ -z $OUT_DIR ]]; then |
| 30 | if [[ -z $OUT_DIR_COMMON_BASE ]]; then |
| 31 | out_dir=out |
| 32 | else |
| 33 | out_dir=${OUT_DIR_COMMON_BASE}/${PWD##*/} |
| 34 | fi |
| 35 | else |
| 36 | out_dir=${OUT_DIR} |
| 37 | fi |
| 38 | |
Nicolas Geoffray | 4b29f38 | 2015-10-07 09:28:52 +0100 | [diff] [blame] | 39 | java_libraries_dir=${out_dir}/target/common/obj/JAVA_LIBRARIES |
Alex Light | 761ee21 | 2020-02-19 20:47:43 +0000 | [diff] [blame] | 40 | common_targets="vogar core-tests apache-harmony-jdwp-tests-hostdex jsr166-tests libartpalette-system mockito-target" |
David Srbecky | fe1c7b4 | 2021-04-23 15:43:51 +0100 | [diff] [blame] | 41 | # These build targets have different names on device and host. |
Nicolas Geoffray | bbc4dc3 | 2021-06-03 18:06:05 +0100 | [diff] [blame] | 42 | specific_targets="libjavacoretests libwrapagentproperties libwrapagentpropertiesd" |
David Srbecky | fe1c7b4 | 2021-04-23 15:43:51 +0100 | [diff] [blame] | 43 | build_host="no" |
| 44 | build_target="no" |
David Srbecky | af30bf7 | 2021-05-04 17:49:17 +0100 | [diff] [blame] | 45 | installclean="no" |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 46 | j_arg="-j$(nproc)" |
Roland Levillain | b8b9356 | 2015-08-20 17:49:56 +0100 | [diff] [blame] | 47 | showcommands= |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 48 | make_command= |
| 49 | |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 50 | while true; do |
| 51 | if [[ "$1" == "--host" ]]; then |
David Srbecky | fe1c7b4 | 2021-04-23 15:43:51 +0100 | [diff] [blame] | 52 | build_host="yes" |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 53 | shift |
| 54 | elif [[ "$1" == "--target" ]]; then |
David Srbecky | fe1c7b4 | 2021-04-23 15:43:51 +0100 | [diff] [blame] | 55 | build_target="yes" |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 56 | shift |
David Srbecky | af30bf7 | 2021-05-04 17:49:17 +0100 | [diff] [blame] | 57 | elif [[ "$1" == "--installclean" ]]; then |
| 58 | installclean="yes" |
David Srbecky | 6de68dd | 2021-04-27 14:47:27 +0100 | [diff] [blame] | 59 | shift |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 60 | elif [[ "$1" == -j* ]]; then |
Nicolas Geoffray | 667b99e | 2015-05-29 12:17:06 +0100 | [diff] [blame] | 61 | j_arg=$1 |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 62 | shift |
Roland Levillain | b8b9356 | 2015-08-20 17:49:56 +0100 | [diff] [blame] | 63 | elif [[ "$1" == "--showcommands" ]]; then |
| 64 | showcommands="showcommands" |
| 65 | shift |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 66 | elif [[ "$1" == "" ]]; then |
| 67 | break |
Andreas Gampe | 0dcee91 | 2017-02-01 22:07:45 -0800 | [diff] [blame] | 68 | else |
| 69 | echo "Unknown options $@" |
| 70 | exit 1 |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 71 | fi |
| 72 | done |
| 73 | |
David Srbecky | fe1c7b4 | 2021-04-23 15:43:51 +0100 | [diff] [blame] | 74 | # If neither was selected, build both by default. |
| 75 | if [[ $build_host == "no" ]] && [[ $build_target == "no" ]]; then |
| 76 | build_host="yes" |
| 77 | build_target="yes" |
| 78 | fi |
| 79 | |
Andreas Gampe | 353d818 | 2017-10-12 10:17:34 -0700 | [diff] [blame] | 80 | # Allow to build successfully in master-art. |
Martin Stjernholm | fb2967e | 2020-06-12 15:12:26 +0100 | [diff] [blame] | 81 | extra_args="SOONG_ALLOW_MISSING_DEPENDENCIES=true" |
Andreas Gampe | 353d818 | 2017-10-12 10:17:34 -0700 | [diff] [blame] | 82 | |
Martin Stjernholm | 6906910 | 2020-06-16 13:26:40 +0100 | [diff] [blame] | 83 | # Switch the build system to unbundled mode in the reduced manifest branch. |
Martin Stjernholm | 6906910 | 2020-06-16 13:26:40 +0100 | [diff] [blame] | 84 | if [ ! -d frameworks/base ]; then |
| 85 | extra_args="$extra_args TARGET_BUILD_UNBUNDLED=true" |
| 86 | fi |
| 87 | |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 88 | apexes=( |
| 89 | "com.android.art.testing" |
| 90 | "com.android.conscrypt" |
| 91 | "com.android.i18n" |
| 92 | "com.android.runtime" |
| 93 | "com.android.tzdata" |
Eric Holk | 39d529f | 2021-02-17 12:48:53 -0800 | [diff] [blame] | 94 | "com.android.os.statsd" |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 95 | ) |
| 96 | |
David Srbecky | fe1c7b4 | 2021-04-23 15:43:51 +0100 | [diff] [blame] | 97 | make_command="build/soong/soong_ui.bash --make-mode $j_arg $extra_args $showcommands $common_targets" |
| 98 | if [[ $build_host == "yes" ]]; then |
| 99 | make_command+=" build-art-host-tests" |
Nicolas Geoffray | bbc4dc3 | 2021-06-03 18:06:05 +0100 | [diff] [blame] | 100 | make_command+=" dx-tests junit-host libjdwp-host" |
David Srbecky | fe1c7b4 | 2021-04-23 15:43:51 +0100 | [diff] [blame] | 101 | for LIB in ${specific_targets} ; do |
| 102 | make_command+=" $LIB-host" |
| 103 | done |
| 104 | fi |
| 105 | if [[ $build_target == "yes" ]]; then |
Evgeny Astigeevich | 069391e | 2018-09-05 22:40:57 +0100 | [diff] [blame] | 106 | if [[ -z "${ANDROID_PRODUCT_OUT}" ]]; then |
| 107 | echo 'ANDROID_PRODUCT_OUT environment variable is empty; did you forget to run `lunch`?' |
Roland Levillain | fe3e2bf | 2018-03-02 16:01:50 +0000 | [diff] [blame] | 108 | exit 1 |
| 109 | fi |
David Srbecky | fe1c7b4 | 2021-04-23 15:43:51 +0100 | [diff] [blame] | 110 | make_command+=" build-art-target-tests" |
Nicolas Geoffray | c631a24 | 2020-08-05 15:52:31 +0100 | [diff] [blame] | 111 | make_command+=" libnetd_client-target toybox sh libtombstoned_client" |
Colin Cross | 789eb40 | 2021-06-26 05:09:24 +0000 | [diff] [blame] | 112 | make_command+=" debuggerd su" |
Nicolas Geoffray | c69b3f8 | 2020-06-22 12:33:38 +0000 | [diff] [blame] | 113 | # vogar requires the class files for conscrypt and ICU. |
| 114 | make_command+=" conscrypt core-icu4j" |
Evgeny Astigeevich | 069391e | 2018-09-05 22:40:57 +0100 | [diff] [blame] | 115 | make_command+=" ${ANDROID_PRODUCT_OUT#"${ANDROID_BUILD_TOP}/"}/system/etc/public.libraries.txt" |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 116 | # Targets required to generate a linker configuration for device within the |
| 117 | # chroot environment. The *.libraries.txt targets are required by |
Martin Stjernholm | c3c7dff | 2020-08-05 22:40:01 +0100 | [diff] [blame] | 118 | # the source linkerconfig but not included in the prebuilt one. |
Victor Chang | d6363c1 | 2020-11-26 16:49:46 +0000 | [diff] [blame] | 119 | make_command+=" linkerconfig conv_linker_config sanitizer.libraries.txt vndkcorevariant.libraries.txt" |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 120 | # Additional targets needed for the chroot environment. |
Martin Stjernholm | 4bb9f67 | 2020-05-19 01:33:47 +0100 | [diff] [blame] | 121 | make_command+=" event-log-tags" |
| 122 | # Needed to extract prebuilt APEXes. |
| 123 | make_command+=" deapexer" |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 124 | # Build/install the required APEXes. |
| 125 | make_command+=" ${apexes[*]}" |
David Srbecky | fe1c7b4 | 2021-04-23 15:43:51 +0100 | [diff] [blame] | 126 | make_command+=" ${specific_targets}" |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 127 | fi |
| 128 | |
David Srbecky | 6de68dd | 2021-04-27 14:47:27 +0100 | [diff] [blame] | 129 | if [[ $installclean == "yes" ]]; then |
| 130 | echo "Perform installclean" |
| 131 | ANDROID_QUIET_BUILD=true build/soong/soong_ui.bash --make-mode $extra_args installclean |
David Srbecky | af30bf7 | 2021-05-04 17:49:17 +0100 | [diff] [blame] | 132 | else |
| 133 | echo "WARNING: Missing --installclean argument to buildbot-build.sh" |
| 134 | echo "WARNING: This is usually ok, but may cause rare odd failures." |
| 135 | echo "" |
David Srbecky | 6de68dd | 2021-04-27 14:47:27 +0100 | [diff] [blame] | 136 | fi |
Andreas Gampe | 6c3e1a0 | 2017-11-09 10:29:32 -0800 | [diff] [blame] | 137 | |
Nicolas Geoffray | aadc986 | 2015-09-29 14:56:31 +0100 | [diff] [blame] | 138 | echo "Executing $make_command" |
Nicolas Geoffray | a8e8cdf | 2018-10-16 09:44:58 +0100 | [diff] [blame] | 139 | # Disable path restrictions to enable luci builds using vpython. |
Roland Levillain | c3f2fe9 | 2020-02-12 19:40:20 +0000 | [diff] [blame] | 140 | eval "$make_command" |
Roland Levillain | 7997590 | 2019-09-16 18:00:29 +0100 | [diff] [blame] | 141 | |
David Srbecky | fe1c7b4 | 2021-04-23 15:43:51 +0100 | [diff] [blame] | 142 | if [[ $build_target == "yes" ]]; then |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 143 | if [[ -z "${ANDROID_HOST_OUT}" ]]; then |
| 144 | echo "ANDROID_HOST_OUT environment variable is empty; using $out_dir/host/linux-x86" |
| 145 | ANDROID_HOST_OUT=$out_dir/host/linux-x86 |
| 146 | fi |
| 147 | |
| 148 | # Extract prebuilt APEXes. |
| 149 | debugfs=$ANDROID_HOST_OUT/bin/debugfs_static |
| 150 | for apex in ${apexes[@]}; do |
| 151 | dir="$ANDROID_PRODUCT_OUT/system/apex/${apex}" |
Martin Stjernholm | f513a76 | 2021-09-13 16:04:52 +0100 | [diff] [blame^] | 152 | apexbase="$ANDROID_PRODUCT_OUT/system/apex/${apex}" |
| 153 | unset file |
| 154 | if [ -f "${apexbase}.apex" ]; then |
| 155 | file="${apexbase}.apex" |
| 156 | elif [ -f "${apexbase}.capex" ]; then |
| 157 | file="${apexbase}.capex" |
| 158 | fi |
| 159 | if [ -n "${file}" ]; then |
| 160 | echo "Extracting APEX file: ${file}" |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 161 | rm -rf $dir |
| 162 | mkdir -p $dir |
| 163 | $ANDROID_HOST_OUT/bin/deapexer --debugfs_path $debugfs extract $file $dir |
| 164 | fi |
| 165 | done |
| 166 | |
Nicolas Geoffray | c631a24 | 2020-08-05 15:52:31 +0100 | [diff] [blame] | 167 | # Replace stub libraries with implemenation libraries: because we do chroot |
| 168 | # testing, we need to install an implementation of the libraries (and cannot |
| 169 | # rely on the one already installed on the device, if the device is post R and |
| 170 | # has it). |
Martin Stjernholm | f2893ad | 2021-03-09 17:43:59 +0000 | [diff] [blame] | 171 | implementation_libs=( |
| 172 | "heapprofd_client_api.so" |
| 173 | "libartpalette-system.so" |
| 174 | "liblog.so" |
| 175 | ) |
Nicolas Geoffray | c631a24 | 2020-08-05 15:52:31 +0100 | [diff] [blame] | 176 | if [ -d prebuilts/runtime/mainline/platform/impl ]; then |
| 177 | if [[ $TARGET_ARCH = arm* ]]; then |
| 178 | arch32=arm |
| 179 | arch64=arm64 |
| 180 | else |
| 181 | arch32=x86 |
| 182 | arch64=x86_64 |
| 183 | fi |
Martin Stjernholm | f2893ad | 2021-03-09 17:43:59 +0000 | [diff] [blame] | 184 | for so in ${implementation_libs[@]}; do |
Nicolas Geoffray | c631a24 | 2020-08-05 15:52:31 +0100 | [diff] [blame] | 185 | if [ -d "$ANDROID_PRODUCT_OUT/system/lib" ]; then |
| 186 | cmd="cp -p prebuilts/runtime/mainline/platform/impl/$arch32/$so $ANDROID_PRODUCT_OUT/system/lib/$so" |
| 187 | echo "Executing $cmd" |
| 188 | eval "$cmd" |
| 189 | fi |
| 190 | if [ -d "$ANDROID_PRODUCT_OUT/system/lib64" ]; then |
| 191 | cmd="cp -p prebuilts/runtime/mainline/platform/impl/$arch64/$so $ANDROID_PRODUCT_OUT/system/lib64/$so" |
| 192 | echo "Executing $cmd" |
| 193 | eval "$cmd" |
| 194 | fi |
| 195 | done |
| 196 | fi |
| 197 | |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 198 | # Create canonical name -> file name symlink in the symbol directory for the |
| 199 | # Testing ART APEX. |
| 200 | # |
| 201 | # This mimics the logic from `art/Android.mk`. We made the choice not to |
| 202 | # implement this in `art/Android.mk`, as the Testing ART APEX is a test artifact |
| 203 | # that should never ship with an actual product, and we try to keep it out of |
| 204 | # standard build recipes |
| 205 | # |
| 206 | # TODO(b/141004137, b/129534335): Remove this, expose the Testing ART APEX in |
| 207 | # the `art/Android.mk` build logic, and add absence checks (e.g. in |
| 208 | # `build/make/core/main.mk`) to prevent the Testing ART APEX from ending up in a |
| 209 | # system image. |
Roland Levillain | 7997590 | 2019-09-16 18:00:29 +0100 | [diff] [blame] | 210 | target_out_unstripped="$ANDROID_PRODUCT_OUT/symbols" |
| 211 | link_name="$target_out_unstripped/apex/com.android.art" |
| 212 | link_command="mkdir -p $(dirname "$link_name") && ln -sf com.android.art.testing \"$link_name\"" |
| 213 | echo "Executing $link_command" |
Roland Levillain | c3f2fe9 | 2020-02-12 19:40:20 +0000 | [diff] [blame] | 214 | eval "$link_command" |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 215 | |
| 216 | # Temporary fix for libjavacrypto.so dependencies in libcore and jvmti tests (b/147124225). |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 217 | conscrypt_dir="$ANDROID_PRODUCT_OUT/system/apex/com.android.conscrypt" |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 218 | conscrypt_libs="libjavacrypto.so libcrypto.so libssl.so" |
Nicolas Geoffray | cb62cd8 | 2020-04-03 12:17:50 +0100 | [diff] [blame] | 219 | if [ ! -d "${conscrypt_dir}" ]; then |
| 220 | echo -e "Missing conscrypt APEX in build output: ${conscrypt_dir}" |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 221 | exit 1 |
| 222 | fi |
Nicolas Geoffray | 81673f0 | 2020-04-22 16:43:54 +0100 | [diff] [blame] | 223 | if [ ! -f "${conscrypt_dir}/javalib/conscrypt.jar" ]; then |
| 224 | echo -e "Missing conscrypt jar in build output: ${conscrypt_dir}" |
| 225 | exit 1 |
| 226 | fi |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 227 | for l in lib lib64; do |
Nicolas Geoffray | cb62cd8 | 2020-04-03 12:17:50 +0100 | [diff] [blame] | 228 | if [ ! -d "$ANDROID_PRODUCT_OUT/system/$l" ]; then |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 229 | continue |
| 230 | fi |
| 231 | for so in $conscrypt_libs; do |
Nicolas Geoffray | cb62cd8 | 2020-04-03 12:17:50 +0100 | [diff] [blame] | 232 | src="${conscrypt_dir}/${l}/${so}" |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 233 | dst="$ANDROID_PRODUCT_OUT/system/${l}/${so}" |
| 234 | if [ "${src}" -nt "${dst}" ]; then |
| 235 | cmd="cp -p \"${src}\" \"${dst}\"" |
| 236 | echo "Executing $cmd" |
Roland Levillain | c3f2fe9 | 2020-02-12 19:40:20 +0000 | [diff] [blame] | 237 | eval "$cmd" |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 238 | fi |
| 239 | done |
| 240 | done |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 241 | |
Martin Stjernholm | ac048ae | 2020-06-22 14:38:11 +0100 | [diff] [blame] | 242 | # TODO(b/159355595): Ensure there is a tzdata in system to avoid warnings on |
| 243 | # stderr from Bionic. |
| 244 | if [ ! -f $ANDROID_PRODUCT_OUT/system/usr/share/zoneinfo/tzdata ]; then |
| 245 | mkdir -p $ANDROID_PRODUCT_OUT/system/usr/share/zoneinfo |
| 246 | cp $ANDROID_PRODUCT_OUT/system/apex/com.android.tzdata/etc/tz/tzdata \ |
| 247 | $ANDROID_PRODUCT_OUT/system/usr/share/zoneinfo/tzdata |
| 248 | fi |
| 249 | |
Martin Stjernholm | 4bb9f67 | 2020-05-19 01:33:47 +0100 | [diff] [blame] | 250 | # Create system symlinks for the Runtime APEX. Normally handled by |
| 251 | # installSymlinkToRuntimeApex in soong/cc/binary.go, but we have to replicate |
| 252 | # it here since we don't run the install rules for the Runtime APEX. |
| 253 | for b in linker{,_asan}{,64}; do |
| 254 | echo "Symlinking /apex/com.android.runtime/bin/$b to /system/bin" |
| 255 | ln -sf /apex/com.android.runtime/bin/$b $ANDROID_PRODUCT_OUT/system/bin/$b |
| 256 | done |
Martin Stjernholm | fa37ba2 | 2020-09-01 18:54:06 +0100 | [diff] [blame] | 257 | for d in $ANDROID_PRODUCT_OUT/system/apex/com.android.runtime/lib{,64}/bionic; do |
| 258 | if [ -d $d ]; then |
| 259 | for p in $d/*; do |
| 260 | lib_dir=$(expr $p : '.*/\(lib[0-9]*\)/.*') |
| 261 | lib_file=$(basename $p) |
| 262 | src=/apex/com.android.runtime/${lib_dir}/bionic/${lib_file} |
| 263 | dst=$ANDROID_PRODUCT_OUT/system/${lib_dir}/${lib_file} |
| 264 | echo "Symlinking $src into /system/${lib_dir}" |
| 265 | mkdir -p $(dirname $dst) |
| 266 | ln -sf $src $dst |
| 267 | done |
| 268 | fi |
Martin Stjernholm | 4bb9f67 | 2020-05-19 01:33:47 +0100 | [diff] [blame] | 269 | done |
| 270 | |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 271 | # Create linker config files. We run linkerconfig on host to avoid problems |
| 272 | # building it statically for device in an unbundled tree. |
| 273 | |
Jooyung Han | f97a859 | 2020-06-17 15:19:17 +0900 | [diff] [blame] | 274 | # temporary root for linkerconfig |
| 275 | linkerconfig_root=$ANDROID_PRODUCT_OUT/art_linkerconfig_root |
| 276 | |
| 277 | rm -rf $linkerconfig_root |
| 278 | |
| 279 | # Linkerconfig reads files from /system/etc |
| 280 | mkdir -p $linkerconfig_root/system |
| 281 | cp -r $ANDROID_PRODUCT_OUT/system/etc $linkerconfig_root/system |
| 282 | |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 283 | # For linkerconfig to pick up the APEXes correctly we need to make them |
Jooyung Han | f97a859 | 2020-06-17 15:19:17 +0900 | [diff] [blame] | 284 | # available in $linkerconfig_root/apex. |
| 285 | mkdir -p $linkerconfig_root/apex |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 286 | for apex in ${apexes[@]}; do |
| 287 | src="$ANDROID_PRODUCT_OUT/system/apex/${apex}" |
| 288 | if [[ $apex == com.android.art.* ]]; then |
Jooyung Han | f97a859 | 2020-06-17 15:19:17 +0900 | [diff] [blame] | 289 | dst="$linkerconfig_root/apex/com.android.art" |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 290 | else |
Jooyung Han | f97a859 | 2020-06-17 15:19:17 +0900 | [diff] [blame] | 291 | dst="$linkerconfig_root/apex/${apex}" |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 292 | fi |
| 293 | echo "Copying APEX directory from $src to $dst" |
| 294 | rm -rf $dst |
| 295 | cp -r $src $dst |
| 296 | done |
| 297 | |
Martin Stjernholm | 7914e89 | 2020-09-02 20:47:05 +0100 | [diff] [blame] | 298 | # Linkerconfig also looks at /apex/apex-info-list.xml to check for system APEXes. |
| 299 | apex_xml_file=$linkerconfig_root/apex/apex-info-list.xml |
| 300 | echo "Creating $apex_xml_file" |
| 301 | cat <<EOF > $apex_xml_file |
| 302 | <?xml version="1.0" encoding="utf-8"?> |
| 303 | <apex-info-list> |
| 304 | EOF |
| 305 | for apex in ${apexes[@]}; do |
| 306 | [[ $apex == com.android.art.* ]] && apex=com.android.art |
| 307 | cat <<EOF >> $apex_xml_file |
| 308 | <apex-info moduleName="${apex}" modulePath="/system/apex/${apex}.apex" preinstalledModulePath="/system/apex/${apex}.apex" versionCode="1" versionName="" isFactory="true" isActive="true"> |
| 309 | </apex-info> |
| 310 | EOF |
| 311 | done |
| 312 | cat <<EOF >> $apex_xml_file |
| 313 | </apex-info-list> |
| 314 | EOF |
| 315 | |
Victor Chang | d6363c1 | 2020-11-26 16:49:46 +0000 | [diff] [blame] | 316 | system_linker_config_pb=$linkerconfig_root/system/etc/linker.config.pb |
Martin Stjernholm | 98e9a12 | 2021-04-25 17:55:31 +0100 | [diff] [blame] | 317 | # This list needs to be synced with provideLibs in system/etc/linker.config.pb |
| 318 | # in the targeted platform image. |
| 319 | # TODO(b/186649223): Create a prebuilt for it in platform-mainline-sdk. |
| 320 | system_provide_libs=( |
| 321 | heapprofd_client_api.so |
| 322 | libEGL.so |
| 323 | libGLESv1_CM.so |
| 324 | libGLESv2.so |
| 325 | libGLESv3.so |
| 326 | libOpenMAXAL.so |
| 327 | libOpenSLES.so |
| 328 | libRS.so |
| 329 | libaaudio.so |
| 330 | libadbd_auth.so |
| 331 | libadbd_fs.so |
| 332 | libamidi.so |
| 333 | libandroid.so |
| 334 | libandroid_net.so |
| 335 | libartpalette-system.so |
| 336 | libbinder_ndk.so |
| 337 | libc.so |
| 338 | libcamera2ndk.so |
| 339 | libcgrouprc.so |
| 340 | libclang_rt.asan-i686-android.so |
| 341 | libclang_rt.asan-x86_64-android.so |
| 342 | libdl.so |
| 343 | libdl_android.so |
| 344 | libft2.so |
| 345 | libincident.so |
| 346 | libjnigraphics.so |
| 347 | liblog.so |
| 348 | libm.so |
| 349 | libmediametrics.so |
| 350 | libmediandk.so |
| 351 | libnativewindow.so |
| 352 | libneuralnetworks_packageinfo.so |
| 353 | libselinux.so |
| 354 | libstdc++.so |
| 355 | libsync.so |
| 356 | libvndksupport.so |
| 357 | libvulkan.so |
| 358 | libz.so |
| 359 | ) |
| 360 | |
Victor Chang | d6363c1 | 2020-11-26 16:49:46 +0000 | [diff] [blame] | 361 | echo "Encoding linker.config.json to $system_linker_config_pb" |
Nicolas Geoffray | 29ce843 | 2020-11-27 09:50:17 +0000 | [diff] [blame] | 362 | $ANDROID_HOST_OUT/bin/conv_linker_config proto -s $ANDROID_BUILD_TOP/system/core/rootdir/etc/linker.config.json -o $system_linker_config_pb |
Martin Stjernholm | 98e9a12 | 2021-04-25 17:55:31 +0100 | [diff] [blame] | 363 | $ANDROID_HOST_OUT/bin/conv_linker_config append -s $system_linker_config_pb -o $system_linker_config_pb --key "provideLibs" --value "${system_provide_libs[*]}" |
Victor Chang | d6363c1 | 2020-11-26 16:49:46 +0000 | [diff] [blame] | 364 | |
Jooyung Han | f97a859 | 2020-06-17 15:19:17 +0900 | [diff] [blame] | 365 | # To avoid warnings from linkerconfig when it checks following two partitions |
| 366 | mkdir -p $linkerconfig_root/product |
| 367 | mkdir -p $linkerconfig_root/system_ext |
| 368 | |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 369 | platform_version=$(build/soong/soong_ui.bash --dumpvar-mode PLATFORM_VERSION) |
Jooyung Han | f97a859 | 2020-06-17 15:19:17 +0900 | [diff] [blame] | 370 | linkerconfig_out=$ANDROID_PRODUCT_OUT/linkerconfig |
| 371 | echo "Generating linkerconfig in $linkerconfig_out" |
| 372 | rm -rf $linkerconfig_out |
| 373 | mkdir -p $linkerconfig_out |
| 374 | $ANDROID_HOST_OUT/bin/linkerconfig --target $linkerconfig_out --root $linkerconfig_root --vndk $platform_version |
Roland Levillain | 7997590 | 2019-09-16 18:00:29 +0100 | [diff] [blame] | 375 | fi |