Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | |
| 3 | export OUT_DIR=${OUT_DIR:-out} |
| 4 | |
| 5 | if [ -e ${OUT_DIR}/soong/.soong.in_make ]; then |
| 6 | # If ${OUT_DIR} has been created without --skip-make, Soong will create an |
| 7 | # ${OUT_DIR}/soong/build.ninja that leaves out many targets which are |
| 8 | # expected to be supplied by the .mk files, and that might cause errors in |
| 9 | # "m --skip-make" below. We therefore default to a different out dir |
| 10 | # location in that case. |
| 11 | AML_OUT_DIR=out-aml |
| 12 | echo "Avoiding in-make OUT_DIR '${OUT_DIR}' - building in '${AML_OUT_DIR}' instead" |
| 13 | OUT_DIR=${AML_OUT_DIR} |
| 14 | fi |
| 15 | |
| 16 | source build/envsetup.sh |
| 17 | |
| 18 | my_get_build_var() { |
| 19 | # get_build_var will run Soong in normal in-make mode where it creates |
| 20 | # .soong.in_make. That would clobber our real out directory, so we need to |
| 21 | # run it in a different one. |
| 22 | OUT_DIR=${OUT_DIR}/get_build_var get_build_var "$@" |
| 23 | } |
| 24 | |
| 25 | PLATFORM_SDK_VERSION=$(my_get_build_var PLATFORM_SDK_VERSION) |
| 26 | PLATFORM_VERSION=$(my_get_build_var PLATFORM_VERSION) |
| 27 | PLATFORM_VERSION_ALL_CODENAMES=$(my_get_build_var PLATFORM_VERSION_ALL_CODENAMES) |
| 28 | |
| 29 | # PLATFORM_VERSION_ALL_CODENAMES is a comma separated list like O,P. We need to |
| 30 | # turn this into ["O","P"]. |
| 31 | PLATFORM_VERSION_ALL_CODENAMES=${PLATFORM_VERSION_ALL_CODENAMES/,/'","'} |
| 32 | PLATFORM_VERSION_ALL_CODENAMES="[\"${PLATFORM_VERSION_ALL_CODENAMES}\"]" |
| 33 | |
| 34 | # Logic from build/make/core/goma.mk |
| 35 | if [ "${USE_GOMA}" = true ]; then |
| 36 | if [ -n "${GOMA_DIR}" ]; then |
| 37 | goma_dir="${GOMA_DIR}" |
| 38 | else |
| 39 | goma_dir="${HOME}/goma" |
| 40 | fi |
| 41 | GOMA_CC="${goma_dir}/gomacc" |
| 42 | export CC_WRAPPER="${CC_WRAPPER}${CC_WRAPPER:+ }${GOMA_CC}" |
| 43 | export CXX_WRAPPER="${CXX_WRAPPER}${CXX_WRAPPER:+ }${GOMA_CC}" |
| 44 | export JAVAC_WRAPPER="${JAVAC_WRAPPER}${JAVAC_WRAPPER:+ }${GOMA_CC}" |
| 45 | else |
| 46 | USE_GOMA=false |
| 47 | fi |
| 48 | |
| 49 | SOONG_OUT=${OUT_DIR}/soong |
| 50 | mkdir -p ${SOONG_OUT} |
| 51 | SOONG_VARS=${SOONG_OUT}/soong.variables |
| 52 | |
| 53 | cat > ${SOONG_VARS}.new << EOF |
| 54 | { |
| 55 | "Platform_sdk_version": ${PLATFORM_SDK_VERSION}, |
| 56 | "Platform_sdk_codename": "${PLATFORM_VERSION}", |
| 57 | "Platform_version_active_codenames": ${PLATFORM_VERSION_ALL_CODENAMES}, |
| 58 | |
| 59 | "DeviceName": "generic_arm64", |
| 60 | "HostArch": "x86_64", |
| 61 | "Aml_abis": true, |
| 62 | |
| 63 | "UseGoma": ${USE_GOMA} |
| 64 | } |
| 65 | EOF |
| 66 | |
| 67 | if [ -f ${SOONG_VARS} ] && cmp -s ${SOONG_VARS} ${SOONG_VARS}.new; then |
| 68 | # Don't touch soong.variables if we don't have to, to avoid Soong rebuilding |
| 69 | # the ninja file when it isn't necessary. |
| 70 | rm ${SOONG_VARS}.new |
| 71 | else |
| 72 | mv ${SOONG_VARS}.new ${SOONG_VARS} |
| 73 | fi |
| 74 | |
| 75 | m --skip-make "$@" |