blob: a40959d00932b4fb74bb26ee1d4195872931a992 [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 Stjernholmab8bba92021-03-23 21:33:44 +000011skip_apex=
Martin Stjernholm62504802021-01-18 22:11:38 +000012skip_module_sdk=
13build_args=()
14for arg; do
15 case "$arg" in
Martin Stjernholmab8bba92021-03-23 21:33:44 +000016 --skip-apex) skip_apex=true ;;
Martin Stjernholm62504802021-01-18 22:11:38 +000017 --skip-module-sdk) skip_module_sdk=true ;;
18 *) build_args+=("$arg") ;;
19 esac
20 shift
21done
22
Martin Stjernholmab8bba92021-03-23 21:33:44 +000023if [ -z "$skip_apex" ]; then
24 # Take the list of modules from MAINLINE_MODULES.
25 if [ -n "${MAINLINE_MODULES}" ]; then
26 read -r -a MAINLINE_MODULES <<< "${MAINLINE_MODULES}"
27 else
28 MAINLINE_MODULES=(
29 com.android.art
30 com.android.art.debug
31 )
32 fi
Martin Stjernholme82d69a2021-06-08 16:44:57 +010033else
34 MAINLINE_MODULES=()
Martin Stjernholm62504802021-01-18 22:11:38 +000035fi
36
37# Take the list of products to build the modules for from
38# MAINLINE_MODULE_PRODUCTS.
39if [ -n "${MAINLINE_MODULE_PRODUCTS}" ]; then
40 read -r -a MAINLINE_MODULE_PRODUCTS <<< "${MAINLINE_MODULE_PRODUCTS}"
41else
42 # The default products are the same as in
43 # build/soong/scripts/build-mainline-modules.sh.
44 MAINLINE_MODULE_PRODUCTS=(
45 art_module_arm
46 art_module_arm64
47 art_module_x86
48 art_module_x86_64
49 )
50fi
51
52MODULE_SDKS_AND_EXPORTS=()
53if [ -z "$skip_module_sdk" ]; then
54 MODULE_SDKS_AND_EXPORTS=(
55 art-module-sdk
56 art-module-host-exports
57 art-module-test-exports
58 )
59fi
60
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000061echo_and_run() {
62 echo "$*"
63 "$@"
64}
65
66export OUT_DIR=${OUT_DIR:-out}
67export DIST_DIR=${DIST_DIR:-${OUT_DIR}/dist}
68
Martin Stjernholmdaf11332021-01-21 00:46:36 +000069# Use same build settings as build_unbundled_mainline_module.sh, for build
70# consistency.
71# TODO(mast): Call out to a common script for building APEXes.
Martin Stjernholmdaf11332021-01-21 00:46:36 +000072export UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true
73export TARGET_BUILD_VARIANT=${TARGET_BUILD_VARIANT:-"user"}
74export TARGET_BUILD_DENSITY=alldpi
75export TARGET_BUILD_TYPE=release
76
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000077if [ ! -d frameworks/base ]; then
Martin Stjernholmdaf11332021-01-21 00:46:36 +000078 # Configure the build system for the reduced manifest branch.
Martin Stjernholm23247752020-11-23 00:31:38 +000079 export SOONG_ALLOW_MISSING_DEPENDENCIES=true
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000080fi
81
Martin Stjernholmab8bba92021-03-23 21:33:44 +000082if [ ${#MAINLINE_MODULES[*]} -gt 0 ]; then
83 (
84 export TARGET_BUILD_APPS="${MAINLINE_MODULES[*]}"
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000085
Martin Stjernholmab8bba92021-03-23 21:33:44 +000086 # We require .apex files here, so ensure we get them regardless of product
87 # settings.
88 export OVERRIDE_TARGET_FLATTEN_APEX=false
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000089
Martin Stjernholmab8bba92021-03-23 21:33:44 +000090 for product in ${MAINLINE_MODULE_PRODUCTS[*]}; do
91 echo_and_run build/soong/soong_ui.bash --make-mode \
92 TARGET_PRODUCT=${product} "${build_args[@]}" ${MAINLINE_MODULES[*]}
93
94 vars="$(TARGET_PRODUCT=${product} build/soong/soong_ui.bash \
95 --dumpvars-mode --vars="PRODUCT_OUT TARGET_ARCH")"
96 # Assign to a variable and eval that, since bash ignores any error status
97 # from the command substitution if it's directly on the eval line.
98 eval $vars
99
100 mkdir -p ${DIST_DIR}/${TARGET_ARCH}
101 for module in ${MAINLINE_MODULES[*]}; do
102 echo_and_run cp ${PRODUCT_OUT}/system/apex/${module}.apex \
103 ${DIST_DIR}/${TARGET_ARCH}/
104 done
105 done
106 )
107fi
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +0000108
Martin Stjernholm62504802021-01-18 22:11:38 +0000109if [ ${#MODULE_SDKS_AND_EXPORTS[*]} -gt 0 ]; then
110 # Create multi-arch SDKs in a different out directory. The multi-arch script
Pete Bentleye22c7a82021-01-29 15:14:42 +0000111 # uses Soong in --skip-make mode which cannot use the same directory as normal
Martin Stjernholm62504802021-01-18 22:11:38 +0000112 # mode with make.
113 export OUT_DIR=${OUT_DIR}/aml
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +0000114
Martin Stjernholmab8bba92021-03-23 21:33:44 +0000115 # Put the build system in apps building mode so we don't trip on platform
116 # dependencies, but there are no actual apps to build here.
117 export TARGET_BUILD_APPS=none
118
Martin Stjernholmb89e7312021-06-07 23:53:41 +0100119 # We use force building LLVM components flag (even though we actually don't
120 # compile them) because we don't have bionic host prebuilts
121 # for them.
122 export FORCE_BUILD_LLVM_COMPONENTS=true
Martin Stjernholm10bb9c52020-12-01 22:53:51 +0000123
Martin Stjernholmb89e7312021-06-07 23:53:41 +0100124 echo_and_run build/soong/scripts/build-aml-prebuilts.sh \
125 TARGET_PRODUCT=mainline_sdk "${build_args[@]}" ${MODULE_SDKS_AND_EXPORTS[*]}
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +0000126
Martin Stjernholm62504802021-01-18 22:11:38 +0000127 rm -rf ${DIST_DIR}/mainline-sdks
Martin Stjernholm3cafbac2021-05-05 00:43:42 +0100128 mkdir -p ${DIST_DIR}
129 echo_and_run cp -r ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}/
Martin Stjernholm62504802021-01-18 22:11:38 +0000130fi