blob: 61338ca5964a748785b1645ebeb3af42a964eb0e [file] [log] [blame]
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +00001#!/bin/bash -e
2
3# This script builds the APEX modules, SDKs and module exports that the ART
4# Module provides.
5
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +00006if [ ! -e build/make/core/Makefile ]; then
7 echo "$0 must be run from the top of the tree"
8 exit 1
9fi
10
Martin Stjernholm62504802021-01-18 22:11:38 +000011skip_module_sdk=
12build_args=()
13for arg; do
14 case "$arg" in
15 --skip-module-sdk) skip_module_sdk=true ;;
16 *) build_args+=("$arg") ;;
17 esac
18 shift
19done
20
21# Take the list of modules from MAINLINE_MODULES.
22if [ -n "${MAINLINE_MODULES}" ]; then
23 read -r -a MAINLINE_MODULES <<< "${MAINLINE_MODULES}"
24else
25 MAINLINE_MODULES=(
26 com.android.art
27 com.android.art.debug
28 )
29fi
30
31# Take the list of products to build the modules for from
32# MAINLINE_MODULE_PRODUCTS.
33if [ -n "${MAINLINE_MODULE_PRODUCTS}" ]; then
34 read -r -a MAINLINE_MODULE_PRODUCTS <<< "${MAINLINE_MODULE_PRODUCTS}"
35else
36 # The default products are the same as in
37 # build/soong/scripts/build-mainline-modules.sh.
38 MAINLINE_MODULE_PRODUCTS=(
39 art_module_arm
40 art_module_arm64
41 art_module_x86
42 art_module_x86_64
43 )
44fi
45
46MODULE_SDKS_AND_EXPORTS=()
47if [ -z "$skip_module_sdk" ]; then
48 MODULE_SDKS_AND_EXPORTS=(
49 art-module-sdk
50 art-module-host-exports
51 art-module-test-exports
52 )
53fi
54
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000055echo_and_run() {
56 echo "$*"
57 "$@"
58}
59
60export OUT_DIR=${OUT_DIR:-out}
61export DIST_DIR=${DIST_DIR:-${OUT_DIR}/dist}
62
Martin Stjernholm62504802021-01-18 22:11:38 +000063# We require .apex files here, so ensure we get them regardless of product
64# settings.
65export OVERRIDE_TARGET_FLATTEN_APEX=false
66
Martin Stjernholmdaf11332021-01-21 00:46:36 +000067# Use same build settings as build_unbundled_mainline_module.sh, for build
68# consistency.
69# TODO(mast): Call out to a common script for building APEXes.
70export TARGET_BUILD_APPS="${MAINLINE_MODULES[*]}"
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
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000076if [ ! -d frameworks/base ]; then
Martin Stjernholmdaf11332021-01-21 00:46:36 +000077 # Configure the build system for the reduced manifest branch.
Martin Stjernholm23247752020-11-23 00:31:38 +000078 export SOONG_ALLOW_MISSING_DEPENDENCIES=true
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000079fi
80
Martin Stjernholm62504802021-01-18 22:11:38 +000081for product in ${MAINLINE_MODULE_PRODUCTS[*]}; do
Martin Stjernholm23247752020-11-23 00:31:38 +000082 echo_and_run build/soong/soong_ui.bash --make-mode \
Martin Stjernholm62504802021-01-18 22:11:38 +000083 TARGET_PRODUCT=${product} "${build_args[@]}" ${MAINLINE_MODULES[*]}
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000084
Martin Stjernholm23247752020-11-23 00:31:38 +000085 vars="$(TARGET_PRODUCT=${product} build/soong/soong_ui.bash --dumpvars-mode \
86 --vars="PRODUCT_OUT TARGET_ARCH")"
87 # Assign to a variable and eval that, since bash ignores any error status from
88 # the command substitution if it's directly on the eval line.
89 eval $vars
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000090
91 mkdir -p ${DIST_DIR}/${TARGET_ARCH}
92 for module in ${MAINLINE_MODULES[*]}; do
93 echo_and_run cp ${PRODUCT_OUT}/system/apex/${module}.apex \
94 ${DIST_DIR}/${TARGET_ARCH}/
95 done
96done
97
Martin Stjernholm62504802021-01-18 22:11:38 +000098if [ ${#MODULE_SDKS_AND_EXPORTS[*]} -gt 0 ]; then
99 # Create multi-arch SDKs in a different out directory. The multi-arch script
Pete Bentleye22c7a82021-01-29 15:14:42 +0000100 # uses Soong in --skip-make mode which cannot use the same directory as normal
Martin Stjernholm62504802021-01-18 22:11:38 +0000101 # mode with make.
102 export OUT_DIR=${OUT_DIR}/aml
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +0000103
Pete Bentleye22c7a82021-01-29 15:14:42 +0000104 # Make build-aml-prebuilts.sh set the source_build Soong config variable true.
105 export ENABLE_ART_SOURCE_BUILD=true
Martin Stjernholm10bb9c52020-12-01 22:53:51 +0000106
Pete Bentleye22c7a82021-01-29 15:14:42 +0000107 echo_and_run build/soong/scripts/build-aml-prebuilts.sh "${build_args[@]}" \
108 ${MODULE_SDKS_AND_EXPORTS[*]}
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +0000109
Martin Stjernholm62504802021-01-18 22:11:38 +0000110 rm -rf ${DIST_DIR}/mainline-sdks
111 echo_and_run cp -r ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}
112fi