From 181322a3c187627f7e5d5ccb924927e574322f5a Mon Sep 17 00:00:00 2001 From: Caoruihong Date: Mon, 23 Aug 2021 17:58:41 +0800 Subject: [PATCH] chore(make): fix and optimize some build scripts Signed-off-by: Caoruihong Change-Id: I2e61b7ea231be78423dc10412e0ab9a710cad8ef --- .gitignore | 1 - BUILD.gn | 11 ++++------ Makefile | 2 +- arch/arm/arm.mk | 2 -- kernel/user/BUILD.gn | 32 +++++++++++++-------------- kernel/user/Makefile | 11 +--------- tools/build/mk/los_config.mk | 42 ++++++++---------------------------- 7 files changed, 30 insertions(+), 71 deletions(-) diff --git a/.gitignore b/.gitignore index 7f3188ff..c796d20f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,6 @@ tags # Menuconfig temp files /config.h -/defconfig /.config /.config.old diff --git a/BUILD.gn b/BUILD.gn index 31915cb1..de886050 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -262,14 +262,11 @@ config("los_common") { } if (defined(LOSCFG_THUMB)) { - cflags += [ - "-mthumb", - "-Wa,-mimplicit-it=thumb", - ] + cflags += [ "-mthumb" ] if (defined(LOSCFG_COMPILER_CLANG_LLVM)) { - # llvm-as do not support "-mimplicit-it=thumb" option currently, - # so we remove it temporary. - cflags -= [ "-Wa,-mimplicit-it=thumb" ] + cflags += [ "-mimplicit-it=thumb" ] + } else { + cflags += [ "-Wa,-mimplicit-it=thumb" ] } } diff --git a/Makefile b/Makefile index e18f8fef..21013aaa 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. LITEOSTOPDIR := $(realpath $(dir $(firstword $(MAKEFILE_LIST)))) +export LITEOSTOPDIR APPS = apps ROOTFS = rootfs @@ -64,7 +65,6 @@ LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h LITEOS_CONFIG_FILE ?= $(LITEOSTOPDIR)/.config # export los_config.mk related environment variables -export LITEOSTOPDIR export LITEOS_MENUCONFIG_H export LITEOS_CONFIG_FILE diff --git a/arch/arm/arm.mk b/arch/arm/arm.mk index 2236d916..99850cdb 100644 --- a/arch/arm/arm.mk +++ b/arch/arm/arm.mk @@ -66,8 +66,6 @@ LITEOS_GCCLIB := $(subst cortex-,,$(LOSCFG_ARCH_CPU))_softfp_$(LOSCFG_ endif LITEOS_CORE_COPTS = $(or $(ARCH_CFLAGS),$(LITEOS_CPU_OPTS) $(LITEOS_FLOAT_OPTS) $(LITEOS_FPU_OPTS)) -LITEOS_INTERWORK += $(LITEOS_CORE_COPTS) -LITEOS_NODEBUG += $(LITEOS_CORE_COPTS) LITEOS_ASOPTS += $(LITEOS_CPU_OPTS) LITEOS_CXXOPTS_BASE += $(LITEOS_CORE_COPTS) diff --git a/kernel/user/BUILD.gn b/kernel/user/BUILD.gn index 31a7719a..6a8fa343 100644 --- a/kernel/user/BUILD.gn +++ b/kernel/user/BUILD.gn @@ -30,38 +30,36 @@ import("//kernel/liteos_a/liteos.gni") module_name = "userinit" -executable(module_name) { +kernel_module(module_name) { sources = [ "src/los_user_init.c" ] include_dirs = [ "include", "$LITEOSTOPDIR/syscall", ] +} - configs = [] - configs += [ - "$LITEOSTOPDIR:public", - "$LITEOSTOPDIR:los_config", - ] +config("public") { +} +userinit = "lib$module_name.O" +executable(userinit) { + output_dir = target_out_dir + deps = [ ":$module_name" ] + configs = [] + configs += [ "$LITEOSTOPDIR:los_config" ] ldflags = [ "-static", "-Wl,-r", ] +} - output_dir = target_out_dir +copy("copy_userinit") { + deps = [ ":$userinit" ] + sources = [ "$target_out_dir/unstripped/bin/$userinit" ] + outputs = [ "$root_out_dir/$userinit" ] } group("user") { - public_deps = [ ":$module_name" ] deps = [ ":copy_userinit" ] } - -config("public") { -} - -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/kernel/user/Makefile b/kernel/user/Makefile index 00ddca85..2037d90b 100644 --- a/kernel/user/Makefile +++ b/kernel/user/Makefile @@ -32,17 +32,8 @@ include $(LITEOSTOPDIR)/config.mk MODULE_NAME := userinit LOCAL_INCLUDE := \ - -I $(LITEOSTOPDIR)/kernel/base/include\ - -I $(LITEOSTOPDIR)/kernel/include \ - -I $(LITEOSTOPDIR)/kernel/extended/include \ -I $(LITEOSTOPDIR)/syscall \ - -I $(LITEOSTOPDIR)/fs/vfs \ - -I $(LITEOSTHIRDPARTY)/FatFs/source \ - -I $(LITEOSTOPDIR)/fs/proc/include \ - -I $(LITEOSTOPDIR)/fs/jffs2/include\ - -I $(LITEOSTOPDIR)/fs/nfs/include\ - -I $(LITEOSTOPDIR)/bsd/compat/linuxkpi/include \ - -I $(LITEOSTOPDIR)/kernel/user/include + -I include LOCAL_SRCS := $(wildcard src/*.c) \ $(wildcard src/*.S) diff --git a/tools/build/mk/los_config.mk b/tools/build/mk/los_config.mk index 9386978c..4f5ea8bc 100644 --- a/tools/build/mk/los_config.mk +++ b/tools/build/mk/los_config.mk @@ -56,16 +56,11 @@ LITEOS_CPU_TYPE := LITEOS_ASOPTS := LITEOS_COPTS_BASE := LITEOS_COPTS_EXTRA := -LITEOS_COPTS_EXTRA_INTERWORK := LITEOS_COPTS_DEBUG := -LITEOS_COPTS_NODEBUG := -LITEOS_INTERWORK := LITEOS_CXXOPTS := LITEOS_CXXOPTS_BASE := LITEOS_LD_OPTS := LITEOS_GCOV_OPTS := -## dynload ld options ## -LITEOS_DYNLOADOPTS := ## macro define ## LITEOS_CMACRO := LITEOS_CXXMACRO := @@ -77,7 +72,6 @@ LITEOS_LD_SCRIPT := ## c as cxx ld flags ## LITEOS_ASFLAGS := LITEOS_CFLAGS := -LITEOS_CFLAGS_INTERWORK := LITEOS_LDFLAGS := LITEOS_CXXFLAGS := ## depended lib ## @@ -395,7 +389,7 @@ endif ifeq ($(LOSCFG_DRIVERS_VIDEO), y) LITEOS_BASELIB += -lvideo LIB_SUBDIRS += $(LITEOSTOPDIR)/drivers/char/video - LITEOS_VIDEO_INCLUDE += -I $(LITEOSTOPDIR)/../../third_party/NuttX/include/nuttx/video + LITEOS_VIDEO_INCLUDE += -I $(LITEOSTHIRDPARTY)/NuttX/include/nuttx/video endif ############################## Driver Option End ####################################### @@ -426,6 +420,10 @@ ifeq ($(LOSCFG_COMPRESS), y) LIB_SUBDIRS += tools/compress endif +ifneq ($(LOSCFG_DEBUG_VERSION), y) + LITEOS_COPTS_DEBUG += -DNDEBUG +endif + ifeq ($(LOSCFG_COMPILE_DEBUG), y) LITEOS_COPTS_OPTMIZE = -O0 LITEOS_COPTS_OPTION = -g -gdwarf-2 @@ -435,13 +433,10 @@ else else LITEOS_COPTS_OPTMIZE = -O2 endif - LITEOS_COPTS_OPTMIZE_NODEBUG = -O0 endif LITEOS_COPTS_DEBUG += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTMIZE) - LITEOS_INTERWORK += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTMIZE) LITEOS_CXXOPTS_BASE += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTMIZE) LITEOS_ASOPTS += $(LITEOS_COPTS_OPTION) - LITEOS_NODEBUG += $(LITEOS_COPTS_OPTMIZE_NODEBUG) ifeq ($(LOSCFG_SHELL), y) LITEOS_BASELIB += -lshell @@ -577,11 +572,11 @@ endif endif LITEOS_COPTS_EXTRA += -fno-short-enums ifeq ($(LOSCFG_THUMB), y) -LITEOS_COPTS_EXTRA_INTERWORK := $(LITEOS_COPTS_EXTRA) -mthumb -Wa,-mimplicit-it=thumb -LITEOS_CMACRO += -DLOSCFG_INTERWORK_THUMB +ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) +LITEOS_CFLAGS_INTERWORK := -mthumb -mimplicit-it=thumb else -LITEOS_COPTS_EXTRA_INTERWORK := $(LITEOS_COPTS_EXTRA) -#-fno-inline +LITEOS_CFLAGS_INTERWORK := -mthumb -Wa,-mimplicit-it=thumb +endif endif # kernel configuration macros @@ -591,12 +586,7 @@ ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y) LITEOS_LD_OPTS += -nostartfiles endif LITEOS_LD_OPTS += -static --gc-sections -LITEOS_LD_OPTS += $(LITEOS_DYNLOADOPTS) LITEOS_LD_PATH += -L$(OUT)/lib -ifeq ($(LOSCFG_VENDOR) ,y) -LITEOS_LD_PATH += -L$(OUT)/lib/rdk -L$(OUT)/lib/sdk \ - -L$(OUT)/lib/main_server -endif ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) LITEOS_LD_SCRIPT := -T$(LITEOSTOPDIR)/tools/build/liteos_llvm.ld @@ -614,17 +604,3 @@ LITEOS_BASELIB += $(shell $(_CC) "-print-file-name=libgcc_eh.a") endif LITEOS_BASELIB += $(shell $(_CC) "-print-libgcc-file-name") LITEOS_LIB_INCLUDE += -isystem $(shell $(_CC) "-print-file-name=include") - -LITEOS_CXXINCLUDE = $(LITEOS_INCLUDE) - -LITEOS_COPTS_NODEBUG := $(LITEOS_NODEBUG) $(LITEOS_COPTS_BASE) $(LITEOS_COPTS_EXTRA) -LITEOS_COPTS_INTERWORK := $(LITEOS_INTERWORK) $(LITEOS_COPTS_BASE) $(LITEOS_COPTS_EXTRA_INTERWORK) -LITEOS_BASE_INCLUDE := $(LITEOS_KERNEL_INCLUDE) $(LITEOS_PLATFORM_INCLUDE) \ - $(LITEOS_LIB_INCLUDE) $(LITEOS_FS_INCLUDE) \ - $(LITEOS_EXTKERNEL_INCLUDE) \ - $(LITEOS_COMPAT_INCLUDE) $(LITEOS_DRIVERS_INCLUDE) \ - $(LOSCFG_TOOLS_DEBUG_INCLUDE) $(LITEOS_NET_INCLUDE) -LITEOS_CFLAGS_INTERWORK := $(LITEOS_COPTS_INTERWORK) $(LITEOS_CMACRO) \ - $(LITEOS_IMAGE_MACRO) $(LITEOS_BASE_INCLUDE) -LITEOS_CFLAGS_NODEBUG := $(LITEOS_COPTS_NODEBUG) $(LITEOS_CMACRO) \ - $(LITEOS_IMAGE_MACRO) $(LITEOS_BASE_INCLUDE) -- GitLab