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