Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 3 | # This is a wrapper around "m" that builds the given modules in multi-arch mode |
| 4 | # for all architectures supported by Mainline modules. The make (kati) stage is |
| 5 | # skipped, so the build targets in the arguments can only be Soong modules or |
| 6 | # intermediate output files - make targets and normal installed paths are not |
| 7 | # supported. |
| 8 | # |
| 9 | # This script is typically used with "sdk" or "module_export" modules, which |
| 10 | # Soong will install in $OUT_DIR/soong/mainline-sdks (cf |
| 11 | # PathForMainlineSdksInstall in android/paths.go). |
| 12 | |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 13 | export OUT_DIR=${OUT_DIR:-out} |
| 14 | |
Jingwen Chen | cda22c9 | 2020-11-23 00:22:30 -0500 | [diff] [blame] | 15 | if [ -e ${OUT_DIR}/soong/.soong.kati_enabled ]; then |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 16 | # If ${OUT_DIR} has been created without --skip-make, Soong will create an |
| 17 | # ${OUT_DIR}/soong/build.ninja that leaves out many targets which are |
| 18 | # expected to be supplied by the .mk files, and that might cause errors in |
| 19 | # "m --skip-make" below. We therefore default to a different out dir |
| 20 | # location in that case. |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 21 | AML_OUT_DIR=out/aml |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 22 | echo "Avoiding in-make OUT_DIR '${OUT_DIR}' - building in '${AML_OUT_DIR}' instead" |
| 23 | OUT_DIR=${AML_OUT_DIR} |
| 24 | fi |
| 25 | |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 26 | if [ ! -e "build/envsetup.sh" ]; then |
| 27 | echo "$0 must be run from the top of the tree" |
| 28 | exit 1 |
| 29 | fi |
| 30 | |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 31 | source build/envsetup.sh |
| 32 | |
| 33 | my_get_build_var() { |
| 34 | # get_build_var will run Soong in normal in-make mode where it creates |
Jingwen Chen | cda22c9 | 2020-11-23 00:22:30 -0500 | [diff] [blame] | 35 | # .soong.kati_enabled. That would clobber our real out directory, so we need |
| 36 | # to run it in a different one. |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 37 | OUT_DIR=${OUT_DIR}/get_build_var get_build_var "$@" |
| 38 | } |
| 39 | |
Martin Stjernholm | c488743 | 2020-11-05 12:59:02 +0000 | [diff] [blame] | 40 | readonly SOONG_OUT=${OUT_DIR}/soong |
| 41 | mkdir -p ${SOONG_OUT} |
| 42 | |
| 43 | # Some Soong build rules may require this, and the failure mode if it's missing |
| 44 | # is confusing (b/172548608). |
| 45 | readonly BUILD_NUMBER="$(my_get_build_var BUILD_NUMBER)" |
| 46 | echo -n ${BUILD_NUMBER} > ${SOONG_OUT}/build_number.txt |
| 47 | |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 48 | readonly PLATFORM_SDK_VERSION="$(my_get_build_var PLATFORM_SDK_VERSION)" |
| 49 | readonly PLATFORM_VERSION="$(my_get_build_var PLATFORM_VERSION)" |
| 50 | PLATFORM_VERSION_ALL_CODENAMES="$(my_get_build_var PLATFORM_VERSION_ALL_CODENAMES)" |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 51 | |
| 52 | # PLATFORM_VERSION_ALL_CODENAMES is a comma separated list like O,P. We need to |
| 53 | # turn this into ["O","P"]. |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 54 | PLATFORM_VERSION_ALL_CODENAMES="${PLATFORM_VERSION_ALL_CODENAMES/,/'","'}" |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 55 | PLATFORM_VERSION_ALL_CODENAMES="[\"${PLATFORM_VERSION_ALL_CODENAMES}\"]" |
| 56 | |
| 57 | # Logic from build/make/core/goma.mk |
| 58 | if [ "${USE_GOMA}" = true ]; then |
| 59 | if [ -n "${GOMA_DIR}" ]; then |
| 60 | goma_dir="${GOMA_DIR}" |
| 61 | else |
| 62 | goma_dir="${HOME}/goma" |
| 63 | fi |
| 64 | GOMA_CC="${goma_dir}/gomacc" |
| 65 | export CC_WRAPPER="${CC_WRAPPER}${CC_WRAPPER:+ }${GOMA_CC}" |
| 66 | export CXX_WRAPPER="${CXX_WRAPPER}${CXX_WRAPPER:+ }${GOMA_CC}" |
| 67 | export JAVAC_WRAPPER="${JAVAC_WRAPPER}${JAVAC_WRAPPER:+ }${GOMA_CC}" |
| 68 | else |
| 69 | USE_GOMA=false |
| 70 | fi |
| 71 | |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 72 | readonly SOONG_VARS=${SOONG_OUT}/soong.variables |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 73 | |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 74 | # Aml_abis: true |
| 75 | # - This flag configures Soong to compile for all architectures required for |
| 76 | # Mainline modules. |
| 77 | # CrossHost: linux_bionic |
| 78 | # CrossHostArch: x86_64 |
| 79 | # - Enable Bionic on host as ART needs prebuilts for it. |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 80 | cat > ${SOONG_VARS}.new << EOF |
| 81 | { |
Martin Stjernholm | c488743 | 2020-11-05 12:59:02 +0000 | [diff] [blame] | 82 | "BuildNumberFile": "build_number.txt", |
| 83 | |
Martin Stjernholm | 6f8fecd | 2020-12-14 15:06:22 +0000 | [diff] [blame^] | 84 | "Platform_version_name": "${PLATFORM_VERSION}", |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 85 | "Platform_sdk_version": ${PLATFORM_SDK_VERSION}, |
| 86 | "Platform_sdk_codename": "${PLATFORM_VERSION}", |
| 87 | "Platform_version_active_codenames": ${PLATFORM_VERSION_ALL_CODENAMES}, |
| 88 | |
| 89 | "DeviceName": "generic_arm64", |
| 90 | "HostArch": "x86_64", |
Nicolas Geoffray | abdc8c5 | 2020-03-24 11:39:06 +0000 | [diff] [blame] | 91 | "HostSecondaryArch": "x86", |
Nicolas Geoffray | 71233e4 | 2020-04-25 16:25:21 +0100 | [diff] [blame] | 92 | "CrossHost": "linux_bionic", |
| 93 | "CrossHostArch": "x86_64", |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 94 | "Aml_abis": true, |
| 95 | |
Martin Stjernholm | 2829f6c | 2020-08-11 01:41:20 +0100 | [diff] [blame] | 96 | "Allow_missing_dependencies": ${SOONG_ALLOW_MISSING_DEPENDENCIES:-false}, |
| 97 | "Unbundled_build": ${TARGET_BUILD_UNBUNDLED:-false}, |
Martin Stjernholm | f371381 | 2020-12-01 18:00:52 +0000 | [diff] [blame] | 98 | "UseGoma": ${USE_GOMA}, |
| 99 | |
| 100 | "VendorVars": { |
| 101 | "art_module": { |
| 102 | "source_build": "${ENABLE_ART_SOURCE_BUILD:-false}" |
| 103 | } |
| 104 | } |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 105 | } |
| 106 | EOF |
| 107 | |
| 108 | if [ -f ${SOONG_VARS} ] && cmp -s ${SOONG_VARS} ${SOONG_VARS}.new; then |
| 109 | # Don't touch soong.variables if we don't have to, to avoid Soong rebuilding |
| 110 | # the ninja file when it isn't necessary. |
| 111 | rm ${SOONG_VARS}.new |
| 112 | else |
| 113 | mv ${SOONG_VARS}.new ${SOONG_VARS} |
| 114 | fi |
| 115 | |
Nicolas Geoffray | 7cad0f8 | 2020-04-28 15:53:42 +0100 | [diff] [blame] | 116 | # We use force building LLVM components flag (even though we actually don't |
| 117 | # compile them) because we don't have bionic host prebuilts |
| 118 | # for them. |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 119 | export FORCE_BUILD_LLVM_COMPONENTS=true |
| 120 | |
| 121 | m --skip-make "$@" |