diff options
author | Matthias Maennich <maennich@google.com> | 2021-06-26 15:35:22 +0100 |
---|---|---|
committer | Matthias Maennich <maennich@google.com> | 2021-06-28 13:23:56 +0100 |
commit | 46bea128ef104c9e57baf39a6bd6998d0d863245 (patch) | |
tree | 8b47f67bc70c6e82c4e22832618f701a7cbb970d /_setup_env.sh | |
parent | 27db4ed5b808d80cdef11eb355091e6c9d87b4f5 (diff) | |
download | build-46bea128ef104c9e57baf39a6bd6998d0d863245.tar.gz |
build.sh: Move TOOL_ARGS to _setup_env.sh
The TOOL_ARGS definition is actually an environment setup. Move it to
setup_env then. This also decouples environment setup from build
execution. As a side effect, the bazel based build (kleaf) can make use
of this to setup a complete environment to run 'make' in.
Bug: 189451175
Signed-off-by: Matthias Maennich <maennich@google.com>
Change-Id: Id7a57684433c1d07ec66a671e5f882f11a759eb5
Diffstat (limited to '_setup_env.sh')
-rw-r--r-- | _setup_env.sh | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/_setup_env.sh b/_setup_env.sh index a3106fc..0243dbf 100644 --- a/_setup_env.sh +++ b/_setup_env.sh @@ -135,10 +135,90 @@ for PREBUILT_BIN in "${PREBUILTS_PATHS[@]}"; do done export PATH +export CLANG_TRIPLE CROSS_COMPILE CROSS_COMPILE_COMPAT CROSS_COMPILE_ARM32 ARCH SUBARCH MAKE_GOALS + +tool_args=() + +# LLVM=1 implies what is otherwise set below; it is a more concise way of +# specifying CC=clang LD=ld.lld NM=llvm-nm OBJCOPY=llvm-objcopy <etc>, for +# newer kernel versions. +if [[ -n "${LLVM}" ]]; then + tool_args+=("LLVM=1") + # Reset a bunch of variables that the kernel's top level Makefile does, just + # in case someone tries to use these binaries in this script such as in + # initramfs generation below. + HOSTCC=clang + HOSTCXX=clang++ + CC=clang + LD=ld.lld + AR=llvm-ar + NM=llvm-nm + OBJCOPY=llvm-objcopy + OBJDUMP=llvm-objdump + READELF=llvm-readelf + OBJSIZE=llvm-size + STRIP=llvm-strip +else + if [ -n "${HOSTCC}" ]; then + tool_args+=("HOSTCC=${HOSTCC}") + fi + + if [ -n "${CC}" ]; then + tool_args+=("CC=${CC}") + if [ -z "${HOSTCC}" ]; then + tool_args+=("HOSTCC=${CC}") + fi + fi + + if [ -n "${LD}" ]; then + tool_args+=("LD=${LD}" "HOSTLD=${LD}") + fi + + if [ -n "${NM}" ]; then + tool_args+=("NM=${NM}") + fi + + if [ -n "${OBJCOPY}" ]; then + tool_args+=("OBJCOPY=${OBJCOPY}") + fi +fi + +if [ -n "${LLVM_IAS}" ]; then + tool_args+=("LLVM_IAS=${LLVM_IAS}") + # Reset $AS for the same reason that we reset $CC etc above. + AS=clang +fi + +if [ -n "${DEPMOD}" ]; then + tool_args+=("DEPMOD=${DEPMOD}") +fi + +if [ -n "${DTC}" ]; then + tool_args+=("DTC=${DTC}") +fi + +export TOOL_ARGS="${tool_args[@]}" + +# Allow hooks that refer to $CC_LD_ARG to keep working until they can be +# updated. +CC_LD_ARG="${TOOL_ARGS}" + +DECOMPRESS_GZIP="gzip -c -d" +DECOMPRESS_LZ4="lz4 -c -d -l" +if [ -z "${LZ4_RAMDISK}" ] ; then + RAMDISK_COMPRESS="gzip -c -f" + RAMDISK_DECOMPRESS="${DECOMPRESS_GZIP}" + RAMDISK_EXT="gz" +else + RAMDISK_COMPRESS="lz4 -c -l -12 --favor-decSpeed" + RAMDISK_DECOMPRESS="${DECOMPRESS_LZ4}" + RAMDISK_EXT="lz4" +fi + # verifies that defconfig matches the DEFCONFIG function check_defconfig() { (cd ${OUT_DIR} && \ - make "${TOOL_ARGS[@]}" O=${OUT_DIR} savedefconfig) + make ${TOOL_ARGS} O=${OUT_DIR} savedefconfig) [ "$ARCH" = "x86_64" -o "$ARCH" = "i386" ] && local ARCH=x86 RES=0 diff -u ${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG} ${OUT_DIR}/defconfig >&2 || |