From 3f1c04dd57bca0379ce37162d9d824801e7d880f Mon Sep 17 00:00:00 2001 From: SimonLi Date: Fri, 19 Nov 2021 04:41:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Board=20=E5=92=8C=20SoC=E5=88=86?= =?UTF-8?q?=E7=A6=BB=EF=BC=8C=E7=BC=96=E8=AF=91=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. BUILD.gn 根据device_path中是否包含board,来判别 SoC 和 Board 分离特性是否打开, 根据特性开关兼容以前老的Build.gn编译方式 2. Makefile 中新增BOARD_COMPANY环境变量传给Kconfig,确定选择哪一个 Board 3. Kconfig 兼容老的形式,新增 device 路径下 Kconfig.liteos_m.xxxx 表示为 liteos_m 适配 Kconfig 功能,不会影响其他内核适配。主要是同个device 路径下,会有多个不同的 内核进行适配Kconfig。 Signed-off-by: SimonLi Change-Id: Iaa2ffc6e56ab9127bb13dbbb934414f63dfbcdc2 --- BUILD.gn | 25 +++++++++++++++++++++---- Kconfig | 29 +++++++++++++++++++++++++++++ Makefile | 7 +++++++ 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index de52d0a4..d5dcfe3f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -44,6 +44,7 @@ print("liteos_config_file:", liteos_config_file) exec_script("//build/lite/run_shell_cmd.py", [ "env" + " CONFIG_=LOSCFG_" + " KCONFIG_CONFIG_HEADER='y=true'" + " KCONFIG_CONFIG=$liteos_config_file" + + " BOARD_COMPANY=$device_company" + " DEVICE_PATH=$device_path" + " srctree=" + rebase_path(".") + " genconfig" + " --header-path $LITEOS_MENUCONFIG_H" + " --file-list kconfig_files.txt" + @@ -223,6 +224,9 @@ config("los_config") { cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi" HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") +# board and soc decoupling feature, device_path should contains board +BOARD_SOC_FEATURE = device_path != string_replace(device_path, "/board/", "") + config("public") { configs = [ "arch:public", @@ -232,8 +236,13 @@ config("public") { "utils:public", ] - if (HAVE_DEVICE_SDK) { - configs += [ "$device_path:public" ] + if (BOARD_SOC_FEATURE) { + configs += [ "//device/board/$device_company:public" ] + configs += [ "//device/soc/$LOSCFG_SOC_COMPANY:public" ] + } else { + if (HAVE_DEVICE_SDK) { + configs += [ "$device_path:public" ] + } } configs += @@ -252,14 +261,22 @@ group("modules") { HDFTOPDIR, ] - if (HAVE_DEVICE_SDK) { - deps += [ device_path ] + if (BOARD_SOC_FEATURE) { + deps += [ "//device/board/$device_company" ] + deps += [ "//device/soc/$LOSCFG_SOC_COMPANY" ] + } else { + if (HAVE_DEVICE_SDK) { + deps += [ device_path ] + } } deps += [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ] deps += [ "$LITEOSTHIRDPARTY/musl/porting/liteos_m/kernel" ] } +# when HAVE_DEVICE_SDK is not reached, gn raises an error. so we just use it as +# not needed +not_needed("*", [ "$HAVE_DEVICE_SDK" ]) static_library("libkernel") { deps = [ ":modules" ] public_configs = [ diff --git a/Kconfig b/Kconfig index 57f154df..0f80f4a5 100644 --- a/Kconfig +++ b/Kconfig @@ -177,6 +177,35 @@ source "arch/Kconfig" # Device Kconfig import osource "$(DEVICE_PATH)/Kconfig" +config SOC_COMPANY + string "SoC company name to locate soc build path" + help + This option specifies the SoC company name, used to locate the build path for soc. This option is set by the + SoC's Kconfig file, and should be exactly the same with SoC company path, and the user should generally avoid + modifying it via the menu configuration. + +orsource "../../device/board/*/Kconfig.liteos_m.shields" + +orsource "../../device/board/$(BOARD_COMPANY)/Kconfig.liteos_m.defconfig.boards" + +choice + prompt "Board Selection" + +orsource "../../device/board/$(BOARD_COMPANY)/Kconfig.liteos_m.boards" + +endchoice + +orsource "../../device/soc/*/Kconfig.liteos_m.defconfig" + +choice + prompt "SoC Series Selection" + +orsource "../../device/soc/*/Kconfig.liteos_m.series" + +endchoice + +orsource "../../device/soc/*/Kconfig.liteos_m.soc" + config QUICK_START bool "Enable QUICK_START" default n diff --git a/Makefile b/Makefile index 244aeef8..192f54a3 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,10 @@ ifeq ($(DEVICE_PATH),) DEVICE_PATH:=$(ohos_device_path) endif +ifeq ($(BOARD_COMPANY),) +BOARD_COMPANY:=$(ohos_device_company) +endif + ifeq ($(TEE:1=y),y) tee = _tee endif @@ -64,6 +68,9 @@ LITEOS_CONFIG_FILE ?= $(LITEOSTOPDIR)/.config # export los_config.mk related environment variables export LITEOS_MENUCONFIG_H export LITEOS_CONFIG_FILE +export BOARD_COMPANY +export DEVICE_PATH +export PRODUCT_PATH # export kconfig related environment variables export CONFIG_=LOSCFG_