blob: 2f546ec54d47c857ca338187485fdc5daf480385 [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
45 # Configure the build system for the reduced manifest branch.
46 build_args="SOONG_ALLOW_MISSING_DEPENDENCIES=true"
47 build_args="$build_args TARGET_BUILD_UNBUNDLED=true"
48fi
49
50for product in ${PRODUCTS[*]}; do
51 echo_and_run build/soong/soong_ui.bash --make-mode $build_args \
52 TARGET_PRODUCT=${product} ${MAINLINE_MODULES[*]}
53
54 eval $(TARGET_PRODUCT=${product} build/soong/soong_ui.bash --dumpvars-mode \
55 --vars="PRODUCT_OUT TARGET_ARCH")
56
57 mkdir -p ${DIST_DIR}/${TARGET_ARCH}
58 for module in ${MAINLINE_MODULES[*]}; do
59 echo_and_run cp ${PRODUCT_OUT}/system/apex/${module}.apex \
60 ${DIST_DIR}/${TARGET_ARCH}/
61 done
62done
63
64# Create multi-archs SDKs in a different out directory. The multi-arch script
65# uses Soong in --skip-make mode which cannot use the same directory as normal
66# mode with make.
67export OUT_DIR=${OUT_DIR}/aml
68
69echo_and_run build/soong/scripts/build-aml-prebuilts.sh $build_args \
70 ${MODULES_SDK_AND_EXPORTS[*]}
71
72rm -rf ${DIST_DIR}/mainline-sdks
73echo_and_run cp -r ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}