1 #!/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 17 if [ ! -d art ]; then 18 echo "Script needs to be run at the root of the android tree" 19 exit 1 20 fi 21 22 source build/envsetup.sh >&/dev/null # for get_build_var 23 24 # Logic for setting out_dir from build/make/core/envsetup.mk: 25 if [[ -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 31 else 32 out_dir=${OUT_DIR} 33 fi 34 35 using_jack=$(get_build_var ANDROID_COMPILE_WITH_JACK) 36 37 java_libraries_dir=${out_dir}/target/common/obj/JAVA_LIBRARIES 38 common_targets="vogar core-tests apache-harmony-jdwp-tests-hostdex jsr166-tests mockito-target" 39 mode="target" 40 j_arg="-j$(nproc)" 41 showcommands= 42 make_command= 43 44 while true; do 45 if [[ "$1" == "--host" ]]; then 46 mode="host" 47 shift 48 elif [[ "$1" == "--target" ]]; then 49 mode="target" 50 shift 51 elif [[ "$1" == -j* ]]; then 52 j_arg=$1 53 shift 54 elif [[ "$1" == "--showcommands" ]]; then 55 showcommands="showcommands" 56 shift 57 elif [[ "$1" == "" ]]; then 58 break 59 else 60 echo "Unknown options $@" 61 exit 1 62 fi 63 done 64 65 if [[ $using_jack == "true" ]]; then 66 common_targets="$common_targets ${out_dir}/host/linux-x86/bin/jack" 67 fi 68 69 # Allow to build successfully in master-art. 70 extra_args=SOONG_ALLOW_MISSING_DEPENDENCIES=true 71 72 if [[ $mode == "host" ]]; then 73 make_command="make $j_arg $extra_args $showcommands build-art-host-tests $common_targets" 74 make_command+=" dx-tests" 75 mode_suffix="-host" 76 elif [[ $mode == "target" ]]; then 77 make_command="make $j_arg $extra_args $showcommands build-art-target-tests $common_targets" 78 make_command+=" libjavacrypto-target libnetd_client-target linker toybox toolbox sh" 79 make_command+=" ${out_dir}/host/linux-x86/bin/adb libstdc++ " 80 make_command+=" ${out_dir}/target/product/${TARGET_PRODUCT}/system/etc/public.libraries.txt" 81 mode_suffix="-target" 82 fi 83 84 mode_specific_libraries="libjavacoretests libjdwp libwrapagentproperties libwrapagentpropertiesd" 85 for LIB in ${mode_specific_libraries} ; do 86 make_command+=" $LIB${mode_suffix}" 87 done 88 89 90 91 echo "Executing $make_command" 92 bash -c "$make_command" 93