blob: d8a97299278409c9da70b85b65e9eef15cf6f781 [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
23
24# TODO: Use a $(gettop) style method.
25export ROOT_DIR=$PWD
26
27export BUILD_CONFIG=${BUILD_CONFIG:-build.config}
28. ${ROOT_DIR}/${BUILD_CONFIG}
29
30echo "========================================================"
31echo "= build config: ${ROOT_DIR}/${BUILD_CONFIG}"
32cat ${ROOT_DIR}/${BUILD_CONFIG}
33
34# List of prebuilt directories shell variables to incorporate into PATH
35PREBUILTS_PATHS="
36LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN
37LINUX_GCC_CROSS_COMPILE_ARM32_PREBUILTS_BIN
38CLANG_PREBUILT_BIN
39LZ4_PREBUILTS_BIN
40DTC_PREBUILTS_BIN
41LIBUFDT_PREBUILTS_BIN
42"
43
44for PREBUILT_BIN in ${PREBUILTS_PATHS}; do
45 PREBUILT_BIN=\${${PREBUILT_BIN}}
46 eval PREBUILT_BIN="${PREBUILT_BIN}"
47 if [ -n "${PREBUILT_BIN}" ]; then
48 # Mitigate dup paths
49 PATH=${PATH//"${ROOT_DIR}/${PREBUILT_BIN}:"}
50 PATH=${ROOT_DIR}/${PREBUILT_BIN}:${PATH}
51 fi
52done
53export PATH
54
55echo
56echo "PATH=${PATH}"
57echo
58
59export $(sed -n -e 's/\([^=]\)=.*/\1/p' ${ROOT_DIR}/${BUILD_CONFIG})
60
61# verifies that defconfig matches the DEFCONFIG
62function check_defconfig() {
63 (cd ${OUT_DIR} && \
64 make O=${OUT_DIR} savedefconfig)
65 [ "$ARCH" = "x86_64" -o "$ARCH" = "i386" ] && local ARCH=x86
66 echo Verifying that savedefconfig matches ${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG}
67 RES=0
68 diff ${OUT_DIR}/defconfig ${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG} ||
69 RES=$?
70 if [ ${RES} -ne 0 ]; then
71 echo ERROR: savedefconfig does not match ${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG}
72 fi
73 return ${RES}
74}