blob: cf5461e6cde630d0b59e1e9e709b66e5a56f89fc [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
17if [ ! -d art ]; then
18 echo "Script needs to be run at the root of the android tree"
19 exit 1
20fi
21
Colin Crosse0ef0a82017-07-27 21:29:18 +000022source build/envsetup.sh >&/dev/null # for get_build_var
23
Fredrik Roubertad9c4a32016-11-11 19:28:18 -080024# Logic for setting out_dir from build/make/core/envsetup.mk:
25if [[ -z $OUT_DIR ]]; then
26 if [[ -z $OUT_DIR_COMMON_BASE ]]; then
27 out_dir=out
28 else
29 out_dir=${OUT_DIR_COMMON_BASE}/${PWD##*/}
30 fi
31else
32 out_dir=${OUT_DIR}
33fi
34
Nicolas Geoffray4b29f382015-10-07 09:28:52 +010035java_libraries_dir=${out_dir}/target/common/obj/JAVA_LIBRARIES
Andreas Gampe6c3e1a02017-11-09 10:29:32 -080036common_targets="vogar core-tests apache-harmony-jdwp-tests-hostdex jsr166-tests mockito-target"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010037mode="target"
38j_arg="-j$(nproc)"
Roland Levillainb8b93562015-08-20 17:49:56 +010039showcommands=
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010040make_command=
41
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010042while true; do
43 if [[ "$1" == "--host" ]]; then
44 mode="host"
45 shift
46 elif [[ "$1" == "--target" ]]; then
47 mode="target"
48 shift
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010049 elif [[ "$1" == -j* ]]; then
Nicolas Geoffray667b99e2015-05-29 12:17:06 +010050 j_arg=$1
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010051 shift
Roland Levillainb8b93562015-08-20 17:49:56 +010052 elif [[ "$1" == "--showcommands" ]]; then
53 showcommands="showcommands"
54 shift
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010055 elif [[ "$1" == "" ]]; then
56 break
Andreas Gampe0dcee912017-02-01 22:07:45 -080057 else
58 echo "Unknown options $@"
59 exit 1
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010060 fi
61done
62
Andreas Gampe353d8182017-10-12 10:17:34 -070063# Allow to build successfully in master-art.
Nicolas Geoffray21622b82018-11-15 14:50:07 +000064extra_args="SOONG_ALLOW_MISSING_DEPENDENCIES=true TEMPORARY_DISABLE_PATH_RESTRICTIONS=true"
Andreas Gampe353d8182017-10-12 10:17:34 -070065
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010066if [[ $mode == "host" ]]; then
Alex Light92fc2c02019-07-30 16:15:29 -070067 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 +000068 make_command+=" dx-tests junit-host"
Andreas Gampe6c3e1a02017-11-09 10:29:32 -080069 mode_suffix="-host"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010070elif [[ $mode == "target" ]]; then
Evgeny Astigeevich069391e2018-09-05 22:40:57 +010071 if [[ -z "${ANDROID_PRODUCT_OUT}" ]]; then
72 echo 'ANDROID_PRODUCT_OUT environment variable is empty; did you forget to run `lunch`?'
Roland Levillainfe3e2bf2018-03-02 16:01:50 +000073 exit 1
74 fi
Alex Light92fc2c02019-07-30 16:15:29 -070075 make_command="build/soong/soong_ui.bash --make-mode $j_arg $extra_args $showcommands build-art-target-tests $common_targets"
Roland Levillaindcd7b512019-07-10 14:21:43 +000076 make_command+=" libjavacrypto-target libnetd_client-target toybox toolbox sh"
Roland Levillainb52dbb72018-05-01 14:03:45 +010077 make_command+=" debuggerd su"
Nicolas Geoffray512c1212018-10-08 09:03:23 +010078 make_command+=" libstdc++ "
Evgeny Astigeevich069391e2018-09-05 22:40:57 +010079 make_command+=" ${ANDROID_PRODUCT_OUT#"${ANDROID_BUILD_TOP}/"}/system/etc/public.libraries.txt"
Roland Levillaine4f1c512017-10-30 13:28:28 +000080 if [[ -n "$ART_TEST_CHROOT" ]]; then
81 # These targets are needed for the chroot environment.
82 make_command+=" crash_dump event-log-tags"
83 fi
Martin Stjernholmd6be5da2019-07-16 17:14:46 +010084 # Build the Runtime (Bionic) APEX.
85 make_command+=" com.android.runtime"
86 # Build the Testing ART APEX (which is a superset of the Release and Debug ART APEXes).
87 make_command+=" com.android.art.testing"
Roland Levillain72f67742019-03-06 15:48:08 +000088 # Build the system linker configuration, which is needed to use the
89 # Runtime APEX's linker configuration.
90 make_command+=" ld.config.txt "
91 # Build the bootstrap Bionic artifacts links (linker, libc, libdl, libm).
92 # These targets create these symlinks:
93 # - from /system/bin/linker(64) to /apex/com.android.runtime/bin/linker(64); and
94 # - from /system/lib(64)/$lib to /apex/com.android.runtime/lib(64)/$lib.
95 make_command+=" linker libc.bootstrap libdl.bootstrap libm.bootstrap"
Victor Chang64611242019-07-05 16:32:41 +010096 # Build the i18n APEX.
97 make_command+=" com.android.i18n"
Roland Levillain2f1e8f82019-06-12 19:57:50 +010098 # Build the Time Zone Data APEX.
99 make_command+=" com.android.tzdata"
Andreas Gampe6c3e1a02017-11-09 10:29:32 -0800100 mode_suffix="-target"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +0100101fi
102
Andreas Gampe6c3e1a02017-11-09 10:29:32 -0800103mode_specific_libraries="libjavacoretests libjdwp libwrapagentproperties libwrapagentpropertiesd"
104for LIB in ${mode_specific_libraries} ; do
105 make_command+=" $LIB${mode_suffix}"
106done
107
108
Nicolas Geoffrayaadc9862015-09-29 14:56:31 +0100109echo "Executing $make_command"
Nicolas Geoffraya8e8cdf2018-10-16 09:44:58 +0100110# Disable path restrictions to enable luci builds using vpython.
Nicolas Geoffray21622b82018-11-15 14:50:07 +0000111bash -c "$make_command"
Roland Levillain79975902019-09-16 18:00:29 +0100112
113
114# Create canonical name -> file name symlink in the symbol directory for the
115# Testing ART APEX.
116#
117# This mimics the logic from `art/Android.mk`. We made the choice not to
118# implement this in `art/Android.mk`, as the Testing ART APEX is a test artifact
119# that should never ship with an actual product, and we try to keep it out of
120# standard build recipes
121#
122# TODO(b/141004137, b/129534335): Remove this, expose the Testing ART APEX in
123# the `art/Android.mk` build logic, and add absence checks (e.g. in
124# `build/make/core/main.mk`) to prevent the Testing ART APEX from ending up in a
125# system image.
126if [[ $mode == "target" ]]; then
127 target_out_unstripped="$ANDROID_PRODUCT_OUT/symbols"
128 link_name="$target_out_unstripped/apex/com.android.art"
129 link_command="mkdir -p $(dirname "$link_name") && ln -sf com.android.art.testing \"$link_name\""
130 echo "Executing $link_command"
131 bash -c "$link_command"
132fi