diff --git a/BUILD.gn b/BUILD.gn index f0ab922f6213d5ff5224e020d0f87686db68600f..8b7b846ecfb48feae78cc841e243eb4dfb8a883d 100644 --- a/BUILD.gn +++ b/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") { diff --git a/Makefile b/Makefile index 5c0c1beaf36be781a0b956c0b5d93f77713f3d20..0647ee9bde4b6e44667cd4f1f10ed7ed6ba65d9c 100644 --- a/Makefile +++ b/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) diff --git a/drivers/BUILD.gn b/drivers/BUILD.gn index 4926f95941834dc2aff6ddacf8e4fcbad965af78..08ef974ca63e9bb05fb0c59892ba4ce873d86ed9 100644 --- a/drivers/BUILD.gn +++ b/drivers/BUILD.gn @@ -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" ] - } } diff --git a/kernel/user/BUILD.gn b/kernel/user/BUILD.gn index 975b37e4e02907dc4803a8492164d3d055df204f..31a7719a78aee5ec69341e53906cf670cfc064b2 100644 --- a/kernel/user/BUILD.gn +++ b/kernel/user/BUILD.gn @@ -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" ] } diff --git a/liteos.gni b/liteos.gni index 5e2e723cccca77ac2cac9b16361a92aa4a314d69..d4ee8660ea1ce895f6c0b780981d7d83d2433676 100644 --- a/liteos.gni +++ b/liteos.gni @@ -39,7 +39,7 @@ template("kernel_module") { not_needed(invoker, "*") } } else { - static_library(target_name) { + source_set(target_name) { forward_variables_from(invoker, "*") } } diff --git a/platform/BUILD.gn b/platform/BUILD.gn index 13c15ef1538fb1b7edfb8bdd99633349e486d1ea..31928452e100291e74c46b1f87567e3e3fba090d 100644 --- a/platform/BUILD.gn +++ b/platform/BUILD.gn @@ -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 = [ diff --git a/tools/build/mk/los_config.mk b/tools/build/mk/los_config.mk index 840f64b239b633d7833d23b00c242c7808711dfe..2d273619ce7926ccede64cfc5744a885dcbc0da6 100644 --- a/tools/build/mk/los_config.mk +++ b/tools/build/mk/los_config.mk @@ -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)