From 009d2503fbe2c73a650bfdb18d5e31dd12008eb5 Mon Sep 17 00:00:00 2001 From: arvinzzz Date: Tue, 12 Jul 2022 16:46:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=BC=96=E8=AF=91=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E5=AF=B9=E4=B8=8D=E5=90=8C=E5=B7=A5=E5=85=B7=E9=93=BE?= =?UTF-8?q?=E7=9A=84=E8=A7=A3=E8=80=A6=E4=BC=98=E5=8C=96=20close:=20#I5GQ9?= =?UTF-8?q?A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: arvinzzz Change-Id: I3e371a67bdab75c53e769e08c1c54ec83c741a69 --- BUILD.gn | 32 ++------------------------------ config.gni | 20 ++++++++++++++++++++ config_iccarm.gni | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index be4dec99..0cd45e2d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -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 } diff --git a/config.gni b/config.gni index 13b126b3..f99bfb92 100644 --- a/config.gni +++ b/config.gni @@ -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'" diff --git a/config_iccarm.gni b/config_iccarm.gni index 8153f29d..0b934ff6 100644 --- a/config_iccarm.gni +++ b/config_iccarm.gni @@ -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'"