| 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 | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 11 | skip_module_sdk= |
| 12 | build_args=() |
| 13 | for arg; do |
| 14 | case "$arg" in |
| 15 | --skip-module-sdk) skip_module_sdk=true ;; |
| 16 | *) build_args+=("$arg") ;; |
| 17 | esac |
| 18 | shift |
| 19 | done |
| 20 | |
| 21 | # Take the list of modules from MAINLINE_MODULES. |
| 22 | if [ -n "${MAINLINE_MODULES}" ]; then |
| 23 | read -r -a MAINLINE_MODULES <<< "${MAINLINE_MODULES}" |
| 24 | else |
| 25 | MAINLINE_MODULES=( |
| 26 | com.android.art |
| 27 | com.android.art.debug |
| 28 | ) |
| 29 | fi |
| 30 | |
| 31 | # Take the list of products to build the modules for from |
| 32 | # MAINLINE_MODULE_PRODUCTS. |
| 33 | if [ -n "${MAINLINE_MODULE_PRODUCTS}" ]; then |
| 34 | read -r -a MAINLINE_MODULE_PRODUCTS <<< "${MAINLINE_MODULE_PRODUCTS}" |
| 35 | else |
| 36 | # The default products are the same as in |
| 37 | # build/soong/scripts/build-mainline-modules.sh. |
| 38 | MAINLINE_MODULE_PRODUCTS=( |
| 39 | art_module_arm |
| 40 | art_module_arm64 |
| 41 | art_module_x86 |
| 42 | art_module_x86_64 |
| 43 | ) |
| 44 | fi |
| 45 | |
| 46 | MODULE_SDKS_AND_EXPORTS=() |
| 47 | if [ -z "$skip_module_sdk" ]; then |
| 48 | MODULE_SDKS_AND_EXPORTS=( |
| 49 | art-module-sdk |
| 50 | art-module-host-exports |
| 51 | art-module-test-exports |
| 52 | ) |
| 53 | fi |
| 54 | |
| Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 55 | echo_and_run() { |
| 56 | echo "$*" |
| 57 | "$@" |
| 58 | } |
| 59 | |
| 60 | export OUT_DIR=${OUT_DIR:-out} |
| 61 | export DIST_DIR=${DIST_DIR:-${OUT_DIR}/dist} |
| 62 | |
| Martin Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 63 | # We require .apex files here, so ensure we get them regardless of product |
| 64 | # settings. |
| 65 | export OVERRIDE_TARGET_FLATTEN_APEX=false |
| 66 | |
| Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 67 | if [ ! -d frameworks/base ]; then |
| Martin Stjernholm | 2324775 | 2020-11-23 00:31:38 +0000 | [diff] [blame] | 68 | # Configure the build system for the reduced manifest branch. These need to be |
| 69 | # passed through the environment since they have to be visible to the Soong |
| 70 | # --dumpvars-mode invocations. |
| 71 | export SOONG_ALLOW_MISSING_DEPENDENCIES=true |
| 72 | export TARGET_BUILD_UNBUNDLED=true |
| Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 73 | fi |
| 74 | |
| Martin Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 75 | for product in ${MAINLINE_MODULE_PRODUCTS[*]}; do |
| Martin Stjernholm | 2324775 | 2020-11-23 00:31:38 +0000 | [diff] [blame] | 76 | echo_and_run build/soong/soong_ui.bash --make-mode \ |
| Martin Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 77 | TARGET_PRODUCT=${product} "${build_args[@]}" ${MAINLINE_MODULES[*]} |
| Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 78 | |
| Martin Stjernholm | 2324775 | 2020-11-23 00:31:38 +0000 | [diff] [blame] | 79 | vars="$(TARGET_PRODUCT=${product} build/soong/soong_ui.bash --dumpvars-mode \ |
| 80 | --vars="PRODUCT_OUT TARGET_ARCH")" |
| 81 | # Assign to a variable and eval that, since bash ignores any error status from |
| 82 | # the command substitution if it's directly on the eval line. |
| 83 | eval $vars |
| Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 84 | |
| 85 | mkdir -p ${DIST_DIR}/${TARGET_ARCH} |
| 86 | for module in ${MAINLINE_MODULES[*]}; do |
| 87 | echo_and_run cp ${PRODUCT_OUT}/system/apex/${module}.apex \ |
| 88 | ${DIST_DIR}/${TARGET_ARCH}/ |
| 89 | done |
| 90 | done |
| 91 | |
| Martin Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 92 | if [ ${#MODULE_SDKS_AND_EXPORTS[*]} -gt 0 ]; then |
| 93 | # 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^] | 94 | # 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] | 95 | # mode with make. |
| 96 | export OUT_DIR=${OUT_DIR}/aml |
| Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 97 | |
| Pete Bentley | e22c7a8 | 2021-01-29 15:14:42 +0000 | [diff] [blame^] | 98 | # Make build-aml-prebuilts.sh set the source_build Soong config variable true. |
| 99 | export ENABLE_ART_SOURCE_BUILD=true |
| Martin Stjernholm | 10bb9c5 | 2020-12-01 22:53:51 +0000 | [diff] [blame] | 100 | |
| Pete Bentley | e22c7a8 | 2021-01-29 15:14:42 +0000 | [diff] [blame^] | 101 | echo_and_run build/soong/scripts/build-aml-prebuilts.sh "${build_args[@]}" \ |
| 102 | ${MODULE_SDKS_AND_EXPORTS[*]} |
| Martin Stjernholm | b1cbfc7 | 2020-11-18 23:02:39 +0000 | [diff] [blame] | 103 | |
| Martin Stjernholm | 6250480 | 2021-01-18 22:11:38 +0000 | [diff] [blame] | 104 | rm -rf ${DIST_DIR}/mainline-sdks |
| 105 | echo_and_run cp -r ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR} |
| 106 | fi |