When building android project, we can use prebuilt linux kernel or kernel source code.
About how to add new product in AOSP and android build steps,please refer to Android build tips andAndroid Makefile 具体是 如何识别 TARGET_PRODUCT 变量
I want to use an example to elaborate the build step of a product and how to build kernel.
Example: Add a new flounder device on Nougat. Htc/flounder is already on Nougat, but I want to use different configuration to build it. So I define a new flounder product and add different configurations.
1. Define vendorsetup.sh (device/company/tablet/products/vendorsetup.sh)-------------use print_lunch_menu command to check
add_lunch_combo firetab_flounder-userdebug
2. Define PRODUCT_MAKEFILES in device/company/tablet/products/flounder/AndroidProducts.mk
9PRODUCT_MAKEFILES := \ 10 $(LOCAL_DIR)/firetab_flounder.mk
3. When executing "lunch firetab_flounder-userdebug" command, build system will searching firetab_flounder.mk and execute it. ----use "make dump-products" to check
You can also define TARGET_PREBUILT_KERNEL to provider prebuilt kernel path if you want to build kernel from prebuilt binary.
9# Setup to build custom kernel 10KERNEL_CFG_NAME ?= flounder 11KERNEL_SRC_DIR ?= kernel/htc/flounder 12TARGET_KERNEL_ARCH ?= arm64 13KERNEL_OUT_DIR ?= $(PRODUCT_OUT)/linux/kernel ----------------- $(PRODUCT_OUT)=out/target/product/flounder32 14 15# Check for availability of kernel source 16ifneq ($(wildcard $(KERNEL_SRC_DIR)/Makefile),) 17 # Give precedence to TARGET_PREBUILT_KERNEL 18 ifeq ($(TARGET_PREBUILT_KERNEL),) 19 TARGET_KERNEL_BUILT_FROM_SOURCE := true 20 endif 21endif