build: add new KERNEL_GIT_DEPTH feature

Its PITA to clone some huge external Git kernel trees, so lets make the
work with such Git repositories faster by introducing new
`KERNEL_GIT_DEPTH` feature which is going to clone such repositories
with `--depth 1` by default, since we don't need Git history as the
source tree is going to be packed into the tarball in download directory
anyway.

Signed-off-by: Marvin Lu <marvin.lu@wnc.com.tw>
Signed-off-by: Petr Štetiar <ynezz@true.cz> [refactor]
This commit is contained in:
Marvin Lu
2023-12-22 17:40:45 +00:00
committed by Petr Štetiar
parent 4dbbed7d2d
commit 00cad4113a
4 changed files with 12 additions and 0 deletions

View File

@@ -110,6 +110,12 @@ menuconfig DEVEL
It can be a git hash or a branch name.
If unused, the clone's repository HEAD will be checked-out.
config KERNEL_GIT_DEPTH
int "Shallow clone with a history truncated to the specified number of commits" if DEVEL
depends on (KERNEL_GIT_CLONE_URI != "")
range 1 2147483647
default 1
config KERNEL_GIT_MIRROR_HASH
string "Enter hash of Git kernel tree source checkout tarball" if DEVEL
depends on (KERNEL_GIT_CLONE_URI != "")

View File

@@ -308,6 +308,7 @@ define Download/default
$(if $(PKG_SOURCE_MIRROR),MIRROR:=$(filter 1,$(PKG_MIRROR)))
$(if $(PKG_MIRROR_MD5SUM),MIRROR_MD5SUM:=$(PKG_MIRROR_MD5SUM))
$(if $(PKG_MIRROR_HASH),MIRROR_HASH:=$(PKG_MIRROR_HASH))
$(if $(PKG_MIRROR_DEPTH),OPTS+=--depth $(PKG_MIRROR_DEPTH))
VERSION:=$(PKG_SOURCE_VERSION)
$(if $(PKG_MD5SUM),MD5SUM:=$(PKG_MD5SUM))
$(if $(PKG_HASH),HASH:=$(PKG_HASH))

View File

@@ -48,6 +48,10 @@ ifneq ($(strip $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY)),"")
KERNEL_GIT_OPTS+=--reference $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY)
endif
ifneq ($(strip $(CONFIG_KERNEL_GIT_DEPTH)),"")
KERNEL_GIT_OPTS+=--depth $(CONFIG_KERNEL_GIT_DEPTH)
endif
define Download/git-kernel
URL:=$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI))
PROTO:=git

View File

@@ -23,6 +23,7 @@ ifneq ($(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
PKG_SOURCE_URL:=$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI))
PKG_SOURCE_VERSION:=$(call qstrip,$(CONFIG_KERNEL_GIT_REF))
PKG_MIRROR_HASH:=$(call qstrip,$(CONFIG_KERNEL_GIT_MIRROR_HASH))
PKG_MIRROR_DEPTH:=$(call qstrip,$(CONFIG_KERNEL_GIT_DEPTH))
ifdef CHECK
PLATFORM_DIR:=$(firstword $(wildcard $(TOPDIR)/target/linux/feeds/$(BOARD) $(TOPDIR)/target/linux/$(BOARD)))
include $(PLATFORM_DIR)/Makefile