diff mbox series

[1/1] boot/edk2: add support for custom configuration.

Message ID tencent_8FFB06F67FA524B2D90D051931B1F0082405@qq.com
State New
Headers show
Series [1/1] boot/edk2: add support for custom configuration. | expand

Commit Message

Cheng Yang Jan. 24, 2024, 11:10 a.m. UTC
From: Cheng Yang <yangcheng.work@foxmail.com>

EDK2 currently only supports github, but sometimes
we may need to customize the source of EDK2 to support
applications in some specific scenarios, such as github
access is limited or some repositories that have not
yet been merged into the mainline.

Therefore, this commit adds the possibility to specify custom
EDK2 version, custom version from upstream, custom tarball or
Customizations from Git. Just like OpenSBI, Uboot or Linux.

Signed-off-by: Cheng Yang <yangcheng.work@foxmail.com>
---
 boot/edk2/Config.in | 50 +++++++++++++++++++++++++++++++++++++++++++++
 boot/edk2/edk2.mk   | 15 +++++++++++++-
 2 files changed, 64 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/boot/edk2/Config.in b/boot/edk2/Config.in
index 4e6e7d122c..c9f592a9a5 100644
--- a/boot/edk2/Config.in
+++ b/boot/edk2/Config.in
@@ -17,6 +17,56 @@  config BR2_TARGET_EDK2
 	  https://github.com/tianocore/tianocore.github.io/wiki/EDK-II
 
 if BR2_TARGET_EDK2
+choice 
+	prompt "EDK2 Version"
+	help
+	  Select the specific EDK2 version you want to use
+
+config BR2_TARGET_EDK2_LATEST_VERSION
+	bool "edk2-stable202308"
+
+config BR2_TARGET_EDK2_CUSTOM_VERSION
+	bool "Custom version"
+	help
+	  This option allows to use a specific official versions
+
+config BR2_TARGET_EDK2_CUSTOM_TARBALL
+	bool "Custom tarball"
+
+config BR2_TARGET_EDK2_CUSTOM_GIT
+	bool "Custom Git repository"
+
+endchoice
+
+config BR2_TARGET_EDK2_CUSTOM_VERSION_VALUE
+	string "EDK2 version"
+	depends on BR2_TARGET_EDK2_CUSTOM_VERSION
+
+config BR2_TARGET_EDK2_CUSTOM_TARBALL_LOCATION
+	string "URL of custom EDK2 tarball"
+	depends on BR2_TARGET_EDK2_CUSTOM_TARBALL
+
+if BR2_TARGET_EDK2_CUSTOM_GIT
+
+config BR2_TARGET_EDK2_CUSTOM_REPO_URL
+	string "URL of custom repository"
+
+config BR2_TARGET_EDK2_CUSTOM_REPO_VERSION
+	string "Custom repository version"
+	help
+	  Revision to use in the typical format used by Git. E.G. a
+	  sha id, a tag, branch, ..
+
+endif
+
+config BR2_TARGET_EDK2_VERSION
+	string
+	default "edk2-stable202308" if BR2_TARGET_EDK2_LATEST_VERSION
+	default BR2_TARGET_EDK2_CUSTOM_VERSION_VALUE \
+		if BR2_TARGET_EDK2_CUSTOM_VERSION
+	default "custom" if BR2_TARGET_EDK2_CUSTOM_TARBALL
+	default BR2_TARGET_EDK2_CUSTOM_REPO_VERSION \
+		if BR2_TARGET_EDK2_CUSTOM_GIT
 
 choice
 	prompt "Platform"
diff --git a/boot/edk2/edk2.mk b/boot/edk2/edk2.mk
index 87ac80c88f..0f8aed703e 100644
--- a/boot/edk2/edk2.mk
+++ b/boot/edk2/edk2.mk
@@ -4,9 +4,22 @@ 
 #
 ################################################################################
 
-EDK2_VERSION = edk2-stable202308
+EDK2_VERSION = $(call qstrip,$(BR2_TARGET_EDK2_VERSION))
+
+ifeq ($(BR2_TARGET_EDK2_CUSTOM_TARBALL),y)
+# Handle custom EDK2 tarballs as specified by the configuration
+EDK2_TARBALL = $(call qstrip,$(BR2_TARGET_EDK2_CUSTOM_TARBALL_LOCATION))
+EDK2_SITE = $(patsubst %/,%,$(dir $(EDK2_TARBALL)))
+EDK2_SOURCE = $(notdir $(EDK2_TARBALL))
+else ifeq ($(BR2_TARGET_EDK2_CUSTOM_GIT),y)
+EDK2_SITE = $(call qstrip,$(BR2_TARGET_EDK2_CUSTOM_REPO_URL))
+EDK2_SITE_METHOD = git
+else
+# Handle official EDK2 versions
 EDK2_SITE = https://github.com/tianocore/edk2
 EDK2_SITE_METHOD = git
+endif
+
 EDK2_LICENSE = BSD-2-Clause-Patent
 EDK2_LICENSE_FILES = License.txt
 EDK2_CPE_ID_VENDOR = tianocore