feat: build OHOS_Image from kernel
using OHOS_Image as liteos default name Signed-off-by: Caoruihong <crh.cao@huawei.com> Change-Id: I00bcc9a6747ffde0f07f3d243150055a644df02f
This commit is contained in:
parent
0dc79479ff
commit
abf4d8fb25
62
BUILD.gn
62
BUILD.gn
|
@ -31,8 +31,12 @@ import("//build/lite/config/component/lite_component.gni")
|
|||
|
||||
declare_args() {
|
||||
tee_enable = false
|
||||
liteos_name = "OHOS_Image"
|
||||
}
|
||||
|
||||
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")
|
||||
|
||||
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
||||
|
||||
tee = ""
|
||||
|
@ -66,7 +70,7 @@ if (exec_script("//build/lite/run_shell_cmd.py", [ "if [ -f $f ]; then echo true
|
|||
|
||||
print("liteos_config_file:", liteos_config_file)
|
||||
|
||||
exec_script("//build/lite/run_shell_cmd.py", [ "which genconfig || pip install --user kconfiglib" ])
|
||||
exec_script("//build/lite/run_shell_cmd.py", [ "which genconfig || pip3 install --user kconfiglib" ])
|
||||
|
||||
exec_script("//build/lite/run_shell_cmd.py",
|
||||
[
|
||||
|
@ -156,8 +160,16 @@ config("public") {
|
|||
"net:public",
|
||||
"shell:public",
|
||||
"lib:public",
|
||||
":std_include",
|
||||
]
|
||||
|
||||
configs += [
|
||||
"$HDFTOPDIR:public",
|
||||
"//drivers/liteos:public",
|
||||
]
|
||||
|
||||
if (HAVE_DEVICE_SDK) {
|
||||
configs += [ "$device_path:public" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("los_nostdinc") {
|
||||
|
@ -259,21 +271,20 @@ config("los_config") {
|
|||
":arch_config",
|
||||
":los_nostdinc",
|
||||
":los_nostdlib",
|
||||
":std_include",
|
||||
]
|
||||
}
|
||||
|
||||
liteos_name = "liteos2"
|
||||
liteos_out = rebase_path("$target_out_dir/$liteos_name")
|
||||
executable(liteos_name) {
|
||||
executable("liteos") {
|
||||
configs = [] # clear default configs
|
||||
configs += [ ":los_config" ]
|
||||
configs += [ ":public" ]
|
||||
|
||||
ldflags = [
|
||||
"-static",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,-Map=" + rebase_path("$liteos_out.map"),
|
||||
"-Wl,-Map=$liteos_name.map",
|
||||
"-Wl,--no-eh-frame-hdr",
|
||||
"-Wl,--whole-archive",
|
||||
]
|
||||
|
||||
libgcc = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-libgcc-file-name" ], "trim string")
|
||||
|
@ -282,28 +293,33 @@ executable(liteos_name) {
|
|||
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos_llvm.ld", root_build_dir) ]
|
||||
} else {
|
||||
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
|
||||
ldflags += [ "-nostartfiles" ]
|
||||
ldflags += [ "-Wl,-nostartfiles" ]
|
||||
}
|
||||
|
||||
output_dir = target_out_dir
|
||||
output_name = liteos_name
|
||||
|
||||
deps = [
|
||||
":modules",
|
||||
]
|
||||
}
|
||||
|
||||
build_ext_component("build_liteos_bin") {
|
||||
deps = [ ":$liteos_name" ]
|
||||
exec_path = rebase_path(target_out_dir)
|
||||
copy("copy_liteos") {
|
||||
deps = [ ":liteos" ]
|
||||
sources = [ "$target_out_dir/unstripped/bin/$liteos_name" ]
|
||||
outputs = [ "$root_out_dir/{{source_file_part}}" ]
|
||||
}
|
||||
|
||||
build_ext_component("build_kernel_image") {
|
||||
deps = [ ":copy_liteos" ]
|
||||
exec_path = rebase_path(root_out_dir)
|
||||
|
||||
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
|
||||
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
|
||||
|
||||
liteos = rebase_path("$target_out_dir/unstripped/bin/$liteos_name")
|
||||
|
||||
command = "$objcopy -O binary $liteos $liteos_out.bin"
|
||||
command += " && sh -c '$objdump -t $liteos | sort >$liteos_out.sym.sorted'"
|
||||
command += " && sh -c '$objdump -d $liteos >$liteos_out.asm'"
|
||||
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
|
||||
command += " && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
||||
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
|
||||
}
|
||||
|
||||
group("modules") {
|
||||
|
@ -321,6 +337,15 @@ group("modules") {
|
|||
"shell",
|
||||
"syscall",
|
||||
]
|
||||
|
||||
deps += [
|
||||
"$HDFTOPDIR",
|
||||
"//drivers/liteos",
|
||||
]
|
||||
|
||||
if (HAVE_DEVICE_SDK) {
|
||||
deps += [ device_path ]
|
||||
}
|
||||
}
|
||||
|
||||
group("apps") {
|
||||
|
@ -332,10 +357,7 @@ group("tests") {
|
|||
}
|
||||
|
||||
group("kernel") {
|
||||
deps = [
|
||||
":make",
|
||||
":tests",
|
||||
]
|
||||
deps = [ ":build_kernel_image" ]
|
||||
}
|
||||
|
||||
group("liteos_a") {
|
||||
|
|
2
Makefile
2
Makefile
|
@ -67,7 +67,7 @@ CONFIG ?= $(PRODUCT_PATH)/config/debug$(tee).config
|
|||
endif
|
||||
|
||||
ifeq ($(shell which menuconfig),)
|
||||
$(shell pip install --user kconfiglib >/dev/null)
|
||||
$(shell pip3 install --user kconfiglib >/dev/null)
|
||||
endif
|
||||
$(shell env CONFIG_=$(CONFIG_) DEVICE_PATH=$(DEVICE_PATH) olddefconfig >/dev/null)
|
||||
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
cmd = "if [ -f $device_path/drivers/BUILD.gn ]; then echo true; else echo false; fi"
|
||||
HAVE_DEVICE_DRIVERS = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
|
||||
|
||||
module_switch = defined(LOSCFG_DRIVERS)
|
||||
group("drivers") {
|
||||
if (module_switch) {
|
||||
|
@ -43,12 +40,7 @@ group("drivers") {
|
|||
"char/random",
|
||||
"char/video",
|
||||
"mtd/multi_partition",
|
||||
"//drivers/adapter/khdf/liteos",
|
||||
"//drivers/liteos",
|
||||
]
|
||||
if (HAVE_DEVICE_DRIVERS) {
|
||||
deps += [ "$device_path/drivers" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,10 +53,5 @@ config("public") {
|
|||
"char/random:public",
|
||||
"char/video:public",
|
||||
"mtd/multi_partition:public",
|
||||
"//drivers/adapter/khdf/liteos:public",
|
||||
"//drivers/liteos:public",
|
||||
]
|
||||
if (HAVE_DEVICE_DRIVERS) {
|
||||
configs += [ "$device_path/drivers:public" ]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,14 +50,18 @@ executable(module_name) {
|
|||
]
|
||||
|
||||
output_dir = target_out_dir
|
||||
output_name = "lib$module_name"
|
||||
output_extension = "O"
|
||||
}
|
||||
|
||||
group("user") {
|
||||
public_deps = [ ":$module_name" ]
|
||||
deps = [ ":copy_userinit" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
lib_dirs = [ "$target_out_dir/unstripped/bin" ]
|
||||
}
|
||||
|
||||
copy("copy_userinit") {
|
||||
deps = [ ":$module_name" ]
|
||||
sources = [ "$target_out_dir/unstripped/bin/$module_name" ]
|
||||
outputs = [ "$root_out_dir/lib$module_name.O" ]
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ template("kernel_module") {
|
|||
not_needed(invoker, "*")
|
||||
}
|
||||
} else {
|
||||
static_library(target_name) {
|
||||
source_set(target_name) {
|
||||
forward_variables_from(invoker, "*")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
cmd = "if [ -f " + rebase_path("//$LOSCFG_BOARD_CONFIG_PATH/BUILD.gn") + " ]; then echo true; else echo false; fi"
|
||||
HAVE_BOARD_CONFIG = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
|
||||
|
||||
module_name = "bsp"
|
||||
kernel_module(module_name) {
|
||||
sources = [ "main.c" ]
|
||||
|
@ -64,18 +61,10 @@ kernel_module(module_name) {
|
|||
group("platform") {
|
||||
public_deps = [ ":$module_name" ]
|
||||
deps = [ ":board.ld" ]
|
||||
if (HAVE_BOARD_CONFIG) {
|
||||
deps += [ "//$LOSCFG_BOARD_CONFIG_PATH" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [
|
||||
".",
|
||||
]
|
||||
if (HAVE_BOARD_CONFIG) {
|
||||
configs = [ "//$LOSCFG_BOARD_CONFIG_PATH:public" ]
|
||||
}
|
||||
include_dirs = [ "." ]
|
||||
}
|
||||
|
||||
source_set("board") {
|
||||
|
@ -84,8 +73,7 @@ source_set("board") {
|
|||
configs = []
|
||||
configs += [
|
||||
"$LITEOSTOPDIR:los_config",
|
||||
"$LITEOSTOPDIR/kernel/base:public",
|
||||
":public",
|
||||
"$LITEOSTOPDIR:public",
|
||||
]
|
||||
|
||||
asmflags = [
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
|
||||
CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
|
||||
-include $(CONFIG_FILE)
|
||||
LOSCFG_BOARD_CONFIG_PATH := $(LOSCFG_BOARD_CONFIG_PATH:"%"=%)
|
||||
ifeq ($(wildcard $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) $(LOSCFG_BOARD_CONFIG_PATH)),)
|
||||
LOSCFG_BOARD_CONFIG_PATH := $(LOSCFG_BOARD_CONFIG_PATH:%/config/board=%/board)
|
||||
endif
|
||||
ifeq ($(LOSCFG_COMPILER_HIMIX_32), y)
|
||||
CROSS_COMPILE := arm-linux-ohoseabi-
|
||||
else ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
|
|
Loading…
Reference in New Issue