refactor: 编译框架对不同工具链的解耦优化

close: #I5GQ9A

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I3e371a67bdab75c53e769e08c1c54ec83c741a69
This commit is contained in:
arvinzzz 2022-07-12 16:46:40 +08:00
parent d92c10d92d
commit 009d2503fb
3 changed files with 36 additions and 30 deletions

View File

@ -31,11 +31,6 @@ import("//build/lite/config/component/lite_component.gni")
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
declare_args() {
liteos_name = "OHOS_Image"
liteos_kernel_only = false
}
import("liteos.gni")
if (defined(LOSCFG_COMPILER_ICCARM)) {
@ -194,15 +189,7 @@ executable("liteos") {
":los_config",
]
if (defined(LOSCFG_COMPILER_ICCARM)) {
ldflags = [ "--map=$liteos_name.map" ]
} else {
ldflags = [
"-static",
"-Wl,--gc-sections",
"-Wl,-Map=$liteos_name.map",
]
}
ldflags = executable_config_ldflags
output_dir = target_out_dir
@ -223,20 +210,5 @@ build_ext_component("build_kernel_image") {
deps = [ ":copy_liteos" ]
exec_path = rebase_path(root_out_dir)
if (defined(LOSCFG_COMPILER_ICCARM)) {
objcopy = "${compile_prefix}ielftool$toolchain_cmd_suffix"
objdump = "${compile_prefix}ielfdumparm$toolchain_cmd_suffix"
command = "$objcopy --bin --verbose $liteos_name $liteos_name.bin"
command +=
" && sh -c '$objdump --source --all $liteos_name -o $liteos_name.asm'"
} else {
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
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'"
}
command = toochain_config_command
}

View File

@ -31,6 +31,9 @@ import("liteos.gni")
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
liteos_name = "OHOS_Image"
liteos_kernel_only = false
#
# arch_config
#
@ -188,3 +191,20 @@ if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
}
misc_config_asmflags += misc_config_cflags
misc_config_asmflags += [ "-DCLZ=CLZ" ]
# ldflags for generating executable bin files
executable_config_ldflags = [
"-static",
"-Wl,--gc-sections",
"-Wl,-Map=$liteos_name.map",
]
# Commands to generate kernel_image
toochain_config_objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
toochain_config_objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
toochain_config_command =
"$toochain_config_objcopy -O binary $liteos_name $liteos_name.bin"
toochain_config_command += " && sh -c '$toochain_config_objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
toochain_config_command +=
" && sh -c '$toochain_config_objdump -d $liteos_name >$liteos_name.asm'"

View File

@ -31,6 +31,9 @@ import("liteos.gni")
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
liteos_name = "OHOS_Image"
liteos_kernel_only = false
#
# arch_config
#
@ -138,3 +141,14 @@ misc_config_cflags = []
misc_config_asmflags = []
misc_config_asmflags += [ "-DCLZ=CLZ" ]
# ldflags for generating executable bin files
executable_config_ldflags = [ "--map=$liteos_name.map" ]
# Commands to generate kernel_image
toochain_config_objcopy = "${compile_prefix}ielftool$toolchain_cmd_suffix"
toochain_config_objdump = "${compile_prefix}ielfdumparm$toolchain_cmd_suffix"
toochain_config_command =
"$toochain_config_objcopy --bin --verbose $liteos_name $liteos_name.bin"
toochain_config_command += " && sh -c '$toochain_config_objdump --source --all $liteos_name -o $liteos_name.asm'"