diff --git a/Makefile b/Makefile index b0b1014eb832197328e437bd243fe6f5cf50dd5c..c0e14748699d74bac4e2f7eee7ff1179a9d06779 100644 --- a/Makefile +++ b/Makefile @@ -152,8 +152,9 @@ $(LITEOS_LIBS_TARGET): $(__LIBS) sysroot $(HIDE)echo "=============== make lib done ===============" ##### make menuconfig ##### -menuconfig: - $(HIDE)menuconfig +KCONFIG_CMDS = $(notdir $(wildcard $(dir $(shell which menuconfig))*config)) +$(KCONFIG_CMDS): + $(HIDE)$@ $(args) ##### menuconfig end ####### $(LITEOS_MENUCONFIG_H): .config @@ -229,4 +230,4 @@ update_config: $(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig && savedefconfig --out "$(CONFIG)" .PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help update_all_config update_config -.PHONY: prepare sysroot cleanrootfs $(ROOTFS) $(ROOTFSDIR) $(APPS) menuconfig $(LITEOS_LIBS_TARGET) $(__LIBS) $(OUT) +.PHONY: prepare sysroot cleanrootfs $(ROOTFS) $(ROOTFSDIR) $(APPS) $(KCONFIG_CMDS) $(LITEOS_LIBS_TARGET) $(__LIBS) $(OUT) diff --git a/apps/BUILD.gn b/apps/BUILD.gn index 3e19700780c655ed86b0db07f530373d2108aa7c..2edc1d0c479012dcdfbe5da6ec386b491e435374 100644 --- a/apps/BUILD.gn +++ b/apps/BUILD.gn @@ -35,13 +35,13 @@ group("apps") { if (defined(LOSCFG_SHELL)) { deps += [ "shell", - #"mksh", - #"toybox", + "mksh", + "toybox", ] } if (defined(LOSCFG_USER_INIT_DEBUG)) { - #deps += [ "init" ] + deps += [ "init" ] } if (defined(LOSCFG_NET_LWIP_SACK_TFTP)) { diff --git a/apps/mksh/BUILD.gn b/apps/mksh/BUILD.gn index a09888e53386cd182ea436163c0af23cbcc1a70d..12e6691e386cae180446e3b469858fe036d048a9 100644 --- a/apps/mksh/BUILD.gn +++ b/apps/mksh/BUILD.gn @@ -34,7 +34,56 @@ group("mksh") { deps = [ ":build_mksh" ] } +copy("copy_mksh_src") { + sources = [ "$LITEOSTHIRDPARTY/mksh" ] + outputs = [ "$target_out_dir/mksh_build" ] +} + build_ext_component("build_mksh") { - exec_path = rebase_path(target_out_dir) - command = "make -C $LITEOSTHIRDPARTY/mksh" + deps = [ ":copy_mksh_src" ] + deps += [ "//prebuilts/lite/sysroot" ] + exec_path = rebase_path("$target_out_dir/mksh_build") + + cflags = [ + "-flto", + "-fdata-sections", + "-ffunction-sections", + "-Oz", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-DMKSH_DISABLE_TTY_WARNING", + "-DMKSH_SMALL=1", + "-DMKSH_ASSUME_UTF8=1", + "-DMKSH_SMALL_BUT_FAST=0", + "-DMKSH_S_NOVI=1", + "-DHAVE_CAN_FSTACKPROTECTORSTRONG=1", + "-DMKSH_LESS_CMDLINE_EDITING", + "-DMKSH_LESS_BUILDINS", + "-DMKSH_NO_INITCOMS", + "-DADAPT_FOR_LITEOS_A", + ] + cflags = string_join(" ", cflags) + + extra_flags = string_join(" ", target_arch_cflags) + if (ohos_build_compiler == "clang") { + extra_flags += " --target=$target_triple" + extra_flags += " --sysroot=" + rebase_path(ohos_current_sysroot) + } + + command = "rm -rf .git && env" + command += " CC=\"$ohos_current_cc_command\"" + command += " TARGET_OS=OpenHarmony" + command += " CFLAGS=\"$cflags $extra_flags\"" + command += " LDFLAGS=\"-Wl,--gc-sections -flto -O2\"" + command += " sh ./Build.sh -r" + + # copy mksh and .mkshrc to out dir + command += " && mkdir -p " + command += rebase_path("$root_out_dir/bin", exec_path) + command += " " + command += rebase_path("$root_out_dir/etc", exec_path) + command += " && $ohos_current_strip_command mksh -o " + command += rebase_path("$root_out_dir/bin/mksh", exec_path) + command += " && cp -f .mkshrc " + command += rebase_path("$root_out_dir/etc", exec_path) } diff --git a/apps/module.mk b/apps/module.mk index 5b246a4591119bee3b856cbb6332138b80f20aae..285a1bc45d29d3ece53ec481bf7779a0d3d88309 100644 --- a/apps/module.mk +++ b/apps/module.mk @@ -33,8 +33,8 @@ APP_SUBDIRS := ifeq ($(LOSCFG_SHELL), y) APP_SUBDIRS += shell -APP_SUBDIRS += mksh -APP_SUBDIRS += toybox +#APP_SUBDIRS += mksh +#APP_SUBDIRS += toybox endif ifeq ($(LOSCFG_USER_INIT_DEBUG), y) diff --git a/apps/toybox/BUILD.gn b/apps/toybox/BUILD.gn index 8438e89ea4787281c72d293461395a405910f207..1edb7d05b28c4a7120af26a442eb375a04348c11 100644 --- a/apps/toybox/BUILD.gn +++ b/apps/toybox/BUILD.gn @@ -34,7 +34,40 @@ group("toybox") { deps = [ ":build_toybox" ] } +copy("copy_toybox_src") { + sources = [ "$LITEOSTHIRDPARTY/toybox" ] + outputs = [ "$target_out_dir/toybox_build" ] +} + +copy("copy_toybox_config") { + deps = [ ":copy_toybox_src" ] + sources = [ "liteos_a_custom.config" ] + outputs = [ "$target_out_dir/{{source_file_part}}" ] +} + build_ext_component("build_toybox") { - exec_path = rebase_path(target_out_dir) - command = "make -C $LITEOSTHIRDPARTY/toybox" + deps = [ ":copy_toybox_src", ":copy_toybox_config" ] + deps += [ "//prebuilts/lite/sysroot" ] + exec_path = rebase_path("$target_out_dir/toybox_build") + + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + ] + cflags = string_join(" ", cflags) + + extra_flags = string_join(" ", target_arch_cflags) + if (ohos_build_compiler == "clang") { + extra_flags += " --target=$target_triple" + extra_flags += " --sysroot=" + rebase_path(ohos_current_sysroot) + } + + command = "rm -rf .git && cp -rfp porting/liteos_a/. . && env" + command += " CC=\"$ohos_current_cc_command\"" + command += " STRIP=\"$ohos_current_strip_command\"" + command += " OUTNAME=toybox" + command += " CFLAGS=\"$cflags $extra_flags\"" + command += " make toybox" + command += " && install -D toybox " + command += rebase_path("$root_out_dir/bin/toybox", exec_path) }