kernel_build: support arm64 build

besides use os_level instead of obsolete ohos_lite
remove redudant clang argument passing

Signed-off-by: Yu Changchun <yuchangchun1@huawei.com>
This commit is contained in:
Yu Changchun
2022-01-16 13:38:27 +08:00
parent 7cab015329
commit a0fc7ef278
3 changed files with 43 additions and 54 deletions
+14 -11
View File
@@ -11,7 +11,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if (defined(ohos_lite)) {
if (os_level == "mini" || os_level == "small") {
import("//build/lite/config/component/lite_component.gni")
} else {
import("//build/config/clang/clang.gni")
@@ -19,30 +19,33 @@ if (defined(ohos_lite)) {
}
import("//build/ohos/kernel/kernel.gni")
if (defined(ohos_lite)) {
# it needs adaptation for more device target
kernel_image = ""
if (target_cpu == "arm") {
kernel_image = "uImage"
} else if (target_cpu == "arm64") {
kernel_image = "Image"
}
if (os_level == "mini" || os_level == "small") {
build_ext_component("linux_kernel") {
no_default_deps = true
exec_path = rebase_path(".", root_build_dir)
outdir = rebase_path("$root_out_dir")
clang_dir = ""
if (ohos_build_compiler_dir != "") {
clang_dir = rebase_path("${ohos_build_compiler_dir}")
}
build_type = "small"
product_path_rebase = rebase_path(product_path, ohos_root_path)
command = "./kernel_module_build.sh ${outdir} ${build_type} ${clang_dir} ${product_path_rebase} ${board_name} ${linux_kernel_version}"
command = "./kernel_module_build.sh ${outdir} ${build_type} ${target_cpu} ${product_path_rebase} ${board_name} ${linux_kernel_version}"
}
} else {
kernel_build_script_dir = "//kernel/linux/build"
kernel_source_dir = "//kernel/linux/$linux_kernel_version"
action("check_build") {
script = "check_build.sh"
sources = [ kernel_source_dir ]
outputs = [ "$root_build_dir/kernel.timestamp" ]
args = [
rebase_path(kernel_source_dir, root_build_dir),
rebase_path("$root_build_dir/packages/phone/images/uImage"),
rebase_path("$root_build_dir/packages/phone/images/$kernel_image"),
rebase_path("$root_build_dir/kernel.timestamp"),
]
}
@@ -54,13 +57,13 @@ if (defined(ohos_lite)) {
deps = [ ":check_build" ]
product_path = "vendor/$product_company/$product_name"
build_type = "standard"
outputs = [ "$root_build_dir/packages/phone/images/uImage" ]
outputs = [ "$root_build_dir/packages/phone/images/$kernel_image" ]
args = [
rebase_path(kernel_build_script_dir, root_build_dir),
rebase_path("$root_out_dir/../KERNEL_OBJ"),
rebase_path("$root_build_dir/packages/phone/images"),
build_type,
rebase_path("$clang_base_path"),
target_cpu,
product_path,
device_name,
linux_kernel_version,
+8 -20
View File
@@ -19,7 +19,6 @@ OHOS_BUILD_HOME := $(realpath $(shell pwd)/../../../)
KERNEL_SRC_TMP_PATH := $(OUT_DIR)/kernel/${KERNEL_VERSION}
KERNEL_OBJ_TMP_PATH := $(OUT_DIR)/kernel/OBJ/${KERNEL_VERSION}
ifeq ($(BUILD_TYPE), standard)
OHOS_BUILD_HOME := $(OHOS_ROOT_PATH)
BOOT_IMAGE_PATH = $(OHOS_BUILD_HOME)/device/board/hisilicon/hispark_taurus/uboot/prebuilts
KERNEL_SRC_TMP_PATH := $(OUT_DIR)/kernel/src_tmp/${KERNEL_VERSION}
endif
@@ -31,30 +30,19 @@ PREBUILTS_GCC_DIR := $(OHOS_BUILD_HOME)/prebuilts/gcc
CLANG_HOST_TOOLCHAIN := $(OHOS_BUILD_HOME)/prebuilts/clang/ohos/linux-x86_64/llvm/bin
KERNEL_HOSTCC := $(CLANG_HOST_TOOLCHAIN)/clang
KERNEL_PREBUILT_MAKE := make
CLANG_CC := $(CLANG_HOST_TOOLCHAIN)/clang
ifeq ($(BUILD_TYPE), standard)
KERNEL_ARCH := arm
ifeq ($(KERNEL_ARCH), arm)
KERNEL_TARGET_TOOLCHAIN := $(PREBUILTS_GCC_DIR)/linux-x86/arm/gcc-linaro-7.5.0-arm-linux-gnueabi/bin
KERNEL_TARGET_TOOLCHAIN_PREFIX := $(KERNEL_TARGET_TOOLCHAIN)/arm-linux-gnueabi-
CLANG_CC := $(CLANG_HOST_TOOLCHAIN)/clang
else ifeq ($(BUILD_TYPE), small)
KERNEL_ARCH := arm
ifeq ($(CLANG_CC), "")
CLANG_CC := $(CLANG_HOST_TOOLCHAIN)/clang
endif
else ifeq ($(KERNEL_ARCH), arm64)
KERNEL_TARGET_TOOLCHAIN := $(PREBUILTS_GCC_DIR)/linux-x86/aarch64/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin
KERNEL_TARGET_TOOLCHAIN_PREFIX := $(KERNEL_TARGET_TOOLCHAIN)/aarch64-linux-gnu-
endif
KERNEL_PERL := /usr/bin/perl
KERNEL_CROSS_COMPILE :=
KERNEL_CROSS_COMPILE += CC="$(CLANG_CC)"
ifeq ($(BUILD_TYPE), standard)
KERNEL_CROSS_COMPILE += HOSTCC="$(KERNEL_HOSTCC)"
KERNEL_CROSS_COMPILE += PERL=$(KERNEL_PERL)
KERNEL_CROSS_COMPILE += CROSS_COMPILE="$(KERNEL_TARGET_TOOLCHAIN_PREFIX)"
else ifeq ($(BUILD_TYPE), small)
KERNEL_CROSS_COMPILE += CROSS_COMPILE="arm-linux-gnueabi-"
endif
KERNEL_CROSS_COMPILE += CROSS_COMPILE="$(KERNEL_TARGET_TOOLCHAIN_PREFIX)"
KERNEL_MAKE := \
PATH="$(BOOT_IMAGE_PATH):$$PATH" \
@@ -66,7 +54,7 @@ DEVICE_PATCH_DIR := $(OHOS_BUILD_HOME)/kernel/linux/patches/${KERNEL_VERSION}/$(
DEVICE_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME).patch
HDF_PATCH_FILE := $(DEVICE_PATCH_DIR)/hdf.patch
SMALL_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME)_$(BUILD_TYPE).patch
KERNEL_IMAGE_FILE := $(KERNEL_SRC_TMP_PATH)/arch/arm/boot/uImage
KERNEL_IMAGE_FILE := $(KERNEL_SRC_TMP_PATH)/arch/$(KERNEL_ARCH)/boot/$(KERNEL_IMAGE)
DEFCONFIG_FILE := $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig
export KBUILD_OUTPUT=$(KERNEL_OBJ_TMP_PATH)
@@ -85,7 +73,7 @@ endif
ifeq ($(KERNEL_VERSION), linux-5.10)
$(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) modules_prepare
endif
$(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) -j64 uImage
$(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) -j64 $(KERNEL_IMAGE)
endif
.PHONY: build-kernel
build-kernel: $(KERNEL_IMAGE_FILE)
+21 -23
View File
@@ -16,45 +16,43 @@
set -e
export OUT_DIR=$1
export BUILD_TYPE=$2
export KERNEL_ARCH=$3
export PRODUCT_PATH=$4
export DEVICE_NAME=$5
export KERNEL_VERSION=$6
if [ "$2" == "small" ];then
if [ ""x == $(which arm-linux-gnueabi-ld)x ] || [ ""x == $(which arm-linux-gnueabi-gcc)x ];then
echo "Please install gcc-arm-linux-gnueabi, run \"sudo apt-get install gcc-arm-linux-gnueabi\"."
exit 1
fi
export BUILD_TYPE=small
if [ "$BUILD_TYPE" == "small" ];then
LINUX_KERNEL_OUT=${OUT_DIR}/kernel/${KERNEL_VERSION}
if [ "$3" != "" ];then
LLVM_PATH=$3
export CLANG_CC=${LLVM_PATH}/bin/clang
fi
if [ "$5" == "hispark_taurus" ];then
export DEVICE_NAME=hi3516dv300
export DEVICE_NAME=hi3516dv300
fi
elif [ "$2" == "standard" ];then
export BUILD_TYPE=standard
export DEVICE_NAME=$5
elif [ "$BUILD_TYPE" == "standard" ];then
LINUX_KERNEL_OUT=${OUT_DIR}/kernel/src_tmp/${KERNEL_VERSION}
CLANG_BASE_PATH=$3
fi
LINUX_KERNEL_OBJ_OUT=${OUT_DIR}/kernel/OBJ/${KERNEL_VERSION}
export OHOS_ROOT_PATH=$(pwd)/../../..
export PRODUCT_PATH=$4
LINUX_KERNEL_UIMAGE_FILE=${LINUX_KERNEL_OBJ_OUT}/arch/arm/boot/uImage
# it needs adaptation for more device target
kernel_image=""
if [ "$KERNEL_ARCH" == "arm" ];then
kernel_image="uImage"
elif [ "$KERNEL_ARCH" == "arm64" ];then
kernel_image="Image"
fi
export KERNEL_IMAGE=${kernel_image}
LINUX_KERNEL_IMAGE_FILE=${LINUX_KERNEL_OBJ_OUT}/arch/${KERNEL_ARCH}/boot/${kernel_image}
make -f kernel.mk
if [ -f "${LINUX_KERNEL_UIMAGE_FILE}" ];then
echo "uImage: ${LINUX_KERNEL_UIMAGE_FILE} build success"
if [ -f "${LINUX_KERNEL_IMAGE_FILE}" ];then
echo "Image: ${LINUX_KERNEL_IMAGE_FILE} build success"
else
echo "uImage: ${LINUX_KERNEL_UIMAGE_FILE} build failed!!!"
echo "Image: ${LINUX_KERNEL_IMAGE_FILE} build failed!!!"
exit 1
fi
if [ "$2" == "small" ];then
cp -rf ${LINUX_KERNEL_UIMAGE_FILE} ${OUT_DIR}/uImage_${DEVICE_NAME}_smp
if [ "$5" == "hispark_taurus" ];then
cp -rf ${LINUX_KERNEL_IMAGE_FILE} ${OUT_DIR}/uImage_${DEVICE_NAME}_smp
fi
exit 0