kernel: Add TARGET_FORCE_PREBUILT_KERNEL flag

* TARGET_FORCE_PREBUILT_KERNEL should be useful when you don't have ready kernel sources (OEM releasing broken sources or releasing them lately)
* It lets you use kernel sources for userspace generated headers (generated_kernel_headers) while keeping using prebuilt kernel
* Keep in mind that generated kernel headers may not align with the ABI of kernel you're including
* This commit also partially revert commit a836d79, where TARGET_KERNEL_SOURCE would have been unset if TARGET_PREBUILT_KERNEL was defined (we already check in kernel.mk if kernel sources are present anyway)

Change-Id: I84acae890dabb5b9dbd48143ad58f6420c0cef75
This commit is contained in:
Sebastiano Barezzi
2021-02-09 00:31:49 +01:00
parent 5f7f10de7b
commit c86a1a8128
2 changed files with 25 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
# Copyright (C) 2012 The CyanogenMod Project
# (C) 2017-2020 The LineageOS Project
# (C) 2017-2021 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -61,6 +61,9 @@
# modules in system instead of vendor
# NEED_KERNEL_MODULE_VENDOR_OVERLAY = Optional, if true, install kernel
# modules in vendor_overlay instead of vendor
#
# TARGET_FORCE_PREBUILT_KERNEL = Optional, use TARGET_PREBUILT_KERNEL even if
# kernel sources are present
ifneq ($(TARGET_NO_KERNEL),true)
ifneq ($(TARGET_NO_KERNEL_OVERRIDE),true)
@@ -153,8 +156,27 @@ else
$(warning **********************************************************)
$(error "NO KERNEL CONFIG")
else
FULL_KERNEL_BUILD := true
KERNEL_BIN := $(TARGET_PREBUILT_INT_KERNEL)
ifeq ($(filter RELEASE NIGHTLY SNAPSHOT EXPERIMENTAL,$(LINEAGE_BUILDTYPE)),)
$(error "PREBUILT KERNEL IS NOT ALLOWED ON OFFICIAL BUILDS!")
else
ifneq ($(TARGET_FORCE_PREBUILT_KERNEL),)
$(warning **********************************************************)
$(warning * Kernel source found and configuration was defined, *)
$(warning * but prebuilt kernel is being forced. *)
$(warning * While this is likely intentional, *)
$(warning * it is NOT SUPPORTED WHATSOEVER. *)
$(warning * Generated kernel headers may not align with *)
$(warning * the ABI of kernel you're including. *)
$(warning * Please unset TARGET_FORCE_PREBUILT_KERNEL *)
$(warning * to build the kernel from source. *)
$(warning **********************************************************)
FULL_KERNEL_BUILD := false
KERNEL_BIN := $(TARGET_PREBUILT_KERNEL)
else
FULL_KERNEL_BUILD := true
KERNEL_BIN := $(TARGET_PREBUILT_INT_KERNEL)
endif
endif
endif
endif

View File

@@ -41,9 +41,6 @@ BUILD_TOP := $(shell pwd)
TARGET_AUTO_KDIR := $(shell echo $(TARGET_DEVICE_DIR) | sed -e 's/^device/kernel/g')
TARGET_KERNEL_SOURCE ?= $(TARGET_AUTO_KDIR)
ifneq ($(TARGET_PREBUILT_KERNEL),)
TARGET_KERNEL_SOURCE :=
endif
TARGET_KERNEL_ARCH := $(strip $(TARGET_KERNEL_ARCH))
ifeq ($(TARGET_KERNEL_ARCH),)