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 | |
| 15 | if [ -e ${OUT_DIR}/soong/.soong.in_make ]; then |
| 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 |
| 35 | # .soong.in_make. That would clobber our real out directory, so we need to |
| 36 | # run it in a different one. |
| 37 | OUT_DIR=${OUT_DIR}/get_build_var get_build_var "$@" |
| 38 | } |
| 39 | |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 40 | readonly PLATFORM_SDK_VERSION="$(my_get_build_var PLATFORM_SDK_VERSION)" |
| 41 | readonly PLATFORM_VERSION="$(my_get_build_var PLATFORM_VERSION)" |
| 42 | PLATFORM_VERSION_ALL_CODENAMES="$(my_get_build_var PLATFORM_VERSION_ALL_CODENAMES)" |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 43 | |
| 44 | # PLATFORM_VERSION_ALL_CODENAMES is a comma separated list like O,P. We need to |
| 45 | # turn this into ["O","P"]. |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 46 | PLATFORM_VERSION_ALL_CODENAMES="${PLATFORM_VERSION_ALL_CODENAMES/,/'","'}" |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 47 | PLATFORM_VERSION_ALL_CODENAMES="[\"${PLATFORM_VERSION_ALL_CODENAMES}\"]" |
| 48 | |
| 49 | # Logic from build/make/core/goma.mk |
| 50 | if [ "${USE_GOMA}" = true ]; then |
| 51 | if [ -n "${GOMA_DIR}" ]; then |
| 52 | goma_dir="${GOMA_DIR}" |
| 53 | else |
| 54 | goma_dir="${HOME}/goma" |
| 55 | fi |
| 56 | GOMA_CC="${goma_dir}/gomacc" |
| 57 | export CC_WRAPPER="${CC_WRAPPER}${CC_WRAPPER:+ }${GOMA_CC}" |
| 58 | export CXX_WRAPPER="${CXX_WRAPPER}${CXX_WRAPPER:+ }${GOMA_CC}" |
| 59 | export JAVAC_WRAPPER="${JAVAC_WRAPPER}${JAVAC_WRAPPER:+ }${GOMA_CC}" |
| 60 | else |
| 61 | USE_GOMA=false |
| 62 | fi |
| 63 | |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 64 | readonly SOONG_OUT=${OUT_DIR}/soong |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 65 | mkdir -p ${SOONG_OUT} |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 66 | readonly SOONG_VARS=${SOONG_OUT}/soong.variables |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 67 | |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 68 | # Aml_abis: true |
| 69 | # - This flag configures Soong to compile for all architectures required for |
| 70 | # Mainline modules. |
| 71 | # CrossHost: linux_bionic |
| 72 | # CrossHostArch: x86_64 |
| 73 | # - Enable Bionic on host as ART needs prebuilts for it. |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 74 | cat > ${SOONG_VARS}.new << EOF |
| 75 | { |
| 76 | "Platform_sdk_version": ${PLATFORM_SDK_VERSION}, |
| 77 | "Platform_sdk_codename": "${PLATFORM_VERSION}", |
| 78 | "Platform_version_active_codenames": ${PLATFORM_VERSION_ALL_CODENAMES}, |
| 79 | |
| 80 | "DeviceName": "generic_arm64", |
| 81 | "HostArch": "x86_64", |
Nicolas Geoffray | abdc8c5 | 2020-03-24 11:39:06 +0000 | [diff] [blame] | 82 | "HostSecondaryArch": "x86", |
Nicolas Geoffray | 71233e4 | 2020-04-25 16:25:21 +0100 | [diff] [blame] | 83 | "CrossHost": "linux_bionic", |
| 84 | "CrossHostArch": "x86_64", |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 85 | "Aml_abis": true, |
| 86 | |
Martin Stjernholm | 2829f6c | 2020-08-11 01:41:20 +0100 | [diff] [blame] | 87 | "Allow_missing_dependencies": ${SOONG_ALLOW_MISSING_DEPENDENCIES:-false}, |
| 88 | "Unbundled_build": ${TARGET_BUILD_UNBUNDLED:-false}, |
Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 89 | "UseGoma": ${USE_GOMA} |
| 90 | } |
| 91 | EOF |
| 92 | |
| 93 | if [ -f ${SOONG_VARS} ] && cmp -s ${SOONG_VARS} ${SOONG_VARS}.new; then |
| 94 | # Don't touch soong.variables if we don't have to, to avoid Soong rebuilding |
| 95 | # the ninja file when it isn't necessary. |
| 96 | rm ${SOONG_VARS}.new |
| 97 | else |
| 98 | mv ${SOONG_VARS}.new ${SOONG_VARS} |
| 99 | fi |
| 100 | |
Nicolas Geoffray | 7cad0f8 | 2020-04-28 15:53:42 +0100 | [diff] [blame] | 101 | # We use force building LLVM components flag (even though we actually don't |
| 102 | # compile them) because we don't have bionic host prebuilts |
| 103 | # for them. |
Martin Stjernholm | 691503e | 2020-05-06 22:03:26 +0100 | [diff] [blame] | 104 | export FORCE_BUILD_LLVM_COMPONENTS=true |
| 105 | |
| 106 | m --skip-make "$@" |