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() {
|
declare_args() {
|
||||||
tee_enable = false
|
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")
|
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
||||||
|
|
||||||
tee = ""
|
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)
|
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",
|
exec_script("//build/lite/run_shell_cmd.py",
|
||||||
[
|
[
|
||||||
|
@ -156,8 +160,16 @@ config("public") {
|
||||||
"net:public",
|
"net:public",
|
||||||
"shell:public",
|
"shell:public",
|
||||||
"lib:public",
|
"lib:public",
|
||||||
":std_include",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
configs += [
|
||||||
|
"$HDFTOPDIR:public",
|
||||||
|
"//drivers/liteos:public",
|
||||||
|
]
|
||||||
|
|
||||||
|
if (HAVE_DEVICE_SDK) {
|
||||||
|
configs += [ "$device_path:public" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config("los_nostdinc") {
|
config("los_nostdinc") {
|
||||||
|
@ -259,21 +271,20 @@ config("los_config") {
|
||||||
":arch_config",
|
":arch_config",
|
||||||
":los_nostdinc",
|
":los_nostdinc",
|
||||||
":los_nostdlib",
|
":los_nostdlib",
|
||||||
|
":std_include",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
liteos_name = "liteos2"
|
executable("liteos") {
|
||||||
liteos_out = rebase_path("$target_out_dir/$liteos_name")
|
|
||||||
executable(liteos_name) {
|
|
||||||
configs = [] # clear default configs
|
configs = [] # clear default configs
|
||||||
configs += [ ":los_config" ]
|
configs += [ ":los_config" ]
|
||||||
|
configs += [ ":public" ]
|
||||||
|
|
||||||
ldflags = [
|
ldflags = [
|
||||||
"-static",
|
"-static",
|
||||||
"-Wl,--gc-sections",
|
"-Wl,--gc-sections",
|
||||||
"-Wl,-Map=" + rebase_path("$liteos_out.map"),
|
"-Wl,-Map=$liteos_name.map",
|
||||||
"-Wl,--no-eh-frame-hdr",
|
"-Wl,--no-eh-frame-hdr",
|
||||||
"-Wl,--whole-archive",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
libgcc = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-libgcc-file-name" ], "trim string")
|
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) ]
|
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos_llvm.ld", root_build_dir) ]
|
||||||
} else {
|
} else {
|
||||||
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
|
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
|
||||||
ldflags += [ "-nostartfiles" ]
|
ldflags += [ "-Wl,-nostartfiles" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
output_dir = target_out_dir
|
output_dir = target_out_dir
|
||||||
|
output_name = liteos_name
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":modules",
|
":modules",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
build_ext_component("build_liteos_bin") {
|
copy("copy_liteos") {
|
||||||
deps = [ ":$liteos_name" ]
|
deps = [ ":liteos" ]
|
||||||
exec_path = rebase_path(target_out_dir)
|
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"
|
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
|
||||||
objdump = "${compile_prefix}objdump$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_name $liteos_name.bin"
|
||||||
|
command += " && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
||||||
command = "$objcopy -O binary $liteos $liteos_out.bin"
|
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
|
||||||
command += " && sh -c '$objdump -t $liteos | sort >$liteos_out.sym.sorted'"
|
|
||||||
command += " && sh -c '$objdump -d $liteos >$liteos_out.asm'"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group("modules") {
|
group("modules") {
|
||||||
|
@ -321,6 +337,15 @@ group("modules") {
|
||||||
"shell",
|
"shell",
|
||||||
"syscall",
|
"syscall",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
deps += [
|
||||||
|
"$HDFTOPDIR",
|
||||||
|
"//drivers/liteos",
|
||||||
|
]
|
||||||
|
|
||||||
|
if (HAVE_DEVICE_SDK) {
|
||||||
|
deps += [ device_path ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group("apps") {
|
group("apps") {
|
||||||
|
@ -332,10 +357,7 @@ group("tests") {
|
||||||
}
|
}
|
||||||
|
|
||||||
group("kernel") {
|
group("kernel") {
|
||||||
deps = [
|
deps = [ ":build_kernel_image" ]
|
||||||
":make",
|
|
||||||
":tests",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group("liteos_a") {
|
group("liteos_a") {
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -67,7 +67,7 @@ CONFIG ?= $(PRODUCT_PATH)/config/debug$(tee).config
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(shell which menuconfig),)
|
ifeq ($(shell which menuconfig),)
|
||||||
$(shell pip install --user kconfiglib >/dev/null)
|
$(shell pip3 install --user kconfiglib >/dev/null)
|
||||||
endif
|
endif
|
||||||
$(shell env CONFIG_=$(CONFIG_) DEVICE_PATH=$(DEVICE_PATH) olddefconfig >/dev/null)
|
$(shell env CONFIG_=$(CONFIG_) DEVICE_PATH=$(DEVICE_PATH) olddefconfig >/dev/null)
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,6 @@
|
||||||
|
|
||||||
import("//kernel/liteos_a/liteos.gni")
|
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)
|
module_switch = defined(LOSCFG_DRIVERS)
|
||||||
group("drivers") {
|
group("drivers") {
|
||||||
if (module_switch) {
|
if (module_switch) {
|
||||||
|
@ -43,12 +40,7 @@ group("drivers") {
|
||||||
"char/random",
|
"char/random",
|
||||||
"char/video",
|
"char/video",
|
||||||
"mtd/multi_partition",
|
"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/random:public",
|
||||||
"char/video:public",
|
"char/video:public",
|
||||||
"mtd/multi_partition: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_dir = target_out_dir
|
||||||
output_name = "lib$module_name"
|
|
||||||
output_extension = "O"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group("user") {
|
group("user") {
|
||||||
public_deps = [ ":$module_name" ]
|
public_deps = [ ":$module_name" ]
|
||||||
|
deps = [ ":copy_userinit" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
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, "*")
|
not_needed(invoker, "*")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
static_library(target_name) {
|
source_set(target_name) {
|
||||||
forward_variables_from(invoker, "*")
|
forward_variables_from(invoker, "*")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,6 @@
|
||||||
|
|
||||||
import("//kernel/liteos_a/liteos.gni")
|
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"
|
module_name = "bsp"
|
||||||
kernel_module(module_name) {
|
kernel_module(module_name) {
|
||||||
sources = [ "main.c" ]
|
sources = [ "main.c" ]
|
||||||
|
@ -64,18 +61,10 @@ kernel_module(module_name) {
|
||||||
group("platform") {
|
group("platform") {
|
||||||
public_deps = [ ":$module_name" ]
|
public_deps = [ ":$module_name" ]
|
||||||
deps = [ ":board.ld" ]
|
deps = [ ":board.ld" ]
|
||||||
if (HAVE_BOARD_CONFIG) {
|
|
||||||
deps += [ "//$LOSCFG_BOARD_CONFIG_PATH" ]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
include_dirs = [
|
include_dirs = [ "." ]
|
||||||
".",
|
|
||||||
]
|
|
||||||
if (HAVE_BOARD_CONFIG) {
|
|
||||||
configs = [ "//$LOSCFG_BOARD_CONFIG_PATH:public" ]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
source_set("board") {
|
source_set("board") {
|
||||||
|
@ -84,8 +73,7 @@ source_set("board") {
|
||||||
configs = []
|
configs = []
|
||||||
configs += [
|
configs += [
|
||||||
"$LITEOSTOPDIR:los_config",
|
"$LITEOSTOPDIR:los_config",
|
||||||
"$LITEOSTOPDIR/kernel/base:public",
|
"$LITEOSTOPDIR:public",
|
||||||
":public",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
asmflags = [
|
asmflags = [
|
||||||
|
|
|
@ -29,6 +29,10 @@
|
||||||
|
|
||||||
CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
|
CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
|
||||||
-include $(CONFIG_FILE)
|
-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)
|
ifeq ($(LOSCFG_COMPILER_HIMIX_32), y)
|
||||||
CROSS_COMPILE := arm-linux-ohoseabi-
|
CROSS_COMPILE := arm-linux-ohoseabi-
|
||||||
else ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
else ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||||
|
|
Loading…
Reference in New Issue