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'"