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 | |
| 23 | |
| 24 | # TODO: Use a $(gettop) style method. |
| 25 | export ROOT_DIR=$PWD |
| 26 | |
| 27 | export BUILD_CONFIG=${BUILD_CONFIG:-build.config} |
| 28 | . ${ROOT_DIR}/${BUILD_CONFIG} |
| 29 | |
| 30 | echo "========================================================" |
| 31 | echo "= build config: ${ROOT_DIR}/${BUILD_CONFIG}" |
| 32 | cat ${ROOT_DIR}/${BUILD_CONFIG} |
| 33 | |
| 34 | # List of prebuilt directories shell variables to incorporate into PATH |
| 35 | PREBUILTS_PATHS=" |
| 36 | LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN |
| 37 | LINUX_GCC_CROSS_COMPILE_ARM32_PREBUILTS_BIN |
| 38 | CLANG_PREBUILT_BIN |
| 39 | LZ4_PREBUILTS_BIN |
| 40 | DTC_PREBUILTS_BIN |
| 41 | LIBUFDT_PREBUILTS_BIN |
| 42 | " |
| 43 | |
| 44 | for 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 |
| 52 | done |
| 53 | export PATH |
| 54 | |
| 55 | echo |
| 56 | echo "PATH=${PATH}" |
| 57 | echo |
| 58 | |
| 59 | export $(sed -n -e 's/\([^=]\)=.*/\1/p' ${ROOT_DIR}/${BUILD_CONFIG}) |
| 60 | |
| 61 | # verifies that defconfig matches the DEFCONFIG |
| 62 | function 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 | } |