13298bea7Sopenharmony_ci#!/bin/bash
23298bea7Sopenharmony_ci# Copyright (c) 2021 Huawei Device Co., Ltd.
33298bea7Sopenharmony_ci# This program is free software; you can redistribute it and/or modify
43298bea7Sopenharmony_ci# it under the terms of the GNU General Public License as published by
53298bea7Sopenharmony_ci# the Free Software Foundation; either version 2 of the License, or
63298bea7Sopenharmony_ci# (at your option) any later version.
73298bea7Sopenharmony_ci#
83298bea7Sopenharmony_ci# This program is distributed in the hope that it will be useful,
93298bea7Sopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of
103298bea7Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
113298bea7Sopenharmony_ci# GNU General Public License for more details.
123298bea7Sopenharmony_ci#
133298bea7Sopenharmony_ci# You should have received a copy of the GNU General Public License
143298bea7Sopenharmony_ci# along with this program. If not, see <http://www.gnu.org/licenses/>.
153298bea7Sopenharmony_ci
163298bea7Sopenharmony_ciset -e
173298bea7Sopenharmony_ci
183298bea7Sopenharmony_ciexport OUT_DIR=$1
193298bea7Sopenharmony_ciexport BUILD_TYPE=$2
203298bea7Sopenharmony_ciexport KERNEL_ARCH=$3
213298bea7Sopenharmony_ciexport PRODUCT_PATH=$4
223298bea7Sopenharmony_ciexport DEVICE_NAME=$5
233298bea7Sopenharmony_ciexport KERNEL_VERSION=$6
243298bea7Sopenharmony_ci
253298bea7Sopenharmony_ciif [ "$BUILD_TYPE" == "small" ];then
263298bea7Sopenharmony_ci    LINUX_KERNEL_OUT=${OUT_DIR}/kernel/${KERNEL_VERSION}
273298bea7Sopenharmony_cielif [ "$BUILD_TYPE" == "standard" ];then
283298bea7Sopenharmony_ci    LINUX_KERNEL_OUT=${OUT_DIR}/kernel/src_tmp/${KERNEL_VERSION}
293298bea7Sopenharmony_cifi
303298bea7Sopenharmony_ciLINUX_KERNEL_OBJ_OUT=${OUT_DIR}/kernel/OBJ/${KERNEL_VERSION}
313298bea7Sopenharmony_ci
323298bea7Sopenharmony_ciexport OHOS_ROOT_PATH=$(pwd)/../../..
333298bea7Sopenharmony_ci# it needs adaptation for more device target
343298bea7Sopenharmony_cikernel_image=""
353298bea7Sopenharmony_ciif [ "$KERNEL_ARCH" == "arm" ];then
363298bea7Sopenharmony_ci    kernel_image="uImage"
373298bea7Sopenharmony_cielif [ "$KERNEL_ARCH" == "arm64" ];then
383298bea7Sopenharmony_ci    kernel_image="Image"
393298bea7Sopenharmony_cielif [ "$KERNEL_ARCH" == "x86_64" ];then
403298bea7Sopenharmony_ci    kernel_image="bzImage"
413298bea7Sopenharmony_cifi
423298bea7Sopenharmony_ciexport KERNEL_IMAGE=${kernel_image}
433298bea7Sopenharmony_ci
443298bea7Sopenharmony_ciif [ "$KERNEL_ARCH" == "riscv64" ];then
453298bea7Sopenharmony_ci    LINUX_KERNEL_IMAGE_FILE=${LINUX_KERNEL_OBJ_OUT}/arch/riscv/boot/Image
463298bea7Sopenharmony_cielse
473298bea7Sopenharmony_ci    LINUX_KERNEL_IMAGE_FILE=${LINUX_KERNEL_OBJ_OUT}/arch/${KERNEL_ARCH}/boot/${kernel_image}
483298bea7Sopenharmony_cifi
493298bea7Sopenharmony_ci
503298bea7Sopenharmony_ciif [ "$DEVICE_NAME" == "hispark_phoenix"  ];then
513298bea7Sopenharmony_ciexport SDK_SOURCE_DIR=${OHOS_ROOT_PATH}/device/soc/hisilicon/hi3751v350/sdk_linux/source
523298bea7Sopenharmony_cifi
533298bea7Sopenharmony_ci
543298bea7Sopenharmony_cimake -f kernel.mk
553298bea7Sopenharmony_ci
563298bea7Sopenharmony_ciif [ -f "${LINUX_KERNEL_IMAGE_FILE}" ];then
573298bea7Sopenharmony_ci    echo "Image: ${LINUX_KERNEL_IMAGE_FILE} build success"
583298bea7Sopenharmony_cielse
593298bea7Sopenharmony_ci    echo "Image: ${LINUX_KERNEL_IMAGE_FILE} build failed!!!"
603298bea7Sopenharmony_ci    exit 1
613298bea7Sopenharmony_cifi
623298bea7Sopenharmony_ci
633298bea7Sopenharmony_ciif [ "$5" == "hispark_taurus" ];then
643298bea7Sopenharmony_ci    cp -rf ${LINUX_KERNEL_IMAGE_FILE} ${OUT_DIR}/uImage_${DEVICE_NAME}_smp
653298bea7Sopenharmony_cifi
663298bea7Sopenharmony_ci
673298bea7Sopenharmony_ciexit 0
68