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 | |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 19 | if [ ! -d art ]; then |
| 20 | echo "Script needs to be run at the root of the android tree" |
| 21 | exit 1 |
| 22 | fi |
| 23 | |
Colin Cross | e0ef0a8 | 2017-07-27 21:29:18 +0000 | [diff] [blame] | 24 | source build/envsetup.sh >&/dev/null # for get_build_var |
| 25 | |
Fredrik Roubert | ad9c4a3 | 2016-11-11 19:28:18 -0800 | [diff] [blame] | 26 | # Logic for setting out_dir from build/make/core/envsetup.mk: |
| 27 | if [[ -z $OUT_DIR ]]; then |
| 28 | if [[ -z $OUT_DIR_COMMON_BASE ]]; then |
| 29 | out_dir=out |
| 30 | else |
| 31 | out_dir=${OUT_DIR_COMMON_BASE}/${PWD##*/} |
| 32 | fi |
| 33 | else |
| 34 | out_dir=${OUT_DIR} |
| 35 | fi |
| 36 | |
Nicolas Geoffray | 4b29f38 | 2015-10-07 09:28:52 +0100 | [diff] [blame] | 37 | java_libraries_dir=${out_dir}/target/common/obj/JAVA_LIBRARIES |
Alex Light | 761ee21 | 2020-02-19 20:47:43 +0000 | [diff] [blame] | 38 | common_targets="vogar core-tests apache-harmony-jdwp-tests-hostdex jsr166-tests libartpalette-system mockito-target" |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 39 | mode="target" |
| 40 | j_arg="-j$(nproc)" |
Roland Levillain | b8b9356 | 2015-08-20 17:49:56 +0100 | [diff] [blame] | 41 | showcommands= |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 42 | make_command= |
| 43 | |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 44 | while true; do |
| 45 | if [[ "$1" == "--host" ]]; then |
| 46 | mode="host" |
| 47 | shift |
| 48 | elif [[ "$1" == "--target" ]]; then |
| 49 | mode="target" |
| 50 | shift |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 51 | elif [[ "$1" == -j* ]]; then |
Nicolas Geoffray | 667b99e | 2015-05-29 12:17:06 +0100 | [diff] [blame] | 52 | j_arg=$1 |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 53 | shift |
Roland Levillain | b8b9356 | 2015-08-20 17:49:56 +0100 | [diff] [blame] | 54 | elif [[ "$1" == "--showcommands" ]]; then |
| 55 | showcommands="showcommands" |
| 56 | shift |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 57 | elif [[ "$1" == "" ]]; then |
| 58 | break |
Andreas Gampe | 0dcee91 | 2017-02-01 22:07:45 -0800 | [diff] [blame] | 59 | else |
| 60 | echo "Unknown options $@" |
| 61 | exit 1 |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 62 | fi |
| 63 | done |
| 64 | |
Andreas Gampe | 353d818 | 2017-10-12 10:17:34 -0700 | [diff] [blame] | 65 | # Allow to build successfully in master-art. |
Nicolas Geoffray | 21622b8 | 2018-11-15 14:50:07 +0000 | [diff] [blame] | 66 | extra_args="SOONG_ALLOW_MISSING_DEPENDENCIES=true TEMPORARY_DISABLE_PATH_RESTRICTIONS=true" |
Andreas Gampe | 353d818 | 2017-10-12 10:17:34 -0700 | [diff] [blame] | 67 | |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 68 | if [[ $mode == "host" ]]; then |
Alex Light | 92fc2c0 | 2019-07-30 16:15:29 -0700 | [diff] [blame] | 69 | make_command="build/soong/soong_ui.bash --make-mode $j_arg $extra_args $showcommands build-art-host-tests $common_targets" |
Orion Hodson | f7f85d0 | 2019-02-22 16:17:46 +0000 | [diff] [blame] | 70 | make_command+=" dx-tests junit-host" |
Andreas Gampe | 6c3e1a0 | 2017-11-09 10:29:32 -0800 | [diff] [blame] | 71 | mode_suffix="-host" |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 72 | elif [[ $mode == "target" ]]; then |
Evgeny Astigeevich | 069391e | 2018-09-05 22:40:57 +0100 | [diff] [blame] | 73 | if [[ -z "${ANDROID_PRODUCT_OUT}" ]]; then |
| 74 | 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] | 75 | exit 1 |
| 76 | fi |
Alex Light | 92fc2c0 | 2019-07-30 16:15:29 -0700 | [diff] [blame] | 77 | make_command="build/soong/soong_ui.bash --make-mode $j_arg $extra_args $showcommands build-art-target-tests $common_targets" |
Alex Light | 761ee21 | 2020-02-19 20:47:43 +0000 | [diff] [blame] | 78 | make_command+=" libnetd_client-target toybox toolbox sh" |
Alex Light | 219420e | 2019-12-05 10:20:26 -0800 | [diff] [blame] | 79 | make_command+=" debuggerd su gdbserver" |
Nicolas Geoffray | 512c121 | 2018-10-08 09:03:23 +0100 | [diff] [blame] | 80 | make_command+=" libstdc++ " |
Nicolas Geoffray | cb62cd8 | 2020-04-03 12:17:50 +0100 | [diff] [blame] | 81 | # vogar requires the class files for conscrypt. |
| 82 | make_command+=" conscrypt " |
Evgeny Astigeevich | 069391e | 2018-09-05 22:40:57 +0100 | [diff] [blame] | 83 | make_command+=" ${ANDROID_PRODUCT_OUT#"${ANDROID_BUILD_TOP}/"}/system/etc/public.libraries.txt" |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 84 | if [[ -n "$ART_TEST_CHROOT" ]]; then |
Roland Levillain | 15ff34d | 2020-02-05 19:55:34 +0000 | [diff] [blame] | 85 | # Targets required to generate a linker configuration on device within the |
| 86 | # chroot environment. |
| 87 | make_command+=" linkerconfig" |
Roland Levillain | 15ff34d | 2020-02-05 19:55:34 +0000 | [diff] [blame] | 88 | # Additional targets needed for the chroot environment. |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 89 | make_command+=" crash_dump event-log-tags" |
| 90 | fi |
Nicolas Geoffray | cb62cd8 | 2020-04-03 12:17:50 +0100 | [diff] [blame] | 91 | # Needed to extract prebuilts apexes. |
| 92 | make_command+=" deapexer " |
Martin Stjernholm | d6be5da | 2019-07-16 17:14:46 +0100 | [diff] [blame] | 93 | # Build the Testing ART APEX (which is a superset of the Release and Debug ART APEXes). |
| 94 | make_command+=" com.android.art.testing" |
Nicolas Geoffray | cb62cd8 | 2020-04-03 12:17:50 +0100 | [diff] [blame] | 95 | # Build the Runtime (Bionic) APEX. |
| 96 | make_command+=" com.android.runtime" |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 97 | # Build the bootstrap Bionic artifacts links (linker, libc, libdl, libm). |
| 98 | # These targets create these symlinks: |
| 99 | # - from /system/bin/linker(64) to /apex/com.android.runtime/bin/linker(64); and |
| 100 | # - from /system/lib(64)/$lib to /apex/com.android.runtime/lib(64)/$lib. |
Martin Stjernholm | 78a44b9 | 2019-11-11 16:59:46 +0000 | [diff] [blame] | 101 | make_command+=" linker libc.bootstrap libdl.bootstrap libdl_android.bootstrap libm.bootstrap" |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 102 | # Build the Conscrypt APEX. |
| 103 | make_command+=" com.android.conscrypt" |
Victor Chang | 6461124 | 2019-07-05 16:32:41 +0100 | [diff] [blame] | 104 | # Build the i18n APEX. |
| 105 | make_command+=" com.android.i18n" |
Roland Levillain | 2f1e8f8 | 2019-06-12 19:57:50 +0100 | [diff] [blame] | 106 | # Build the Time Zone Data APEX. |
| 107 | make_command+=" com.android.tzdata" |
Nicolas Geoffray | fbeca75 | 2015-05-29 10:54:12 +0100 | [diff] [blame] | 108 | fi |
| 109 | |
Andreas Gampe | 6c3e1a0 | 2017-11-09 10:29:32 -0800 | [diff] [blame] | 110 | mode_specific_libraries="libjavacoretests libjdwp libwrapagentproperties libwrapagentpropertiesd" |
| 111 | for LIB in ${mode_specific_libraries} ; do |
| 112 | make_command+=" $LIB${mode_suffix}" |
| 113 | done |
| 114 | |
| 115 | |
Nicolas Geoffray | aadc986 | 2015-09-29 14:56:31 +0100 | [diff] [blame] | 116 | echo "Executing $make_command" |
Nicolas Geoffray | a8e8cdf | 2018-10-16 09:44:58 +0100 | [diff] [blame] | 117 | # Disable path restrictions to enable luci builds using vpython. |
Roland Levillain | c3f2fe9 | 2020-02-12 19:40:20 +0000 | [diff] [blame] | 118 | eval "$make_command" |
Roland Levillain | 7997590 | 2019-09-16 18:00:29 +0100 | [diff] [blame] | 119 | |
Roland Levillain | 7997590 | 2019-09-16 18:00:29 +0100 | [diff] [blame] | 120 | if [[ $mode == "target" ]]; then |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 121 | # Create canonical name -> file name symlink in the symbol directory for the |
| 122 | # Testing ART APEX. |
| 123 | # |
| 124 | # This mimics the logic from `art/Android.mk`. We made the choice not to |
| 125 | # implement this in `art/Android.mk`, as the Testing ART APEX is a test artifact |
| 126 | # that should never ship with an actual product, and we try to keep it out of |
| 127 | # standard build recipes |
| 128 | # |
| 129 | # TODO(b/141004137, b/129534335): Remove this, expose the Testing ART APEX in |
| 130 | # the `art/Android.mk` build logic, and add absence checks (e.g. in |
| 131 | # `build/make/core/main.mk`) to prevent the Testing ART APEX from ending up in a |
| 132 | # system image. |
Roland Levillain | 7997590 | 2019-09-16 18:00:29 +0100 | [diff] [blame] | 133 | target_out_unstripped="$ANDROID_PRODUCT_OUT/symbols" |
| 134 | link_name="$target_out_unstripped/apex/com.android.art" |
| 135 | link_command="mkdir -p $(dirname "$link_name") && ln -sf com.android.art.testing \"$link_name\"" |
| 136 | echo "Executing $link_command" |
Roland Levillain | c3f2fe9 | 2020-02-12 19:40:20 +0000 | [diff] [blame] | 137 | eval "$link_command" |
Roland Levillain | a871d84 | 2020-02-14 15:37:12 +0000 | [diff] [blame] | 138 | # Also provide access to symbols of binaries from the Runtime (Bionic) APEX, |
| 139 | # e.g. to support debugging in GDB. |
| 140 | find "$target_out_unstripped/apex/com.android.runtime/bin" -type f | while read target; do |
| 141 | cmd="ln -sf $target $target_out_unstripped/system/bin/$(basename $target)" |
Alex Light | 219420e | 2019-12-05 10:20:26 -0800 | [diff] [blame] | 142 | echo "Executing $cmd" |
Roland Levillain | c3f2fe9 | 2020-02-12 19:40:20 +0000 | [diff] [blame] | 143 | eval "$cmd" |
Alex Light | 219420e | 2019-12-05 10:20:26 -0800 | [diff] [blame] | 144 | done |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 145 | |
Nicolas Geoffray | cb62cd8 | 2020-04-03 12:17:50 +0100 | [diff] [blame] | 146 | |
| 147 | conscrypt_dir="$ANDROID_PRODUCT_OUT/system/apex/com.android.conscrypt" |
| 148 | conscrypt_apex="$ANDROID_PRODUCT_OUT/system/apex/com.android.conscrypt.apex" |
| 149 | if [ -f "${conscrypt_apex}" ]; then |
| 150 | # If there is a conscrypt apex prebuilt, extract it. |
| 151 | rm -rf $conscrypt_dir |
| 152 | mkdir $conscrypt_dir |
Nicolas Geoffray | e67fd20 | 2020-04-21 15:56:52 +0100 | [diff] [blame] | 153 | if [[ -z "${ANDROID_HOST_OUT}" ]]; then |
Nicolas Geoffray | 5eee73b | 2020-04-21 21:27:26 +0100 | [diff] [blame] | 154 | echo "ANDROID_HOST_OUT environment variable is empty; using $out_dir/host/linux-x86" |
Nicolas Geoffray | e67fd20 | 2020-04-21 15:56:52 +0100 | [diff] [blame] | 155 | ANDROID_HOST_OUT=$out_dir/host/linux-x86 |
| 156 | fi |
| 157 | $ANDROID_HOST_OUT/bin/deapexer extract $conscrypt_apex $conscrypt_dir |
Nicolas Geoffray | cb62cd8 | 2020-04-03 12:17:50 +0100 | [diff] [blame] | 158 | fi |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 159 | # Temporary fix for libjavacrypto.so dependencies in libcore and jvmti tests (b/147124225). |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 160 | conscrypt_libs="libjavacrypto.so libcrypto.so libssl.so" |
Nicolas Geoffray | cb62cd8 | 2020-04-03 12:17:50 +0100 | [diff] [blame] | 161 | if [ ! -d "${conscrypt_dir}" ]; then |
| 162 | echo -e "Missing conscrypt APEX in build output: ${conscrypt_dir}" |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 163 | exit 1 |
| 164 | fi |
Nicolas Geoffray | 81673f0 | 2020-04-22 16:43:54 +0100 | [diff] [blame^] | 165 | if [ ! -f "${conscrypt_dir}/javalib/conscrypt.jar" ]; then |
| 166 | echo -e "Missing conscrypt jar in build output: ${conscrypt_dir}" |
| 167 | exit 1 |
| 168 | fi |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 169 | for l in lib lib64; do |
Nicolas Geoffray | cb62cd8 | 2020-04-03 12:17:50 +0100 | [diff] [blame] | 170 | if [ ! -d "$ANDROID_PRODUCT_OUT/system/$l" ]; then |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 171 | continue |
| 172 | fi |
| 173 | for so in $conscrypt_libs; do |
Nicolas Geoffray | cb62cd8 | 2020-04-03 12:17:50 +0100 | [diff] [blame] | 174 | src="${conscrypt_dir}/${l}/${so}" |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 175 | dst="$ANDROID_PRODUCT_OUT/system/${l}/${so}" |
| 176 | if [ "${src}" -nt "${dst}" ]; then |
| 177 | cmd="cp -p \"${src}\" \"${dst}\"" |
| 178 | echo "Executing $cmd" |
Roland Levillain | c3f2fe9 | 2020-02-12 19:40:20 +0000 | [diff] [blame] | 179 | eval "$cmd" |
Orion Hodson | 3a809c8 | 2020-01-03 14:53:14 +0000 | [diff] [blame] | 180 | fi |
| 181 | done |
| 182 | done |
Roland Levillain | 7997590 | 2019-09-16 18:00:29 +0100 | [diff] [blame] | 183 | fi |