blob: 106de5172df922aad093900175d6cc4d35002d6d [file] [log] [blame]
Matthias Maennich6652d742019-02-01 22:20:44 +00001#!/bin/bash
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# build/build.sh <make options>*
19# or:
20# OUT_DIR=<out dir> DIST_DIR=<dist dir> build/build.sh <make options>*
21#
22# Example:
Alessio Balsini20ff3252019-08-13 15:00:25 +010023# OUT_DIR=output DIST_DIR=dist build/build.sh -j24 V=1
Matthias Maennich6652d742019-02-01 22:20:44 +000024#
25#
26# The following environment variables are considered during execution:
27#
28# BUILD_CONFIG
29# Build config file to initialize the build environment from. The location
30# is to be defined relative to the repo root directory.
31# Defaults to 'build.config'.
32#
33# OUT_DIR
34# Base output directory for the kernel build.
35# Defaults to <REPO_ROOT>/out/<BRANCH>.
36#
37# DIST_DIR
38# Base output directory for the kernel distribution.
39# Defaults to <OUT_DIR>/dist
40#
41# EXT_MODULES
42# Space separated list of external kernel modules to be build.
43#
44# UNSTRIPPED_MODULES
45# Space separated list of modules to be copied to <DIST_DIR>/unstripped
46# for debugging purposes.
47#
48# CC
Matthias Maennich0646c8d2019-03-20 11:03:51 +000049# Override compiler to be used. (e.g. CC=clang) Specifying CC=gcc
50# effectively unsets CC to fall back to the default gcc detected by kbuild
51# (including any target triplet). To use a custom 'gcc' from PATH, use an
52# absolute path, e.g. CC=/usr/local/bin/gcc
Matthias Maennich6652d742019-02-01 22:20:44 +000053#
54# LD
55# Override linker (flags) to be used.
56#
Matthias Maennich44509b02019-05-28 12:26:58 +010057# ABI_DEFINITION
58# Location of the abi definition file relative to <REPO_ROOT>/KERNEL_DIR
59# If defined (usually in build.config), also copy that abi definition to
Matthias Maennichd46fd322019-05-29 09:05:38 +010060# <OUT_DIR>/dist/abi.xml when creating the distribution.
Matthias Maennich44509b02019-05-28 12:26:58 +010061#
Matthias Maennich6652d742019-02-01 22:20:44 +000062# Environment variables to influence the stages of the kernel build.
63#
64# SKIP_MRPROPER
65# if defined, skip `make mrproper`
66#
67# SKIP_DEFCONFIG
68# if defined, skip `make defconfig`
69#
Matthias Maenniche4edd6f2019-02-13 12:36:27 +000070# PRE_DEFCONFIG_CMDS
71# Command evaluated before `make defconfig`
72#
Matthias Maennich6652d742019-02-01 22:20:44 +000073# POST_DEFCONFIG_CMDS
74# Command evaluated after `make defconfig` and before `make`.
75#
Matthias Maenniche4edd6f2019-02-13 12:36:27 +000076# POST_KERNEL_BUILD_CMDS
77# Command evaluated after `make`.
78#
Matthias Maennich6652d742019-02-01 22:20:44 +000079# IN_KERNEL_MODULES
80# if defined, install kernel modules
81#
82# SKIP_EXT_MODULES
83# if defined, skip building and installing of external modules
84#
85# EXTRA_CMDS
86# Command evaluated after building and installing kernel and modules.
87#
88# SKIP_CP_KERNEL_HDR
89# if defined, skip installing kernel headers.
90#
Hridya Valsarajue46a9372019-05-13 16:38:14 -070091# BUILD_BOOT_IMG
92# if defined, build a boot.img binary that can be flashed into the 'boot'
93# partition of an Android device. The boot image contains a header as per the
94# format defined by https://source.android.com/devices/bootloader/boot-image-header
95# followed by several components like kernel, ramdisk, DTB etc. The ramdisk
96# component comprises of a GKI ramdisk cpio archive concatenated with a
97# vendor ramdisk cpio archive which is then gzipped. It is expected that
98# all components are present in ${DIST_DIR}.
99#
100# When the BUILD_BOOT_IMG flag is defined, the following flags that point to the
101# various components needed to build a boot.img also need to be defined.
102# - MKBOOTIMG_PATH=<path to the mkbootimg.py script which builds boot.img>
103# - GKI_RAMDISK_PREBUILT_BINARY=<Name of the GKI ramdisk prebuilt which includes
104# the generic ramdisk components like init and the non-device-specific rc files>
105# - VENDOR_RAMDISK_BINARY=<Name of the vendor ramdisk binary which includes the
106# device-specific components of ramdisk like the fstab file and the
107# device-specific rc files.>
108# - KERNEL_BINARY=<name of kernel binary, eg. Image.lz4, Image.gz etc>
109# - BOOT_IMAGE_HEADER_VERSION=<version of the boot image header>
110#
Ram Muthiah3a869ac2019-08-08 21:11:56 -0700111# BUILD_INITRAMFS
112# if defined, build a ramdisk containing all .ko files and resulting depmod artifacts
113#
Matthias Maennich6652d742019-02-01 22:20:44 +0000114# Note: For historic reasons, internally, OUT_DIR will be copied into
115# COMMON_OUT_DIR, and OUT_DIR will be then set to
116# ${COMMON_OUT_DIR}/${KERNEL_DIR}. This has been done to accommodate existing
117# build.config files that expect ${OUT_DIR} to point to the output directory of
118# the kernel build.
119#
120# The kernel is built in ${COMMON_OUT_DIR}/${KERNEL_DIR}.
121# Out-of-tree modules are built in ${COMMON_OUT_DIR}/${EXT_MOD} where
122# ${EXT_MOD} is the path to the module source code.
123
124set -e
125
126# rel_path <to> <from>
127# Generate relative directory path to reach directory <to> from <from>
128function rel_path() {
129 local to=$1
130 local from=$2
131 local path=
132 local stem=
133 local prevstem=
134 [ -n "$to" ] || return 1
135 [ -n "$from" ] || return 1
136 to=$(readlink -e "$to")
137 from=$(readlink -e "$from")
138 [ -n "$to" ] || return 1
139 [ -n "$from" ] || return 1
140 stem=${from}/
141 while [ "${to#$stem}" == "${to}" -a "${stem}" != "${prevstem}" ]; do
142 prevstem=$stem
143 stem=$(readlink -e "${stem}/..")
144 [ "${stem%/}" == "${stem}" ] && stem=${stem}/
145 path=${path}../
146 done
147 echo ${path}${to#$stem}
148}
149
150export ROOT_DIR=$(readlink -f $(dirname $0)/..)
151
152# For module file Signing with the kernel (if needed)
153FILE_SIGN_BIN=scripts/sign-file
154SIGN_SEC=certs/signing_key.pem
155SIGN_CERT=certs/signing_key.x509
156SIGN_ALGO=sha512
157
Alessio Balsinia397d802019-07-24 15:06:20 +0100158# Save environment parameters before being overwritten by sourcing
159# BUILD_CONFIG.
160CC_ARG=${CC}
161
Matthias Maennich6652d742019-02-01 22:20:44 +0000162source "${ROOT_DIR}/build/envsetup.sh"
163
Alessio Balsini20ff3252019-08-13 15:00:25 +0100164export MAKE_ARGS=$*
165export MAKEFLAGS="-j$(nproc) ${MAKEFLAGS}"
Matthias Maennich6652d742019-02-01 22:20:44 +0000166export MODULES_STAGING_DIR=$(readlink -m ${COMMON_OUT_DIR}/staging)
167export MODULES_PRIVATE_DIR=$(readlink -m ${COMMON_OUT_DIR}/private)
Matthias Maennich6652d742019-02-01 22:20:44 +0000168export UNSTRIPPED_DIR=${DIST_DIR}/unstripped
169export KERNEL_UAPI_HEADERS_DIR=$(readlink -m ${COMMON_OUT_DIR}/kernel_uapi_headers)
Ram Muthiah3a869ac2019-08-08 21:11:56 -0700170export INITRAMFS_STAGING_DIR=${MODULES_STAGING_DIR}/initramfs_staging
Matthias Maennich6652d742019-02-01 22:20:44 +0000171
172cd ${ROOT_DIR}
173
174export CLANG_TRIPLE CROSS_COMPILE CROSS_COMPILE_ARM32 ARCH SUBARCH
175
Alessio Balsinia397d802019-07-24 15:06:20 +0100176# Restore the previously saved CC argument that might have been overridden by
177# the BUILD_CONFIG.
178[ -n "${CC_ARG}" ] && CC=${CC_ARG}
179
Matthias Maennich0646c8d2019-03-20 11:03:51 +0000180# CC=gcc is effectively a fallback to the default gcc including any target
Alessio Balsinia397d802019-07-24 15:06:20 +0100181# triplets. An absolute path (e.g., CC=/usr/bin/gcc) must be specified to use a
182# custom compiler.
183[ "${CC}" == "gcc" ] && unset CC && unset CC_ARG
Matthias Maennich0646c8d2019-03-20 11:03:51 +0000184
Matthias Maennich151047e2019-03-18 15:01:03 +0000185if [ -n "${CC}" ]; then
Matthias Maennich2eb25cc2019-06-24 17:45:18 +0100186 CC_ARG="CC=${CC} HOSTCC=${CC}"
Matthias Maennich151047e2019-03-18 15:01:03 +0000187fi
188
189if [ -n "${LD}" ]; then
190 LD_ARG="LD=${LD}"
191fi
192
193CC_LD_ARG="${CC_ARG} ${LD_ARG}"
194
Matthias Maennich6652d742019-02-01 22:20:44 +0000195mkdir -p ${OUT_DIR}
196echo "========================================================"
197echo " Setting up for build"
198if [ -z "${SKIP_MRPROPER}" ] ; then
199 set -x
Alessio Balsini20ff3252019-08-13 15:00:25 +0100200 (cd ${KERNEL_DIR} && make ${CC_LD_ARG} O=${OUT_DIR} ${MAKE_ARGS} mrproper)
Matthias Maennich6652d742019-02-01 22:20:44 +0000201 set +x
202fi
203
Petri Gynther0172f352019-02-12 11:52:50 -0800204if [ "${PRE_DEFCONFIG_CMDS}" != "" ]; then
205 echo "========================================================"
206 echo " Running pre-defconfig command(s):"
207 set -x
208 eval ${PRE_DEFCONFIG_CMDS}
209 set +x
210fi
211
Matthias Maennich6652d742019-02-01 22:20:44 +0000212if [ -z "${SKIP_DEFCONFIG}" ] ; then
213set -x
Alessio Balsini20ff3252019-08-13 15:00:25 +0100214(cd ${KERNEL_DIR} && make ${CC_LD_ARG} O=${OUT_DIR} ${MAKE_ARGS} ${DEFCONFIG})
Matthias Maennich6652d742019-02-01 22:20:44 +0000215set +x
216
217if [ "${POST_DEFCONFIG_CMDS}" != "" ]; then
218 echo "========================================================"
219 echo " Running pre-make command(s):"
220 set -x
221 eval ${POST_DEFCONFIG_CMDS}
222 set +x
223fi
224fi
225
226echo "========================================================"
227echo " Building kernel"
228
Matthias Maennich6652d742019-02-01 22:20:44 +0000229set -x
Alessio Balsini20ff3252019-08-13 15:00:25 +0100230(cd ${OUT_DIR} && make O=${OUT_DIR} ${CC_LD_ARG} ${MAKE_ARGS})
Matthias Maennich6652d742019-02-01 22:20:44 +0000231set +x
232
Petri Gynther0172f352019-02-12 11:52:50 -0800233if [ "${POST_KERNEL_BUILD_CMDS}" != "" ]; then
234 echo "========================================================"
235 echo " Running post-kernel-build command(s):"
236 set -x
237 eval ${POST_KERNEL_BUILD_CMDS}
238 set +x
239fi
240
Matthias Maennich6652d742019-02-01 22:20:44 +0000241rm -rf ${MODULES_STAGING_DIR}
242mkdir -p ${MODULES_STAGING_DIR}
243
Ram Muthiah3a869ac2019-08-08 21:11:56 -0700244if [ -n "${BUILD_INITRAMFS}" -o -n "${IN_KERNEL_MODULES}" ]; then
Matthias Maennich6652d742019-02-01 22:20:44 +0000245 echo "========================================================"
246 echo " Installing kernel modules into staging directory"
247
Alessio Balsini20ff3252019-08-13 15:00:25 +0100248 (cd ${OUT_DIR} && \
249 make O=${OUT_DIR} ${CC_LD_ARG} INSTALL_MOD_STRIP=1 \
250 INSTALL_MOD_PATH=${MODULES_STAGING_DIR} ${MAKE_ARGS} modules_install)
Matthias Maennich6652d742019-02-01 22:20:44 +0000251fi
252
253if [[ -z "${SKIP_EXT_MODULES}" ]] && [[ "${EXT_MODULES}" != "" ]]; then
254 echo "========================================================"
255 echo " Building external modules and installing them into staging directory"
256
257 for EXT_MOD in ${EXT_MODULES}; do
258 # The path that we pass in via the variable M needs to be a relative path
259 # relative to the kernel source directory. The source files will then be
260 # looked for in ${KERNEL_DIR}/${EXT_MOD_REL} and the object files (i.e. .o
261 # and .ko) files will be stored in ${OUT_DIR}/${EXT_MOD_REL}. If we
262 # instead set M to an absolute path, then object (i.e. .o and .ko) files
263 # are stored in the module source directory which is not what we want.
264 EXT_MOD_REL=$(rel_path ${ROOT_DIR}/${EXT_MOD} ${KERNEL_DIR})
265 # The output directory must exist before we invoke make. Otherwise, the
266 # build system behaves horribly wrong.
267 mkdir -p ${OUT_DIR}/${EXT_MOD_REL}
268 set -x
269 make -C ${EXT_MOD} M=${EXT_MOD_REL} KERNEL_SRC=${ROOT_DIR}/${KERNEL_DIR} \
Alessio Balsini20ff3252019-08-13 15:00:25 +0100270 O=${OUT_DIR} ${CC_LD_ARG} ${MAKE_ARGS}
Matthias Maennich6652d742019-02-01 22:20:44 +0000271 make -C ${EXT_MOD} M=${EXT_MOD_REL} KERNEL_SRC=${ROOT_DIR}/${KERNEL_DIR} \
Alessio Balsini20ff3252019-08-13 15:00:25 +0100272 O=${OUT_DIR} ${CC_LD_ARG} INSTALL_MOD_STRIP=1 \
273 INSTALL_MOD_PATH=${MODULES_STAGING_DIR} \
274 ${MAKE_ARGS} modules_install
Matthias Maennich6652d742019-02-01 22:20:44 +0000275 set +x
276 done
277
278fi
279
280if [ "${EXTRA_CMDS}" != "" ]; then
281 echo "========================================================"
282 echo " Running extra build command(s):"
283 set -x
284 eval ${EXTRA_CMDS}
285 set +x
286fi
287
288OVERLAYS_OUT=""
289for ODM_DIR in ${ODM_DIRS}; do
290 OVERLAY_DIR=${ROOT_DIR}/device/${ODM_DIR}/overlays
291
292 if [ -d ${OVERLAY_DIR} ]; then
293 OVERLAY_OUT_DIR=${OUT_DIR}/overlays/${ODM_DIR}
294 mkdir -p ${OVERLAY_OUT_DIR}
Alessio Balsini20ff3252019-08-13 15:00:25 +0100295 make -C ${OVERLAY_DIR} DTC=${OUT_DIR}/scripts/dtc/dtc \
296 OUT_DIR=${OVERLAY_OUT_DIR} ${MAKE_ARGS}
Matthias Maennich6652d742019-02-01 22:20:44 +0000297 OVERLAYS=$(find ${OVERLAY_OUT_DIR} -name "*.dtbo")
298 OVERLAYS_OUT="$OVERLAYS_OUT $OVERLAYS"
299 fi
300done
301
302mkdir -p ${DIST_DIR}
303echo "========================================================"
304echo " Copying files"
Alessio Balsiniac896332019-07-16 15:20:24 +0100305for FILE in $(cd ${OUT_DIR} && ls -1 ${FILES}); do
Matthias Maennich6652d742019-02-01 22:20:44 +0000306 if [ -f ${OUT_DIR}/${FILE} ]; then
307 echo " $FILE"
308 cp -p ${OUT_DIR}/${FILE} ${DIST_DIR}/
309 else
Alessio Balsiniac896332019-07-16 15:20:24 +0100310 echo " $FILE is not a file, skipping"
Matthias Maennich6652d742019-02-01 22:20:44 +0000311 fi
312done
313
314for FILE in ${OVERLAYS_OUT}; do
315 OVERLAY_DIST_DIR=${DIST_DIR}/$(dirname ${FILE#${OUT_DIR}/overlays/})
316 echo " ${FILE#${OUT_DIR}/}"
317 mkdir -p ${OVERLAY_DIST_DIR}
318 cp ${FILE} ${OVERLAY_DIST_DIR}/
319done
320
321MODULES=$(find ${MODULES_STAGING_DIR} -type f -name "*.ko")
322if [ -n "${MODULES}" ]; then
Matthias Maennich6652d742019-02-01 22:20:44 +0000323 if [ -n "${IN_KERNEL_MODULES}" -o "${EXT_MODULES}" != "" ]; then
Ram Muthiah3a869ac2019-08-08 21:11:56 -0700324 echo "========================================================"
325 echo " Copying modules files"
Matthias Maennich6652d742019-02-01 22:20:44 +0000326 for FILE in ${MODULES}; do
327 echo " ${FILE#${MODULES_STAGING_DIR}/}"
328 cp -p ${FILE} ${DIST_DIR}
329 done
330 fi
Ram Muthiah3a869ac2019-08-08 21:11:56 -0700331 if [ -n "${BUILD_INITRAMFS}" ]; then
332 echo "========================================================"
333 echo " Creating initramfs"
334 set -x
335 rm -rf ${INITRAMFS_STAGING_DIR}
336 mkdir -p ${INITRAMFS_STAGING_DIR}/lib/modules/kernel/
337 cp -r ${MODULES_STAGING_DIR}/lib/modules/*/kernel/* ${INITRAMFS_STAGING_DIR}/lib/modules/kernel/
338 cp ${MODULES_STAGING_DIR}/lib/modules/*/modules.* ${INITRAMFS_STAGING_DIR}/lib/modules/
339 cp ${MODULES_STAGING_DIR}/lib/modules/*/modules.order ${INITRAMFS_STAGING_DIR}/lib/modules/modules.load
340
341 (cd ${INITRAMFS_STAGING_DIR} && find . | cpio -H newc -o > ${MODULES_STAGING_DIR}/initramfs.cpio)
342 gzip -f ${MODULES_STAGING_DIR}/initramfs.cpio
343 mv ${MODULES_STAGING_DIR}/initramfs.cpio.gz ${DIST_DIR}/initramfs.img
344 set +x
345 fi
Matthias Maennich6652d742019-02-01 22:20:44 +0000346fi
347
348if [ "${UNSTRIPPED_MODULES}" != "" ]; then
349 echo "========================================================"
350 echo " Copying unstripped module files for debugging purposes (not loaded on device)"
351 mkdir -p ${UNSTRIPPED_DIR}
352 for MODULE in ${UNSTRIPPED_MODULES}; do
353 find ${MODULES_PRIVATE_DIR} -name ${MODULE} -exec cp {} ${UNSTRIPPED_DIR} \;
354 done
355fi
356
357if [ -z "${SKIP_CP_KERNEL_HDR}" ]; then
358 echo "========================================================"
359 echo " Installing UAPI kernel headers:"
360 mkdir -p "${KERNEL_UAPI_HEADERS_DIR}/usr"
Alessio Balsini20ff3252019-08-13 15:00:25 +0100361 make -C ${OUT_DIR} O=${OUT_DIR} ${CC_LD_ARG} \
362 INSTALL_HDR_PATH="${KERNEL_UAPI_HEADERS_DIR}/usr" ${MAKE_ARGS} \
363 headers_install
Matthias Maennich6652d742019-02-01 22:20:44 +0000364 # The kernel makefiles create files named ..install.cmd and .install which
365 # are only side products. We don't want those. Let's delete them.
366 find ${KERNEL_UAPI_HEADERS_DIR} \( -name ..install.cmd -o -name .install \) -exec rm '{}' +
367 KERNEL_UAPI_HEADERS_TAR=${DIST_DIR}/kernel-uapi-headers.tar.gz
368 echo " Copying kernel UAPI headers to ${KERNEL_UAPI_HEADERS_TAR}"
369 tar -czf ${KERNEL_UAPI_HEADERS_TAR} --directory=${KERNEL_UAPI_HEADERS_DIR} usr/
370fi
371
372if [ -z "${SKIP_CP_KERNEL_HDR}" ] ; then
Matthias Maennichbec886a2019-04-15 07:23:47 +0100373 echo "========================================================"
374 KERNEL_HEADERS_TAR=${DIST_DIR}/kernel-headers.tar.gz
375 echo " Copying kernel headers to ${KERNEL_HEADERS_TAR}"
376 pushd $ROOT_DIR/$KERNEL_DIR
377 find arch include $OUT_DIR -name *.h -print0 \
378 | tar -czf $KERNEL_HEADERS_TAR \
379 --absolute-names \
380 --dereference \
381 --transform "s,.*$OUT_DIR,," \
382 --transform "s,^,kernel-headers/," \
383 --null -T -
384 popd
Matthias Maennich6652d742019-02-01 22:20:44 +0000385fi
386
Matthias Maennichd46fd322019-05-29 09:05:38 +0100387# Copy the abi_${arch}.xml file from the sources into the dist dir
Matthias Maennich44509b02019-05-28 12:26:58 +0100388if [ -n "${ABI_DEFINITION}" ]; then
389 echo "========================================================"
Matthias Maennichd46fd322019-05-29 09:05:38 +0100390 echo " Copying abi definition to ${DIST_DIR}/abi.xml"
Matthias Maennich44509b02019-05-28 12:26:58 +0100391 pushd $ROOT_DIR/$KERNEL_DIR
Matthias Maennichd46fd322019-05-29 09:05:38 +0100392 cp "${ABI_DEFINITION}" ${DIST_DIR}/abi.xml
Matthias Maennich44509b02019-05-28 12:26:58 +0100393 popd
394fi
395
Matthias Maennich6652d742019-02-01 22:20:44 +0000396echo "========================================================"
397echo " Files copied to ${DIST_DIR}"
398
Hridya Valsarajue46a9372019-05-13 16:38:14 -0700399if [ ! -z "${BUILD_BOOT_IMG}" ] ; then
400
401 DTB_FILE_LIST=$(find ${DIST_DIR} -name "*.dtb")
402 if [ -z "${DTB_FILE_LIST}" ]; then
403 echo "No *.dtb files found in ${DIST_DIR}"
404 exit 1
405 fi
406 cat $DTB_FILE_LIST > ${DIST_DIR}/dtb.img
407
408 if [ ! -f "${DIST_DIR}/$GKI_RAMDISK_PREBUILT_BINARY" ]; then
409 echo "GKI ramdisk prebuilt binary" \
410 "(GKI_RAMDISK_PREBUILT_BINARY = $GKI_RAMDISK_PREBUILT_BINARY)" \
411 "not present in ${DIST_DIR}"
412 exit 1
413 fi
414 if [ ! -f "${DIST_DIR}/$VENDOR_RAMDISK_BINARY" ]; then
415 echo "vendor ramdisk binary(VENDOR_RAMDISK_BINARY = $VENDOR_RAMDISK_BINARY)" \
416 "not present in ${DIST_DIR}"
417 exit 1
418 fi
419
420 cat ${DIST_DIR}/$GKI_RAMDISK_PREBUILT_BINARY ${DIST_DIR}/$VENDOR_RAMDISK_BINARY \
421 > ${DIST_DIR}/ramdisk.cpio
422 gzip -f ${DIST_DIR}/ramdisk.cpio > ${DIST_DIR}/ramdisk
423
424 if [ ! -x "$MKBOOTIMG_PATH" ]; then
425 echo "mkbootimg.py script not found or not executable. MKBOOTIMG_PATH = $MKBOOTIMG_PATH"
426 exit 1
427 fi
428
429 if [ ! -f "${DIST_DIR}/$KERNEL_BINARY" ]; then
430 echo "kernel binary(KERNEL_BINARY = $KERNEL_BINARY) not present in ${DIST_DIR}"
431 exit 1
432 fi
433
434 if [ -z "${BOOT_IMAGE_HEADER_VERSION}" ]; then
435 echo "BOOT_IMAGE_HEADER_VERSION must specify the boot image header version"
436 exit 1
437 fi
438
439 (set -x; $MKBOOTIMG_PATH --kernel ${DIST_DIR}/$KERNEL_BINARY \
440 --ramdisk ${DIST_DIR}/ramdisk \
441 --dtb ${DIST_DIR}/dtb.img --header_version $BOOT_IMAGE_HEADER_VERSION \
442 -o ${DIST_DIR}/boot.img
443 )
444 set +x
445 echo "boot image created at ${DIST_DIR}/boot.img"
446fi
447
448
Matthias Maennich6652d742019-02-01 22:20:44 +0000449# No trace_printk use on build server build
450if readelf -a ${DIST_DIR}/vmlinux 2>&1 | grep -q trace_printk_fmt; then
451 echo "========================================================"
452 echo "WARN: Found trace_printk usage in vmlinux."
453 echo ""
454 echo "trace_printk will cause trace_printk_init_buffers executed in kernel"
455 echo "start, which will increase memory and lead warning shown during boot."
456 echo "We should not carry trace_printk in production kernel."
457 echo ""
458 if [ ! -z "${STOP_SHIP_TRACEPRINTK}" ]; then
459 echo "ERROR: stop ship on trace_printk usage." 1>&2
460 exit 1
461 fi
462fi