blob: 81d7d477b1eed653a0ae607f8cea575dcf9a3301 [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
6MAINLINE_MODULES=(
7 com.android.art
8 com.android.art.debug
9)
10
11# The products to build MAINLINE_MODULES for, same as in
12# build/soong/scripts/build-mainline-modules.sh.
13PRODUCTS=(
14 aosp_arm
15 aosp_arm64
16 aosp_x86
17 aosp_x86_64
18)
19
20MODULES_SDK_AND_EXPORTS=(
21 art-module-sdk
22 art-module-host-exports
23 art-module-test-exports
24)
25
26# MAINLINE_MODULE_PRODUCTS can be used to override the list of products.
27if [ -n "${MAINLINE_MODULE_PRODUCTS}" ]; then
28 read -r -a PRODUCTS <<< "${MAINLINE_MODULE_PRODUCTS}"
29fi
30
31if [ ! -e build/make/core/Makefile ]; then
32 echo "$0 must be run from the top of the tree"
33 exit 1
34fi
35
36echo_and_run() {
37 echo "$*"
38 "$@"
39}
40
41export OUT_DIR=${OUT_DIR:-out}
42export DIST_DIR=${DIST_DIR:-${OUT_DIR}/dist}
43
44if [ ! -d frameworks/base ]; then
Martin Stjernholm23247752020-11-23 00:31:38 +000045 # Configure the build system for the reduced manifest branch. These need to be
46 # passed through the environment since they have to be visible to the Soong
47 # --dumpvars-mode invocations.
48 export SOONG_ALLOW_MISSING_DEPENDENCIES=true
49 export TARGET_BUILD_UNBUNDLED=true
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000050fi
51
52for product in ${PRODUCTS[*]}; do
Martin Stjernholm23247752020-11-23 00:31:38 +000053 echo_and_run build/soong/soong_ui.bash --make-mode \
54 TARGET_PRODUCT=${product} "$@" ${MAINLINE_MODULES[*]}
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000055
Martin Stjernholm23247752020-11-23 00:31:38 +000056 vars="$(TARGET_PRODUCT=${product} build/soong/soong_ui.bash --dumpvars-mode \
57 --vars="PRODUCT_OUT TARGET_ARCH")"
58 # Assign to a variable and eval that, since bash ignores any error status from
59 # the command substitution if it's directly on the eval line.
60 eval $vars
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000061
62 mkdir -p ${DIST_DIR}/${TARGET_ARCH}
63 for module in ${MAINLINE_MODULES[*]}; do
64 echo_and_run cp ${PRODUCT_OUT}/system/apex/${module}.apex \
65 ${DIST_DIR}/${TARGET_ARCH}/
66 done
67done
68
69# Create multi-archs SDKs in a different out directory. The multi-arch script
70# uses Soong in --skip-make mode which cannot use the same directory as normal
71# mode with make.
72export OUT_DIR=${OUT_DIR}/aml
73
Martin Stjernholm23247752020-11-23 00:31:38 +000074echo_and_run build/soong/scripts/build-aml-prebuilts.sh "$@" \
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000075 ${MODULES_SDK_AND_EXPORTS[*]}
76
77rm -rf ${DIST_DIR}/mainline-sdks
78echo_and_run cp -r ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}