blob: db02d2c5a3fd7444e46e3a90b43b104319d327af [file] [log] [blame]
Matthias Maennich6652d742019-02-01 22:20:44 +00001# source this file. Don't run it.
2
3# Copyright (C) 2019 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Usage:
18# source build/envsetup.sh
19# to setup your path and cross compiler so that a kernel build command is
20# just:
21# make -j24
22
Matthias Maennichccb70fa2019-03-29 08:31:39 +000023[ -n "$ENVSETUP_SH_INCLUDED" ] && return || export ENVSETUP_SH_INCLUDED=1
Matthias Maennich6652d742019-02-01 22:20:44 +000024
25# TODO: Use a $(gettop) style method.
26export ROOT_DIR=$PWD
27
28export BUILD_CONFIG=${BUILD_CONFIG:-build.config}
29. ${ROOT_DIR}/${BUILD_CONFIG}
30
Matthias Maennichccb70fa2019-03-29 08:31:39 +000031export COMMON_OUT_DIR=$(readlink -m ${OUT_DIR:-${ROOT_DIR}/out/${BRANCH}})
32export OUT_DIR=$(readlink -m ${COMMON_OUT_DIR}/${KERNEL_DIR})
33export DIST_DIR=$(readlink -m ${DIST_DIR:-${COMMON_OUT_DIR}/dist})
34
Matthias Maennich6652d742019-02-01 22:20:44 +000035echo "========================================================"
36echo "= build config: ${ROOT_DIR}/${BUILD_CONFIG}"
37cat ${ROOT_DIR}/${BUILD_CONFIG}
38
39# List of prebuilt directories shell variables to incorporate into PATH
40PREBUILTS_PATHS="
41LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN
42LINUX_GCC_CROSS_COMPILE_ARM32_PREBUILTS_BIN
43CLANG_PREBUILT_BIN
44LZ4_PREBUILTS_BIN
45DTC_PREBUILTS_BIN
46LIBUFDT_PREBUILTS_BIN
47"
48
49for PREBUILT_BIN in ${PREBUILTS_PATHS}; do
50 PREBUILT_BIN=\${${PREBUILT_BIN}}
51 eval PREBUILT_BIN="${PREBUILT_BIN}"
52 if [ -n "${PREBUILT_BIN}" ]; then
53 # Mitigate dup paths
54 PATH=${PATH//"${ROOT_DIR}/${PREBUILT_BIN}:"}
55 PATH=${ROOT_DIR}/${PREBUILT_BIN}:${PATH}
56 fi
57done
58export PATH
59
60echo
61echo "PATH=${PATH}"
62echo
63
64export $(sed -n -e 's/\([^=]\)=.*/\1/p' ${ROOT_DIR}/${BUILD_CONFIG})
65
66# verifies that defconfig matches the DEFCONFIG
67function check_defconfig() {
68 (cd ${OUT_DIR} && \
69 make O=${OUT_DIR} savedefconfig)
70 [ "$ARCH" = "x86_64" -o "$ARCH" = "i386" ] && local ARCH=x86
71 echo Verifying that savedefconfig matches ${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG}
72 RES=0
73 diff ${OUT_DIR}/defconfig ${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG} ||
74 RES=$?
75 if [ ${RES} -ne 0 ]; then
76 echo ERROR: savedefconfig does not match ${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG}
77 fi
78 return ${RES}
79}