1#!/bin/bash 2# 3# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 4# 5# This software is licensed under the terms of the GNU General Public 6# License version 2, as published by the Free Software Foundation, and 7# may be copied, distributed, and modified under those terms. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# 15 16set -e 17 18OHOS_SOURCE_ROOT=$1 19KERNEL_BUILD_ROOT=$2 20KERNEL_PATCH_PATH=$3 21DEVICE_NAME=$4 22HDF_COMMON_PATCH="common" 23 24ln_list=( 25 drivers/hdf_core/adapter/khdf/linux drivers/hdf/khdf 26 drivers/hdf_core/framework drivers/hdf/framework 27 drivers/hdf_core/interfaces/inner_api drivers/hdf/inner_api 28 drivers/hdf_core/framework/include include/hdf 29) 30 31cp_list=( 32 $OHOS_SOURCE_ROOT/third_party/bounds_checking_function ./ 33 $OHOS_SOURCE_ROOT/device/soc/hisilicon/common/platform/wifi drivers/hdf/ 34 $OHOS_SOURCE_ROOT/third_party/FreeBSD/sys/dev/evdev drivers/hdf/ 35) 36 37 38function copy_external_compents() 39{ 40 for ((i=0; i<${#cp_list[*]}; i+=2)) 41 do 42 dst_dir=${cp_list[$(expr $i + 1)]}/${cp_list[$i]##*/} 43 mkdir -p $dst_dir 44 [ -d "${cp_list[$i]}"/ ] && cp -arfL ${cp_list[$i]}/* $dst_dir/ 45 done 46} 47 48function ln_hdf_repos() 49{ 50 for ((i=0; i<${#ln_list[*]}; i+=2)) 51 do 52 SOFT_RELATIVE_PATH=$(realpath --relative-to=${ln_list[$(expr $i + 1)]} ${OHOS_SOURCE_ROOT}) 53 ln -sf ${SOFT_RELATIVE_PATH#*/}/${ln_list[$i]} ${ln_list[$(expr $i + 1)]} 54 done 55} 56 57function put_hdf_patch() 58{ 59 HDF_PATCH_FILE=${KERNEL_PATCH_PATH}/${DEVICE_NAME}_patch/hdf.patch 60 if [ ! -e "${HDF_PATCH_FILE}" ] 61 then 62 HDF_PATCH_FILE=${KERNEL_PATCH_PATH}/${HDF_COMMON_PATCH}_patch/hdf.patch 63 fi 64 patch -p1 < $HDF_PATCH_FILE 65} 66 67function main() 68{ 69 cd $KERNEL_BUILD_ROOT 70 put_hdf_patch 71 ln_hdf_repos 72 copy_external_compents 73 cd - 74} 75 76main 77