blob: 1e3f6ce787038f4304041c29dd00dd5eb4de1d21 [file] [log] [blame]
Martin Stjernholm691503e2020-05-06 22:03:26 +01001#!/bin/bash -e
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +00002
3# Non exhaustive list of modules where we want prebuilts. More can be added as
4# needed.
5MAINLINE_MODULES=(
Martin Stjernholm7f511072020-10-12 15:10:36 +01006 com.android.art
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +00007 com.android.art.debug
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +00008 com.android.art.testing
9 com.android.conscrypt
Martin Stjernholm7f511072020-10-12 15:10:36 +010010 com.android.i18n
Eric Holk277b0e72021-02-17 13:00:41 -080011 com.android.os.statsd
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +000012 com.android.runtime
13 com.android.tzdata
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +000014)
15
16# List of SDKs and module exports we know of.
17MODULES_SDK_AND_EXPORTS=(
18 art-module-sdk
19 art-module-test-exports
Martin Stjernholm4c13f582020-11-11 12:49:03 +000020 conscrypt-module-host-exports
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +000021 conscrypt-module-sdk
22 conscrypt-module-test-exports
Martin Stjernholm4c13f582020-11-11 12:49:03 +000023 i18n-module-host-exports
Nicolas Geoffray7505c502020-06-18 15:33:18 +010024 i18n-module-sdk
Martin Stjernholm4c13f582020-11-11 12:49:03 +000025 i18n-module-test-exports
Nicolas Geoffray792ea732020-06-26 14:44:32 +010026 platform-mainline-sdk
Nicolas Geoffrayb0df23f2020-08-05 15:56:09 +010027 platform-mainline-test-exports
Martin Stjernholm4c13f582020-11-11 12:49:03 +000028 runtime-module-host-exports
29 runtime-module-sdk
Eric Holk7529f062021-02-11 02:06:32 +000030 statsd-module-sdk
Nicolas Geoffrayc1b16632021-01-11 09:45:57 +000031 tzdata-module-test-exports
Nicolas Geoffray792ea732020-06-26 14:44:32 +010032)
33
34# List of libraries installed on the platform that are needed for ART chroot
35# testing.
36PLATFORM_LIBRARIES=(
Martin Stjernholm4f0f3f02021-03-09 17:13:51 +000037 heapprofd_client_api
Nicolas Geoffray792ea732020-06-26 14:44:32 +010038 libartpalette-system
Martin Stjernholm4f0f3f02021-03-09 17:13:51 +000039 liblog
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +000040)
41
42# We want to create apex modules for all supported architectures.
43PRODUCTS=(
Martin Stjernholm691503e2020-05-06 22:03:26 +010044 aosp_arm
45 aosp_arm64
46 aosp_x86
47 aosp_x86_64
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +000048)
49
50if [ ! -e "build/make/core/Makefile" ]; then
Martin Stjernholm691503e2020-05-06 22:03:26 +010051 echo "$0 must be run from the top of the tree"
52 exit 1
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +000053fi
54
Martin Stjernholm691503e2020-05-06 22:03:26 +010055echo_and_run() {
56 echo "$*"
57 "$@"
58}
59
Nicolas Geoffrayf23054f2020-07-31 15:36:39 +010060lib_dir() {
61 case $1 in
62 (aosp_arm|aosp_x86) echo "lib";;
63 (aosp_arm64|aosp_x86_64) echo "lib64";;
64 esac
65}
66
Martin Stjernholmbd396b62021-02-02 16:20:45 +000067# Make sure this build builds from source, regardless of the default.
68export SOONG_CONFIG_art_module_source_build=true
69
Samiul Islamd3654492021-06-02 15:23:37 +010070# This script does not intend to handle compressed APEX
71export OVERRIDE_PRODUCT_COMPRESSED_APEX=false
72
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +000073OUT_DIR=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT= get_build_var OUT_DIR)
74DIST_DIR=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT= get_build_var DIST_DIR)
75
76for product in "${PRODUCTS[@]}"; do
Martin Stjernholm691503e2020-05-06 22:03:26 +010077 echo_and_run build/soong/soong_ui.bash --make-mode $@ \
78 TARGET_PRODUCT=${product} \
Nicolas Geoffray792ea732020-06-26 14:44:32 +010079 ${MAINLINE_MODULES[@]} \
80 ${PLATFORM_LIBRARIES[@]}
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +000081
Martin Stjernholm691503e2020-05-06 22:03:26 +010082 PRODUCT_OUT=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT=${product} get_build_var PRODUCT_OUT)
83 TARGET_ARCH=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT=${product} get_build_var TARGET_ARCH)
84 rm -rf ${DIST_DIR}/${TARGET_ARCH}/
85 mkdir -p ${DIST_DIR}/${TARGET_ARCH}/
86 for module in "${MAINLINE_MODULES[@]}"; do
87 echo_and_run cp ${PWD}/${PRODUCT_OUT}/system/apex/${module}.apex ${DIST_DIR}/${TARGET_ARCH}/
88 done
Nicolas Geoffray792ea732020-06-26 14:44:32 +010089 for library in "${PLATFORM_LIBRARIES[@]}"; do
Nicolas Geoffrayf23054f2020-07-31 15:36:39 +010090 libdir=$(lib_dir $product)
91 echo_and_run cp ${PWD}/${PRODUCT_OUT}/system/${libdir}/${library}.so ${DIST_DIR}/${TARGET_ARCH}/
Nicolas Geoffray792ea732020-06-26 14:44:32 +010092 done
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +000093done
94
Martin Stjernholm040e0442021-06-07 23:18:56 +010095# We use force building LLVM components flag (even though we actually don't
96# compile them) because we don't have bionic host prebuilts
97# for them.
98export FORCE_BUILD_LLVM_COMPONENTS=true
99
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +0000100# Create multi-archs SDKs in a different out directory. The multi-arch script
Colin Cross34d60c92021-10-28 16:19:40 -0700101# uses Soong in --soong-only mode which cannot use the same directory as normal
Martin Stjernholm691503e2020-05-06 22:03:26 +0100102# mode with make.
103export OUT_DIR=${OUT_DIR}/aml
Martin Stjernholm040e0442021-06-07 23:18:56 +0100104echo_and_run build/soong/scripts/build-aml-prebuilts.sh \
105 TARGET_PRODUCT=mainline_sdk ${MODULES_SDK_AND_EXPORTS[@]}
Nicolas Geoffray90bc3cd2020-02-28 09:04:25 +0000106
107rm -rf ${DIST_DIR}/mainline-sdks
Martin Stjernholm691503e2020-05-06 22:03:26 +0100108echo_and_run cp -R ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}