1#!/bin/bash -e 2 3# This script builds the APEX modules, SDKs and module exports that the ART 4# Module provides. 5 6if [ ! -e build/make/core/Makefile ]; then 7 echo "$0 must be run from the top of the tree" 8 exit 1 9fi 10 11skip_apex= 12skip_module_sdk= 13build_args=() 14for arg; do 15 case "$arg" in 16 --skip-apex) skip_apex=true ;; 17 --skip-module-sdk) skip_module_sdk=true ;; 18 *) build_args+=("$arg") ;; 19 esac 20 shift 21done 22 23MAINLINE_MODULES=() 24if [ -z "$skip_apex" ]; then 25 # Take the list of modules from MAINLINE_MODULES. 26 if [ -n "${MAINLINE_MODULES}" ]; then 27 read -r -a MAINLINE_MODULES <<< "${MAINLINE_MODULES}" 28 else 29 MAINLINE_MODULES=( 30 com.android.art 31 com.android.art.debug 32 ) 33 fi 34fi 35 36# Take the list of products to build the modules for from 37# MAINLINE_MODULE_PRODUCTS. 38if [ -n "${MAINLINE_MODULE_PRODUCTS}" ]; then 39 read -r -a MAINLINE_MODULE_PRODUCTS <<< "${MAINLINE_MODULE_PRODUCTS}" 40else 41 # The default products are the same as in 42 # build/soong/scripts/build-mainline-modules.sh. 43 MAINLINE_MODULE_PRODUCTS=( 44 art_module_arm 45 art_module_arm64 46 art_module_x86 47 art_module_x86_64 48 ) 49fi 50 51MODULE_SDKS_AND_EXPORTS=() 52if [ -z "$skip_module_sdk" ]; then 53 MODULE_SDKS_AND_EXPORTS=( 54 art-module-sdk 55 art-module-host-exports 56 art-module-test-exports 57 ) 58fi 59 60echo_and_run() { 61 echo "$*" 62 "$@" 63} 64 65export OUT_DIR=${OUT_DIR:-out} 66export DIST_DIR=${DIST_DIR:-${OUT_DIR}/dist} 67 68# Use same build settings as build_unbundled_mainline_module.sh, for build 69# consistency. 70# TODO(mast): Call out to a common script for building APEXes. 71export UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true 72export TARGET_BUILD_VARIANT=${TARGET_BUILD_VARIANT:-"user"} 73export TARGET_BUILD_DENSITY=alldpi 74export TARGET_BUILD_TYPE=release 75 76if [ ! -d frameworks/base ]; then 77 # Configure the build system for the reduced manifest branch. 78 export SOONG_ALLOW_MISSING_DEPENDENCIES=true 79fi 80 81if [ ${#MAINLINE_MODULES[*]} -gt 0 ]; then 82 ( 83 export TARGET_BUILD_APPS="${MAINLINE_MODULES[*]}" 84 85 # We require .apex files here, so ensure we get them regardless of product 86 # settings. 87 export OVERRIDE_TARGET_FLATTEN_APEX=false 88 89 for product in ${MAINLINE_MODULE_PRODUCTS[*]}; do 90 echo_and_run build/soong/soong_ui.bash --make-mode \ 91 TARGET_PRODUCT=${product} "${build_args[@]}" ${MAINLINE_MODULES[*]} 92 93 vars="$(TARGET_PRODUCT=${product} build/soong/soong_ui.bash \ 94 --dumpvars-mode --vars="PRODUCT_OUT TARGET_ARCH")" 95 # Assign to a variable and eval that, since bash ignores any error status 96 # from the command substitution if it's directly on the eval line. 97 eval $vars 98 99 mkdir -p ${DIST_DIR}/${TARGET_ARCH} 100 for module in ${MAINLINE_MODULES[*]}; do 101 echo_and_run cp ${PRODUCT_OUT}/system/apex/${module}.apex \ 102 ${DIST_DIR}/${TARGET_ARCH}/ 103 done 104 done 105 ) 106fi 107 108if [ ${#MODULE_SDKS_AND_EXPORTS[*]} -gt 0 ]; then 109 # Create multi-arch SDKs in a different out directory. The multi-arch script 110 # uses Soong in --skip-make mode which cannot use the same directory as normal 111 # mode with make. 112 export OUT_DIR=${OUT_DIR}/aml 113 114 # Put the build system in apps building mode so we don't trip on platform 115 # dependencies, but there are no actual apps to build here. 116 export TARGET_BUILD_APPS=none 117 118 # We use force building LLVM components flag (even though we actually don't 119 # compile them) because we don't have bionic host prebuilts 120 # for them. 121 export FORCE_BUILD_LLVM_COMPONENTS=true 122 123 echo_and_run build/soong/scripts/build-aml-prebuilts.sh \ 124 TARGET_PRODUCT=mainline_sdk "${build_args[@]}" ${MODULE_SDKS_AND_EXPORTS[*]} 125 126 rm -rf ${DIST_DIR}/mainline-sdks 127 mkdir -p ${DIST_DIR} 128 echo_and_run cp -r ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}/ 129fi 130