blob: 35a6ff3372c0da2af0e8e6d7af7d05de83c6d037 [file] [log] [blame]
Martin Stjernholmc1ecc432019-11-15 15:00:31 +00001#!/bin/bash -e
2
3export OUT_DIR=${OUT_DIR:-out}
4
5if [ -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}
14fi
15
16source build/envsetup.sh
17
18my_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
25PLATFORM_SDK_VERSION=$(my_get_build_var PLATFORM_SDK_VERSION)
26PLATFORM_VERSION=$(my_get_build_var PLATFORM_VERSION)
27PLATFORM_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"].
31PLATFORM_VERSION_ALL_CODENAMES=${PLATFORM_VERSION_ALL_CODENAMES/,/'","'}
32PLATFORM_VERSION_ALL_CODENAMES="[\"${PLATFORM_VERSION_ALL_CODENAMES}\"]"
33
34# Logic from build/make/core/goma.mk
35if [ "${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}"
45else
46 USE_GOMA=false
47fi
48
49SOONG_OUT=${OUT_DIR}/soong
50mkdir -p ${SOONG_OUT}
51SOONG_VARS=${SOONG_OUT}/soong.variables
52
53cat > ${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",
Nicolas Geoffrayabdc8c52020-03-24 11:39:06 +000061 "HostSecondaryArch": "x86",
Martin Stjernholmc1ecc432019-11-15 15:00:31 +000062 "Aml_abis": true,
63
64 "UseGoma": ${USE_GOMA}
65}
66EOF
67
68if [ -f ${SOONG_VARS} ] && cmp -s ${SOONG_VARS} ${SOONG_VARS}.new; then
69 # Don't touch soong.variables if we don't have to, to avoid Soong rebuilding
70 # the ninja file when it isn't necessary.
71 rm ${SOONG_VARS}.new
72else
73 mv ${SOONG_VARS}.new ${SOONG_VARS}
74fi
75
76m --skip-make "$@"