Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | |
| 3 | # This script builds the APEX modules, SDKs and module exports that the ART |
| 4 | # Module provides. |
| 5 | |
Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 6 | if [ ! -e build/make/core/Makefile ]; then |
| 7 | echo "$0 must be run from the top of the tree" |
| 8 | exit 1 |
| 9 | fi |
| 10 | |
Martin Stjernholm | ab8bba9 | 2021-03-23 21:33:44 +0000 | [diff] [blame] | 11 | skip_apex= |
Martin Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 12 | skip_module_sdk= |
| 13 | build_args=() |
| 14 | for arg; do |
| 15 | case "$arg" in |
Martin Stjernholm | ab8bba9 | 2021-03-23 21:33:44 +0000 | [diff] [blame] | 16 | --skip-apex) skip_apex=true ;; |
Martin Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 17 | --skip-module-sdk) skip_module_sdk=true ;; |
| 18 | *) build_args+=("$arg") ;; |
| 19 | esac |
| 20 | shift |
| 21 | done |
| 22 | |
Martin Stjernholm | ab8bba9 | 2021-03-23 21:33:44 +0000 | [diff] [blame] | 23 | MAINLINE_MODULES=() |
| 24 | if [ -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 Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 34 | fi |
| 35 | |
| 36 | # Take the list of products to build the modules for from |
| 37 | # MAINLINE_MODULE_PRODUCTS. |
| 38 | if [ -n "${MAINLINE_MODULE_PRODUCTS}" ]; then |
| 39 | read -r -a MAINLINE_MODULE_PRODUCTS <<< "${MAINLINE_MODULE_PRODUCTS}" |
| 40 | else |
| 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 | ) |
| 49 | fi |
| 50 | |
| 51 | MODULE_SDKS_AND_EXPORTS=() |
| 52 | if [ -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 | ) |
| 58 | fi |
| 59 | |
Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 60 | echo_and_run() { |
| 61 | echo "$*" |
| 62 | "$@" |
| 63 | } |
| 64 | |
| 65 | export OUT_DIR=${OUT_DIR:-out} |
| 66 | export DIST_DIR=${DIST_DIR:-${OUT_DIR}/dist} |
| 67 | |
Martin Stjernholm | daf1133 | 2021-01-21 00:46:36 +0000 | [diff] [blame] | 68 | # 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 Stjernholm | daf1133 | 2021-01-21 00:46:36 +0000 | [diff] [blame] | 71 | export UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true |
| 72 | export TARGET_BUILD_VARIANT=${TARGET_BUILD_VARIANT:-"user"} |
| 73 | export TARGET_BUILD_DENSITY=alldpi |
| 74 | export TARGET_BUILD_TYPE=release |
| 75 | |
Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 76 | if [ ! -d frameworks/base ]; then |
Martin Stjernholm | daf1133 | 2021-01-21 00:46:36 +0000 | [diff] [blame] | 77 | # Configure the build system for the reduced manifest branch. |
Martin Stjernholm | 2324775 | 2020-11-23 00:31:38 +0000 | [diff] [blame] | 78 | export SOONG_ALLOW_MISSING_DEPENDENCIES=true |
Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 79 | fi |
| 80 | |
Martin Stjernholm | ab8bba9 | 2021-03-23 21:33:44 +0000 | [diff] [blame] | 81 | if [ ${#MAINLINE_MODULES[*]} -gt 0 ]; then |
| 82 | ( |
| 83 | export TARGET_BUILD_APPS="${MAINLINE_MODULES[*]}" |
Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 84 | |
Martin Stjernholm | ab8bba9 | 2021-03-23 21:33:44 +0000 | [diff] [blame] | 85 | # We require .apex files here, so ensure we get them regardless of product |
| 86 | # settings. |
| 87 | export OVERRIDE_TARGET_FLATTEN_APEX=false |
Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 88 | |
Martin Stjernholm | ab8bba9 | 2021-03-23 21:33:44 +0000 | [diff] [blame] | 89 | 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 | ) |
| 106 | fi |
Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 107 | |
Martin Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 108 | if [ ${#MODULE_SDKS_AND_EXPORTS[*]} -gt 0 ]; then |
| 109 | # Create multi-arch SDKs in a different out directory. The multi-arch script |
Pete Bentley | e22c7a8 | 2021-01-29 15:14:42 +0000 | [diff] [blame] | 110 | # uses Soong in --skip-make mode which cannot use the same directory as normal |
Martin Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 111 | # mode with make. |
| 112 | export OUT_DIR=${OUT_DIR}/aml |
Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 113 | |
Martin Stjernholm | ab8bba9 | 2021-03-23 21:33:44 +0000 | [diff] [blame] | 114 | # 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 Stjernholm | c6b7866 | 2021-06-07 23:53:41 +0100 | [diff] [blame] | 118 | # 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 Stjernholm | 10bb9c5 | 2020-12-01 22:53:51 +0000 | [diff] [blame] | 122 | |
Martin Stjernholm | c6b7866 | 2021-06-07 23:53:41 +0100 | [diff] [blame] | 123 | echo_and_run build/soong/scripts/build-aml-prebuilts.sh \ |
| 124 | TARGET_PRODUCT=mainline_sdk "${build_args[@]}" ${MODULE_SDKS_AND_EXPORTS[*]} |
Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 125 | |
Martin Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 126 | rm -rf ${DIST_DIR}/mainline-sdks |
Martin Stjernholm | 3cafbac | 2021-05-05 00:43:42 +0100 | [diff] [blame] | 127 | mkdir -p ${DIST_DIR} |
| 128 | echo_and_run cp -r ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}/ |
Martin Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 129 | fi |