blob: bc6f2662207b25cfb992dbae5eec9c9e5d9b8bd5 [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 +000023MAINLINE_MODULES=()
24if [ -z "$skip_apex" ]; then
25 # Take the list of modules from MAINLINE_MODULES.
26 if [ -n "${MAINLINE_MODULES}" ]; then
27 read -r -a MAINLINE_MODULES <<< "${MAINLINE_MODULES}"
28 else
29 MAINLINE_MODULES=(
30 com.android.art
31 com.android.art.debug
32 )
33 fi
Martin Stjernholm62504802021-01-18 22:11:38 +000034fi
35
36# Take the list of products to build the modules for from
37# MAINLINE_MODULE_PRODUCTS.
38if [ -n "${MAINLINE_MODULE_PRODUCTS}" ]; then
39 read -r -a MAINLINE_MODULE_PRODUCTS <<< "${MAINLINE_MODULE_PRODUCTS}"
40else
41 # The default products are the same as in
42 # build/soong/scripts/build-mainline-modules.sh.
43 MAINLINE_MODULE_PRODUCTS=(
44 art_module_arm
45 art_module_arm64
46 art_module_x86
47 art_module_x86_64
48 )
49fi
50
51MODULE_SDKS_AND_EXPORTS=()
52if [ -z "$skip_module_sdk" ]; then
53 MODULE_SDKS_AND_EXPORTS=(
54 art-module-sdk
55 art-module-host-exports
56 art-module-test-exports
57 )
58fi
59
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000060echo_and_run() {
61 echo "$*"
62 "$@"
63}
64
65export OUT_DIR=${OUT_DIR:-out}
66export DIST_DIR=${DIST_DIR:-${OUT_DIR}/dist}
67
Martin Stjernholmdaf11332021-01-21 00:46:36 +000068# Use same build settings as build_unbundled_mainline_module.sh, for build
69# consistency.
70# TODO(mast): Call out to a common script for building APEXes.
Martin Stjernholmdaf11332021-01-21 00:46:36 +000071export 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 Stjernholmab8bba92021-03-23 21:33:44 +000081if [ ${#MAINLINE_MODULES[*]} -gt 0 ]; then
82 (
83 export TARGET_BUILD_APPS="${MAINLINE_MODULES[*]}"
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000084
Martin Stjernholmab8bba92021-03-23 21:33:44 +000085 # We require .apex files here, so ensure we get them regardless of product
86 # settings.
87 export OVERRIDE_TARGET_FLATTEN_APEX=false
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +000088
Martin Stjernholmab8bba92021-03-23 21:33:44 +000089 for product in ${MAINLINE_MODULE_PRODUCTS[*]}; do
90 echo_and_run build/soong/soong_ui.bash --make-mode \
91 TARGET_PRODUCT=${product} "${build_args[@]}" ${MAINLINE_MODULES[*]}
92
93 vars="$(TARGET_PRODUCT=${product} build/soong/soong_ui.bash \
94 --dumpvars-mode --vars="PRODUCT_OUT TARGET_ARCH")"
95 # Assign to a variable and eval that, since bash ignores any error status
96 # from the command substitution if it's directly on the eval line.
97 eval $vars
98
99 mkdir -p ${DIST_DIR}/${TARGET_ARCH}
100 for module in ${MAINLINE_MODULES[*]}; do
101 echo_and_run cp ${PRODUCT_OUT}/system/apex/${module}.apex \
102 ${DIST_DIR}/${TARGET_ARCH}/
103 done
104 done
105 )
106fi
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +0000107
Martin Stjernholm62504802021-01-18 22:11:38 +0000108if [ ${#MODULE_SDKS_AND_EXPORTS[*]} -gt 0 ]; then
109 # Create multi-arch SDKs in a different out directory. The multi-arch script
Pete Bentleye22c7a82021-01-29 15:14:42 +0000110 # uses Soong in --skip-make mode which cannot use the same directory as normal
Martin Stjernholm62504802021-01-18 22:11:38 +0000111 # mode with make.
112 export OUT_DIR=${OUT_DIR}/aml
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +0000113
Martin Stjernholmab8bba92021-03-23 21:33:44 +0000114 # Put the build system in apps building mode so we don't trip on platform
115 # dependencies, but there are no actual apps to build here.
116 export TARGET_BUILD_APPS=none
117
Martin Stjernholmc6b78662021-06-07 23:53:41 +0100118 # We use force building LLVM components flag (even though we actually don't
119 # compile them) because we don't have bionic host prebuilts
120 # for them.
121 export FORCE_BUILD_LLVM_COMPONENTS=true
Martin Stjernholm10bb9c52020-12-01 22:53:51 +0000122
Martin Stjernholmc6b78662021-06-07 23:53:41 +0100123 echo_and_run build/soong/scripts/build-aml-prebuilts.sh \
124 TARGET_PRODUCT=mainline_sdk "${build_args[@]}" ${MODULE_SDKS_AND_EXPORTS[*]}
Martin Stjernholmb1cbfc72020-11-18 23:02:39 +0000125
Martin Stjernholm62504802021-01-18 22:11:38 +0000126 rm -rf ${DIST_DIR}/mainline-sdks
Martin Stjernholm3cafbac2021-05-05 00:43:42 +0100127 mkdir -p ${DIST_DIR}
128 echo_and_run cp -r ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}/
Martin Stjernholm62504802021-01-18 22:11:38 +0000129fi