blob: 17c68f6b61d3f88c35cef0e1d08aa575103c27cd [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++ "
Evgeny Astigeevich069391e2018-09-05 22:40:57 +010081 make_command+=" ${ANDROID_PRODUCT_OUT#"${ANDROID_BUILD_TOP}/"}/system/etc/public.libraries.txt"
Roland Levillaine4f1c512017-10-30 13:28:28 +000082 if [[ -n "$ART_TEST_CHROOT" ]]; then
Roland Levillain15ff34d2020-02-05 19:55:34 +000083 # Targets required to generate a linker configuration on device within the
84 # chroot environment.
85 make_command+=" linkerconfig"
Roland Levillain15ff34d2020-02-05 19:55:34 +000086 # Additional targets needed for the chroot environment.
Roland Levillaine4f1c512017-10-30 13:28:28 +000087 make_command+=" crash_dump event-log-tags"
88 fi
Martin Stjernholmd6be5da2019-07-16 17:14:46 +010089 # Build the Runtime (Bionic) APEX.
90 make_command+=" com.android.runtime"
91 # Build the Testing ART APEX (which is a superset of the Release and Debug ART APEXes).
92 make_command+=" com.android.art.testing"
Roland Levillain72f67742019-03-06 15:48:08 +000093 # Build the bootstrap Bionic artifacts links (linker, libc, libdl, libm).
94 # These targets create these symlinks:
95 # - from /system/bin/linker(64) to /apex/com.android.runtime/bin/linker(64); and
96 # - from /system/lib(64)/$lib to /apex/com.android.runtime/lib(64)/$lib.
Martin Stjernholm78a44b92019-11-11 16:59:46 +000097 make_command+=" linker libc.bootstrap libdl.bootstrap libdl_android.bootstrap libm.bootstrap"
Orion Hodson3a809c82020-01-03 14:53:14 +000098 # Build the Conscrypt APEX.
99 make_command+=" com.android.conscrypt"
Victor Chang64611242019-07-05 16:32:41 +0100100 # Build the i18n APEX.
101 make_command+=" com.android.i18n"
Roland Levillain2f1e8f82019-06-12 19:57:50 +0100102 # Build the Time Zone Data APEX.
103 make_command+=" com.android.tzdata"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +0100104fi
105
Andreas Gampe6c3e1a02017-11-09 10:29:32 -0800106mode_specific_libraries="libjavacoretests libjdwp libwrapagentproperties libwrapagentpropertiesd"
107for LIB in ${mode_specific_libraries} ; do
108 make_command+=" $LIB${mode_suffix}"
109done
110
111
Nicolas Geoffrayaadc9862015-09-29 14:56:31 +0100112echo "Executing $make_command"
Nicolas Geoffraya8e8cdf2018-10-16 09:44:58 +0100113# Disable path restrictions to enable luci builds using vpython.
Roland Levillainc3f2fe92020-02-12 19:40:20 +0000114eval "$make_command"
Roland Levillain79975902019-09-16 18:00:29 +0100115
Roland Levillain79975902019-09-16 18:00:29 +0100116if [[ $mode == "target" ]]; then
Orion Hodson3a809c82020-01-03 14:53:14 +0000117 # Create canonical name -> file name symlink in the symbol directory for the
118 # Testing ART APEX.
119 #
120 # This mimics the logic from `art/Android.mk`. We made the choice not to
121 # implement this in `art/Android.mk`, as the Testing ART APEX is a test artifact
122 # that should never ship with an actual product, and we try to keep it out of
123 # standard build recipes
124 #
125 # TODO(b/141004137, b/129534335): Remove this, expose the Testing ART APEX in
126 # the `art/Android.mk` build logic, and add absence checks (e.g. in
127 # `build/make/core/main.mk`) to prevent the Testing ART APEX from ending up in a
128 # system image.
Roland Levillain79975902019-09-16 18:00:29 +0100129 target_out_unstripped="$ANDROID_PRODUCT_OUT/symbols"
130 link_name="$target_out_unstripped/apex/com.android.art"
131 link_command="mkdir -p $(dirname "$link_name") && ln -sf com.android.art.testing \"$link_name\""
132 echo "Executing $link_command"
Roland Levillainc3f2fe92020-02-12 19:40:20 +0000133 eval "$link_command"
Roland Levillaina871d842020-02-14 15:37:12 +0000134 # Also provide access to symbols of binaries from the Runtime (Bionic) APEX,
135 # e.g. to support debugging in GDB.
136 find "$target_out_unstripped/apex/com.android.runtime/bin" -type f | while read target; do
137 cmd="ln -sf $target $target_out_unstripped/system/bin/$(basename $target)"
Alex Light219420e2019-12-05 10:20:26 -0800138 echo "Executing $cmd"
Roland Levillainc3f2fe92020-02-12 19:40:20 +0000139 eval "$cmd"
Alex Light219420e2019-12-05 10:20:26 -0800140 done
Orion Hodson3a809c82020-01-03 14:53:14 +0000141
142 # Temporary fix for libjavacrypto.so dependencies in libcore and jvmti tests (b/147124225).
143 conscrypt_apex="$ANDROID_PRODUCT_OUT/system/apex/com.android.conscrypt"
144 conscrypt_libs="libjavacrypto.so libcrypto.so libssl.so"
145 if [ ! -d "${conscrypt_apex}" ]; then
146 echo -e "Missing conscrypt APEX in build output: ${conscrypt_apex}"
147 exit 1
148 fi
149 for l in lib lib64; do
150 if [ ! -d "${conscrypt_apex}/$l" ]; then
151 continue
152 fi
153 for so in $conscrypt_libs; do
154 src="${conscrypt_apex}/${l}/${so}"
155 dst="$ANDROID_PRODUCT_OUT/system/${l}/${so}"
156 if [ "${src}" -nt "${dst}" ]; then
157 cmd="cp -p \"${src}\" \"${dst}\""
158 echo "Executing $cmd"
Roland Levillainc3f2fe92020-02-12 19:40:20 +0000159 eval "$cmd"
Orion Hodson3a809c82020-01-03 14:53:14 +0000160 fi
161 done
162 done
Roland Levillain79975902019-09-16 18:00:29 +0100163fi