Matthias Maennich | 6652d74 | 2019-02-01 22:20:44 +0000 | [diff] [blame] | 1 | # 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 Maennich | ccb70fa | 2019-03-29 08:31:39 +0000 | [diff] [blame] | 23 | [ -n "$ENVSETUP_SH_INCLUDED" ] && return || export ENVSETUP_SH_INCLUDED=1 |
Matthias Maennich | 6652d74 | 2019-02-01 22:20:44 +0000 | [diff] [blame] | 24 | |
| 25 | # TODO: Use a $(gettop) style method. |
| 26 | export ROOT_DIR=$PWD |
| 27 | |
| 28 | export BUILD_CONFIG=${BUILD_CONFIG:-build.config} |
| 29 | . ${ROOT_DIR}/${BUILD_CONFIG} |
| 30 | |
Matthias Maennich | ccb70fa | 2019-03-29 08:31:39 +0000 | [diff] [blame] | 31 | export COMMON_OUT_DIR=$(readlink -m ${OUT_DIR:-${ROOT_DIR}/out/${BRANCH}}) |
| 32 | export OUT_DIR=$(readlink -m ${COMMON_OUT_DIR}/${KERNEL_DIR}) |
| 33 | export DIST_DIR=$(readlink -m ${DIST_DIR:-${COMMON_OUT_DIR}/dist}) |
| 34 | |
Matthias Maennich | 6652d74 | 2019-02-01 22:20:44 +0000 | [diff] [blame] | 35 | echo "========================================================" |
| 36 | echo "= build config: ${ROOT_DIR}/${BUILD_CONFIG}" |
| 37 | cat ${ROOT_DIR}/${BUILD_CONFIG} |
| 38 | |
| 39 | # List of prebuilt directories shell variables to incorporate into PATH |
| 40 | PREBUILTS_PATHS=" |
| 41 | LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN |
| 42 | LINUX_GCC_CROSS_COMPILE_ARM32_PREBUILTS_BIN |
| 43 | CLANG_PREBUILT_BIN |
| 44 | LZ4_PREBUILTS_BIN |
| 45 | DTC_PREBUILTS_BIN |
| 46 | LIBUFDT_PREBUILTS_BIN |
| 47 | " |
| 48 | |
| 49 | for 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 |
| 57 | done |
| 58 | export PATH |
| 59 | |
| 60 | echo |
| 61 | echo "PATH=${PATH}" |
| 62 | echo |
| 63 | |
| 64 | export $(sed -n -e 's/\([^=]\)=.*/\1/p' ${ROOT_DIR}/${BUILD_CONFIG}) |
| 65 | |
| 66 | # verifies that defconfig matches the DEFCONFIG |
| 67 | function check_defconfig() { |
| 68 | (cd ${OUT_DIR} && \ |
Alistair Strachan | 898f1e4 | 2019-05-20 16:17:41 -0700 | [diff] [blame^] | 69 | make ${CC_LD_ARG} O=${OUT_DIR} savedefconfig) |
Matthias Maennich | 6652d74 | 2019-02-01 22:20:44 +0000 | [diff] [blame] | 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 | } |