feat: Board 和 SoC分离,编译适配

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 <likailong@huawei.com>
Change-Id: Iaa2ffc6e56ab9127bb13dbbb934414f63dfbcdc2
This commit is contained in:
SimonLi 2021-11-19 04:41:03 +08:00
parent b7de7f6085
commit 3f1c04dd57
3 changed files with 57 additions and 4 deletions

View File

@ -44,6 +44,7 @@ print("liteos_config_file:", liteos_config_file)
exec_script("//build/lite/run_shell_cmd.py", exec_script("//build/lite/run_shell_cmd.py",
[ "env" + " CONFIG_=LOSCFG_" + " KCONFIG_CONFIG_HEADER='y=true'" + [ "env" + " CONFIG_=LOSCFG_" + " KCONFIG_CONFIG_HEADER='y=true'" +
" KCONFIG_CONFIG=$liteos_config_file" + " KCONFIG_CONFIG=$liteos_config_file" +
" BOARD_COMPANY=$device_company" +
" DEVICE_PATH=$device_path" + " srctree=" + rebase_path(".") + " DEVICE_PATH=$device_path" + " srctree=" + rebase_path(".") +
" genconfig" + " --header-path $LITEOS_MENUCONFIG_H" + " genconfig" + " --header-path $LITEOS_MENUCONFIG_H" +
" --file-list kconfig_files.txt" + " --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" 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") 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") { config("public") {
configs = [ configs = [
"arch:public", "arch:public",
@ -232,8 +236,13 @@ config("public") {
"utils:public", "utils:public",
] ]
if (HAVE_DEVICE_SDK) { if (BOARD_SOC_FEATURE) {
configs += [ "$device_path:public" ] configs += [ "//device/board/$device_company:public" ]
configs += [ "//device/soc/$LOSCFG_SOC_COMPANY:public" ]
} else {
if (HAVE_DEVICE_SDK) {
configs += [ "$device_path:public" ]
}
} }
configs += configs +=
@ -252,14 +261,22 @@ group("modules") {
HDFTOPDIR, HDFTOPDIR,
] ]
if (HAVE_DEVICE_SDK) { if (BOARD_SOC_FEATURE) {
deps += [ device_path ] 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/bounds_checking_function:libsec_static" ]
deps += [ "$LITEOSTHIRDPARTY/musl/porting/liteos_m/kernel" ] 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") { static_library("libkernel") {
deps = [ ":modules" ] deps = [ ":modules" ]
public_configs = [ public_configs = [

29
Kconfig
View File

@ -177,6 +177,35 @@ source "arch/Kconfig"
# Device Kconfig import # Device Kconfig import
osource "$(DEVICE_PATH)/Kconfig" 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 config QUICK_START
bool "Enable QUICK_START" bool "Enable QUICK_START"
default n default n

View File

@ -48,6 +48,10 @@ ifeq ($(DEVICE_PATH),)
DEVICE_PATH:=$(ohos_device_path) DEVICE_PATH:=$(ohos_device_path)
endif endif
ifeq ($(BOARD_COMPANY),)
BOARD_COMPANY:=$(ohos_device_company)
endif
ifeq ($(TEE:1=y),y) ifeq ($(TEE:1=y),y)
tee = _tee tee = _tee
endif endif
@ -64,6 +68,9 @@ LITEOS_CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
# export los_config.mk related environment variables # export los_config.mk related environment variables
export LITEOS_MENUCONFIG_H export LITEOS_MENUCONFIG_H
export LITEOS_CONFIG_FILE export LITEOS_CONFIG_FILE
export BOARD_COMPANY
export DEVICE_PATH
export PRODUCT_PATH
# export kconfig related environment variables # export kconfig related environment variables
export CONFIG_=LOSCFG_ export CONFIG_=LOSCFG_