blob: b73eacfb3284983b80266415a2c2d448ee682432 [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 Stjernholmb1cbfc72020-11-18 23:02:39 +000067if [ ! -d frameworks/base ]; then
Martin Stjernholm23247752020-11-23 00:31:38 +000068 # Configure the build system for the reduced manifest branch. These need to be
69 # passed through the environment since they have to be visible to the Soong
70 # --dumpvars-mode invocations.
71 export SOONG_ALLOW_MISSING_DEPENDENCIES=true
72 export TARGET_BUILD_UNBUNDLED=true
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000073fi
74
Martin Stjernholm62504802021-01-18 22:11:38 +000075for product in ${MAINLINE_MODULE_PRODUCTS[*]}; do
Martin Stjernholm23247752020-11-23 00:31:38 +000076 echo_and_run build/soong/soong_ui.bash --make-mode \
Martin Stjernholm62504802021-01-18 22:11:38 +000077 TARGET_PRODUCT=${product} "${build_args[@]}" ${MAINLINE_MODULES[*]}
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000078
Martin Stjernholm23247752020-11-23 00:31:38 +000079 vars="$(TARGET_PRODUCT=${product} build/soong/soong_ui.bash --dumpvars-mode \
80 --vars="PRODUCT_OUT TARGET_ARCH")"
81 # Assign to a variable and eval that, since bash ignores any error status from
82 # the command substitution if it's directly on the eval line.
83 eval $vars
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000084
85 mkdir -p ${DIST_DIR}/${TARGET_ARCH}
86 for module in ${MAINLINE_MODULES[*]}; do
87 echo_and_run cp ${PRODUCT_OUT}/system/apex/${module}.apex \
88 ${DIST_DIR}/${TARGET_ARCH}/
89 done
90done
91
Martin Stjernholm62504802021-01-18 22:11:38 +000092if [ ${#MODULE_SDKS_AND_EXPORTS[*]} -gt 0 ]; then
93 # Create multi-arch SDKs in a different out directory. The multi-arch script
Pete Bentleye22c7a82021-01-29 15:14:42 +000094 # uses Soong in --skip-make mode which cannot use the same directory as normal
Martin Stjernholm62504802021-01-18 22:11:38 +000095 # mode with make.
96 export OUT_DIR=${OUT_DIR}/aml
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000097
Pete Bentleye22c7a82021-01-29 15:14:42 +000098 # Make build-aml-prebuilts.sh set the source_build Soong config variable true.
99 export ENABLE_ART_SOURCE_BUILD=true
Martin Stjernholm10bb9c52020-12-01 22:53:51 +0000100
Pete Bentleye22c7a82021-01-29 15:14:42 +0000101 echo_and_run build/soong/scripts/build-aml-prebuilts.sh "${build_args[@]}" \
102 ${MODULE_SDKS_AND_EXPORTS[*]}
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +0000103
Martin Stjernholm62504802021-01-18 22:11:38 +0000104 rm -rf ${DIST_DIR}/mainline-sdks
105 echo_and_run cp -r ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}
106fi