blob: a20175531d97c480973558173f84829504ffc75b [file] [log] [blame]
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +01001#!/bin/bash
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
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
Colin Crosse0ef0a82017-07-27 21:29:18 +000035using_jack=$(get_build_var ANDROID_COMPILE_WITH_JACK)
Igor Murashkin84f26322017-06-06 11:36:33 -070036
Nicolas Geoffray4b29f382015-10-07 09:28:52 +010037java_libraries_dir=${out_dir}/target/common/obj/JAVA_LIBRARIES
Andreas Gampe6c3e1a02017-11-09 10:29:32 -080038common_targets="vogar core-tests apache-harmony-jdwp-tests-hostdex jsr166-tests 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
Colin Crosse0ef0a82017-07-27 21:29:18 +000065if [[ $using_jack == "true" ]]; then
Igor Murashkin84f26322017-06-06 11:36:33 -070066 common_targets="$common_targets ${out_dir}/host/linux-x86/bin/jack"
67fi
68
Andreas Gampe353d8182017-10-12 10:17:34 -070069# Allow to build successfully in master-art.
70extra_args=SOONG_ALLOW_MISSING_DEPENDENCIES=true
71
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010072if [[ $mode == "host" ]]; then
Andreas Gampe6c3e1a02017-11-09 10:29:32 -080073 make_command="make $j_arg $extra_args $showcommands build-art-host-tests $common_targets"
74 make_command+=" dx-tests"
75 mode_suffix="-host"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010076elif [[ $mode == "target" ]]; then
Nicolas Geoffrayab4825d2018-02-05 16:12:52 +000077 make_command="make $j_arg $extra_args $showcommands build-art-target-tests $common_targets"
Andreas Gampe6c3e1a02017-11-09 10:29:32 -080078 make_command+=" libjavacrypto-target libnetd_client-target linker toybox toolbox sh"
Nicolas Geoffrayf8137452016-04-28 11:58:03 +010079 make_command+=" ${out_dir}/host/linux-x86/bin/adb libstdc++ "
80 make_command+=" ${out_dir}/target/product/${TARGET_PRODUCT}/system/etc/public.libraries.txt"
Andreas Gampe6c3e1a02017-11-09 10:29:32 -080081 mode_suffix="-target"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010082fi
83
Andreas Gampe6c3e1a02017-11-09 10:29:32 -080084mode_specific_libraries="libjavacoretests libjdwp libwrapagentproperties libwrapagentpropertiesd"
85for LIB in ${mode_specific_libraries} ; do
86 make_command+=" $LIB${mode_suffix}"
87done
88
89
90
Nicolas Geoffrayaadc9862015-09-29 14:56:31 +010091echo "Executing $make_command"
David Brazdildf76a5f2018-01-26 11:03:01 +000092bash -c "$make_command"