blob: 142918f13b3e235a3f4eab49b008e7ee08befdbb [file] [log] [blame]
Roland Levillain72f67742019-03-06 15:48:08 +00001#! /bin/bash
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +01002#
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 Hodson44ab2cd2019-10-08 10:17:05 +010017set -e
18
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010019if [ ! -d art ]; then
20 echo "Script needs to be run at the root of the android tree"
21 exit 1
22fi
23
Colin Crosse0ef0a82017-07-27 21:29:18 +000024source build/envsetup.sh >&/dev/null # for get_build_var
25
Fredrik Roubertad9c4a32016-11-11 19:28:18 -080026# Logic for setting out_dir from build/make/core/envsetup.mk:
27if [[ -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
33else
34 out_dir=${OUT_DIR}
35fi
36
Nicolas Geoffray4b29f382015-10-07 09:28:52 +010037java_libraries_dir=${out_dir}/target/common/obj/JAVA_LIBRARIES
Alex Light761ee212020-02-19 20:47:43 +000038common_targets="vogar core-tests apache-harmony-jdwp-tests-hostdex jsr166-tests libartpalette-system mockito-target"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010039mode="target"
40j_arg="-j$(nproc)"
Roland Levillainb8b93562015-08-20 17:49:56 +010041showcommands=
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010042make_command=
43
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010044while true; do
45 if [[ "$1" == "--host" ]]; then
46 mode="host"
47 shift
48 elif [[ "$1" == "--target" ]]; then
49 mode="target"
50 shift
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010051 elif [[ "$1" == -j* ]]; then
Nicolas Geoffray667b99e2015-05-29 12:17:06 +010052 j_arg=$1
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010053 shift
Roland Levillainb8b93562015-08-20 17:49:56 +010054 elif [[ "$1" == "--showcommands" ]]; then
55 showcommands="showcommands"
56 shift
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010057 elif [[ "$1" == "" ]]; then
58 break
Andreas Gampe0dcee912017-02-01 22:07:45 -080059 else
60 echo "Unknown options $@"
61 exit 1
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010062 fi
63done
64
Andreas Gampe353d8182017-10-12 10:17:34 -070065# Allow to build successfully in master-art.
Nicolas Geoffray21622b82018-11-15 14:50:07 +000066extra_args="SOONG_ALLOW_MISSING_DEPENDENCIES=true TEMPORARY_DISABLE_PATH_RESTRICTIONS=true"
Andreas Gampe353d8182017-10-12 10:17:34 -070067
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010068if [[ $mode == "host" ]]; then
Alex Light92fc2c02019-07-30 16:15:29 -070069 make_command="build/soong/soong_ui.bash --make-mode $j_arg $extra_args $showcommands build-art-host-tests $common_targets"
Orion Hodsonf7f85d02019-02-22 16:17:46 +000070 make_command+=" dx-tests junit-host"
Andreas Gampe6c3e1a02017-11-09 10:29:32 -080071 mode_suffix="-host"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010072elif [[ $mode == "target" ]]; then
Evgeny Astigeevich069391e2018-09-05 22:40:57 +010073 if [[ -z "${ANDROID_PRODUCT_OUT}" ]]; then
74 echo 'ANDROID_PRODUCT_OUT environment variable is empty; did you forget to run `lunch`?'
Roland Levillainfe3e2bf2018-03-02 16:01:50 +000075 exit 1
76 fi
Alex Light92fc2c02019-07-30 16:15:29 -070077 make_command="build/soong/soong_ui.bash --make-mode $j_arg $extra_args $showcommands build-art-target-tests $common_targets"
Alex Light761ee212020-02-19 20:47:43 +000078 make_command+=" libnetd_client-target toybox toolbox sh"
Alex Light219420e2019-12-05 10:20:26 -080079 make_command+=" debuggerd su gdbserver"
Nicolas Geoffray512c1212018-10-08 09:03:23 +010080 make_command+=" libstdc++ "
Nicolas Geoffraycb62cd82020-04-03 12:17:50 +010081 # vogar requires the class files for conscrypt.
82 make_command+=" conscrypt "
Evgeny Astigeevich069391e2018-09-05 22:40:57 +010083 make_command+=" ${ANDROID_PRODUCT_OUT#"${ANDROID_BUILD_TOP}/"}/system/etc/public.libraries.txt"
Roland Levillaine4f1c512017-10-30 13:28:28 +000084 if [[ -n "$ART_TEST_CHROOT" ]]; then
Roland Levillain15ff34d2020-02-05 19:55:34 +000085 # Targets required to generate a linker configuration on device within the
86 # chroot environment.
87 make_command+=" linkerconfig"
Roland Levillain15ff34d2020-02-05 19:55:34 +000088 # Additional targets needed for the chroot environment.
Roland Levillaine4f1c512017-10-30 13:28:28 +000089 make_command+=" crash_dump event-log-tags"
90 fi
Nicolas Geoffraycb62cd82020-04-03 12:17:50 +010091 # Needed to extract prebuilts apexes.
92 make_command+=" deapexer "
Martin Stjernholmd6be5da2019-07-16 17:14:46 +010093 # Build the Testing ART APEX (which is a superset of the Release and Debug ART APEXes).
94 make_command+=" com.android.art.testing"
Nicolas Geoffraycb62cd82020-04-03 12:17:50 +010095 # Build the Runtime (Bionic) APEX.
96 make_command+=" com.android.runtime"
Roland Levillain72f67742019-03-06 15:48:08 +000097 # 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 Stjernholm78a44b92019-11-11 16:59:46 +0000101 make_command+=" linker libc.bootstrap libdl.bootstrap libdl_android.bootstrap libm.bootstrap"
Orion Hodson3a809c82020-01-03 14:53:14 +0000102 # Build the Conscrypt APEX.
103 make_command+=" com.android.conscrypt"
Victor Chang64611242019-07-05 16:32:41 +0100104 # Build the i18n APEX.
105 make_command+=" com.android.i18n"
Roland Levillain2f1e8f82019-06-12 19:57:50 +0100106 # Build the Time Zone Data APEX.
107 make_command+=" com.android.tzdata"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +0100108fi
109
Andreas Gampe6c3e1a02017-11-09 10:29:32 -0800110mode_specific_libraries="libjavacoretests libjdwp libwrapagentproperties libwrapagentpropertiesd"
111for LIB in ${mode_specific_libraries} ; do
112 make_command+=" $LIB${mode_suffix}"
113done
114
115
Nicolas Geoffrayaadc9862015-09-29 14:56:31 +0100116echo "Executing $make_command"
Nicolas Geoffraya8e8cdf2018-10-16 09:44:58 +0100117# Disable path restrictions to enable luci builds using vpython.
Roland Levillainc3f2fe92020-02-12 19:40:20 +0000118eval "$make_command"
Roland Levillain79975902019-09-16 18:00:29 +0100119
Roland Levillain79975902019-09-16 18:00:29 +0100120if [[ $mode == "target" ]]; then
Orion Hodson3a809c82020-01-03 14:53:14 +0000121 # 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 Levillain79975902019-09-16 18:00:29 +0100133 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 Levillainc3f2fe92020-02-12 19:40:20 +0000137 eval "$link_command"
Roland Levillaina871d842020-02-14 15:37:12 +0000138 # 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 Light219420e2019-12-05 10:20:26 -0800142 echo "Executing $cmd"
Roland Levillainc3f2fe92020-02-12 19:40:20 +0000143 eval "$cmd"
Alex Light219420e2019-12-05 10:20:26 -0800144 done
Orion Hodson3a809c82020-01-03 14:53:14 +0000145
Nicolas Geoffraycb62cd82020-04-03 12:17:50 +0100146
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 Geoffraye67fd202020-04-21 15:56:52 +0100153 if [[ -z "${ANDROID_HOST_OUT}" ]]; then
Nicolas Geoffray5eee73b2020-04-21 21:27:26 +0100154 echo "ANDROID_HOST_OUT environment variable is empty; using $out_dir/host/linux-x86"
Nicolas Geoffraye67fd202020-04-21 15:56:52 +0100155 ANDROID_HOST_OUT=$out_dir/host/linux-x86
156 fi
157 $ANDROID_HOST_OUT/bin/deapexer extract $conscrypt_apex $conscrypt_dir
Nicolas Geoffraycb62cd82020-04-03 12:17:50 +0100158 fi
Orion Hodson3a809c82020-01-03 14:53:14 +0000159 # Temporary fix for libjavacrypto.so dependencies in libcore and jvmti tests (b/147124225).
Orion Hodson3a809c82020-01-03 14:53:14 +0000160 conscrypt_libs="libjavacrypto.so libcrypto.so libssl.so"
Nicolas Geoffraycb62cd82020-04-03 12:17:50 +0100161 if [ ! -d "${conscrypt_dir}" ]; then
162 echo -e "Missing conscrypt APEX in build output: ${conscrypt_dir}"
Orion Hodson3a809c82020-01-03 14:53:14 +0000163 exit 1
164 fi
Nicolas Geoffray81673f02020-04-22 16:43:54 +0100165 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 Hodson3a809c82020-01-03 14:53:14 +0000169 for l in lib lib64; do
Nicolas Geoffraycb62cd82020-04-03 12:17:50 +0100170 if [ ! -d "$ANDROID_PRODUCT_OUT/system/$l" ]; then
Orion Hodson3a809c82020-01-03 14:53:14 +0000171 continue
172 fi
173 for so in $conscrypt_libs; do
Nicolas Geoffraycb62cd82020-04-03 12:17:50 +0100174 src="${conscrypt_dir}/${l}/${so}"
Orion Hodson3a809c82020-01-03 14:53:14 +0000175 dst="$ANDROID_PRODUCT_OUT/system/${l}/${so}"
176 if [ "${src}" -nt "${dst}" ]; then
177 cmd="cp -p \"${src}\" \"${dst}\""
178 echo "Executing $cmd"
Roland Levillainc3f2fe92020-02-12 19:40:20 +0000179 eval "$cmd"
Orion Hodson3a809c82020-01-03 14:53:14 +0000180 fi
181 done
182 done
Roland Levillain79975902019-09-16 18:00:29 +0100183fi