chore(make): optimize build scripts

Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: Ibb4223ef2d032a03950263b766414ca1c021e69a
This commit is contained in:
Caoruihong 2021-08-27 09:51:14 +08:00
parent aa5b2c7641
commit df35eb513d
24 changed files with 485 additions and 458 deletions

341
BUILD.gn
View File

@ -84,7 +84,7 @@ exec_script("//build/lite/run_shell_cmd.py",
" --file-list kconfig_files.txt" +
" --env-list kconfig_env.txt" +
" --config-out config.gni",
])
], "", [ liteos_config_file ])
import("liteos.gni")
@ -126,6 +126,19 @@ config("arch_config") {
cflags = liteos_arch_cflags
asmflags = cflags
ldflags = cflags
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += ["-mthumb-interwork"]
}
}
if (defined(LOSCFG_THUMB)) {
cflags += [ "-mthumb" ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-mimplicit-it=thumb" ]
} else {
cflags += [ "-Wa,-mimplicit-it=thumb" ]
}
}
}
config("as_objs_libc_flags") {
@ -141,15 +154,182 @@ config("as_objs_libc_flags") {
}
}
config("std_include") {
config("stdinc_config") {
std_include = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-file-name=include" ], "trim string")
cflags = [
"-isystem",
std_include,
]
cflags += [ "-nostdinc" ]
asmflags = cflags
}
config("ssp_config") {
cflags = []
if (defined(LOSCFG_CC_STACKPROTECTOR_ALL)) {
cflags += [ "-fstack-protector-all" ]
} else if (defined(LOSCFG_CC_STACKPROTECTOR_STRONG)) {
cflags += [ "-fstack-protector-strong" ]
} else if (defined(LOSCFG_CC_STACKPROTECTOR)) {
cflags += [
"-fstack-protector",
"--param",
"ssp-buffer-size=4",
]
} else {
cflags += [ "-fno-stack-protector" ]
}
asmflags = cflags
}
config("optimize_config") {
cflags = []
if (defined(LOSCFG_COMPILE_DEBUG)) {
cflags += [
"-g",
"-gdwarf-2",
]
optimization_cflag = "-O0"
}
if (defined(LOSCFG_COMPILE_OPTIMIZE)) {
optimization_cflag = "-O2"
}
if (defined(LOSCFG_COMPILE_OPTIMIZE_SIZE)) {
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
optimization_cflag = "-Oz"
} else {
optimization_cflag = "-Os"
}
cflags += [ "-flto" ]
}
cflags += [ optimization_cflag ]
asmflags = cflags
}
config("kconfig_config") {
cflags = [
"-imacros",
"$LITEOS_MENUCONFIG_H",
]
asmflags = cflags
}
config("warn_config") {
cflags = [
"-Wall",
"-Werror",
"-Wpointer-arith",
"-Wstrict-prototypes",
"-Winvalid-pch",
"-Wno-address-of-packed-member",
]
if (defined(LOSCFG_QUICK_START)) {
cflags -= [ "-Werror" ]
}
asmflags = cflags
}
config("dialect_config") {
cflags_c = [ "-std=c99" ]
cflags_cc = [ "-std=c++11" ]
}
config("misc_config") {
defines = [ "__LITEOS__" ]
if (!defined(LOSCFG_DEBUG_VERSION)) {
defines += [ "NDEBUG" ]
}
cflags = [
"-fno-pic",
"-fno-builtin",
"-fms-extensions",
"-fno-strict-aliasing",
"-fno-common",
"-fsigned-char",
"-ffunction-sections",
"-fdata-sections",
"-fno-exceptions",
"-fno-omit-frame-pointer",
"-fno-short-enums",
"-mno-unaligned-access",
]
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-fno-aggressive-loop-optimizations" ]
}
asmflags = cflags
}
config("los_config") {
configs = [
":arch_config",
":kconfig_config",
":stdinc_config",
":dialect_config",
":optimize_config",
":ssp_config",
":warn_config",
":misc_config",
]
}
executable("liteos") {
configs = [] # clear default configs
configs += [ ":los_config" ]
configs += [ ":public" ]
ldflags = [
"-static",
"-nostdlib",
"-Wl,--gc-sections",
"-Wl,-Map=$liteos_name.map",
"-Wl,--no-eh-frame-hdr",
]
libgcc = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-libgcc-file-name" ], "trim string")
libs = [ libgcc ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos_llvm.ld", root_build_dir) ]
inputs = [ "tools/build/liteos_llvm.ld" ]
} else {
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
ldflags += [ "-Wl,-nostartfiles" ]
inputs = [ "tools/build/liteos.ld" ]
}
inputs += [ "$root_out_dir/board.ld" ]
output_dir = target_out_dir
output_name = liteos_name
deps = [
"platform:board.ld",
":modules",
]
}
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"
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'"
}
config("public") {
configs = [
"arch:public",
@ -175,161 +355,6 @@ config("public") {
}
}
config("los_nostdinc") {
cflags = [ "-nostdinc" ]
}
config("los_nostdlib") {
ldflags = [ "-nostdlib" ]
}
config("los_common") {
cflags = [
"-imacros",
"$LITEOS_MENUCONFIG_H",
]
defines = [ "__LITEOS__" ]
if (!defined(LOSCFG_DEBUG_VERSION)) {
defines += [ "NDEBUG" ]
}
cflags_c = [ "-std=c99" ]
cflags += [
"-fno-pic",
"-fno-builtin",
"-Wall",
"-Werror",
"-fms-extensions",
"-Wno-address-of-packed-member",
"-fno-strict-aliasing",
"-fno-common",
"-fsigned-char",
"-Wpointer-arith",
"-Wstrict-prototypes",
"-Winvalid-pch",
"-ffunction-sections",
"-fdata-sections",
"-fno-exceptions",
"-fno-omit-frame-pointer",
"-fno-short-enums",
]
if (defined(LOSCFG_QUICK_START)) {
cflags -= [ "-Werror" ]
}
if (defined(LOSCFG_COMPILE_DEBUG)) {
cflags += [
"-O0",
"-g",
"-gdwarf-2",
]
} else {
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [
"-Oz",
"-flto",
]
} else {
cflags += [ "-O2" ]
}
}
if (defined(LOSCFG_CC_STACKPROTECTOR_ALL)) {
cflags += [ "-fstack-protector-all" ]
} else if (defined(LOSCFG_CC_STACKPROTECTOR_STRONG)) {
cflags += [ "-fstack-protector-strong" ]
} else if (defined(LOSCFG_CC_STACKPROTECTOR)) {
cflags += [
"-fstack-protector",
"--param",
"ssp-buffer-size=4",
]
} else {
cflags += [ "-fno-stack-protector" ]
}
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-fno-aggressive-loop-optimizations" ]
if (!defined(LOSCFG_ARCH_ARM_AARCH64)) {
cflags += [
"-mno-unaligned-access",
"-mthumb-interwork",
]
}
}
if (defined(LOSCFG_THUMB)) {
cflags += [ "-mthumb" ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-mimplicit-it=thumb" ]
} else {
cflags += [ "-Wa,-mimplicit-it=thumb" ]
}
}
asmflags = cflags
}
config("los_config") {
configs = [
":los_common",
":arch_config",
":los_nostdinc",
":los_nostdlib",
":std_include",
]
}
executable("liteos") {
configs = [] # clear default configs
configs += [ ":los_config" ]
configs += [ ":public" ]
ldflags = [
"-static",
"-Wl,--gc-sections",
"-Wl,-Map=$liteos_name.map",
"-Wl,--no-eh-frame-hdr",
]
libgcc = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-libgcc-file-name" ], "trim string")
libs = [ libgcc ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
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 += [ "-Wl,-nostartfiles" ]
}
output_dir = target_out_dir
output_name = liteos_name
deps = [
":modules",
]
}
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"
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") {
deps = [
"arch",
@ -347,7 +372,7 @@ group("modules") {
]
deps += [
"$HDFTOPDIR",
HDFTOPDIR,
"//drivers/liteos",
]

63
Kconfig
View File

@ -26,27 +26,56 @@
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# For a description of the syntax of this configuration file,
# see extra/config/Kconfig-language.txt
#
mainmenu "Huawei LiteOS Configuration"
menu "Compiler"
choice
prompt "LiteOS_Compiler_Type"
prompt "Compiler type"
default COMPILER_CLANG_LLVM
help
Enable arm-himix100 or aarch64-himix100 or compiler.
Choose compiler type.
config COMPILER_HIMIX_32
bool "arm-linux-ohoseabi"
config COMPILER_GCC
bool "GCC"
config CROSS_COMPILE
string "GCC cross-compile toolchain prefix"
depends on COMPILER_GCC
default "arm-linux-ohoseabi-" if ARCH_ARM_AARCH32
config COMPILER_CLANG_LLVM
bool "clang-llvm"
bool "Clang"
config LLVM_TARGET
string "Clang LLVM target"
depends on COMPILER_CLANG_LLVM
default "arm-liteos" if ARCH_ARM_AARCH32
endchoice
config COMPILE_DEBUG
bool "Enable debug options"
default n
help
Answer Y to add -g option in compile command.
config COMPILE_OPTIMIZE
bool "Enable code optimization options"
default y
help
Answer Y to add optimization options for efficient code.
The final binary size will be smaller and execute faster.
But the debugging experience may be worst somehow.
config COMPILE_OPTIMIZE_SIZE
bool "Enable code size optimization options" if COMPILE_OPTIMIZE
default y
help
Answer Y to add optimization options for small code size.
The final binary size will be smaller.
But the compile time may be much longer.
endmenu
menu "Platform"
@ -123,11 +152,11 @@ source "net/Kconfig"
######################## config options of debug ########################
menu "Debug"
config COMPILE_DEBUG
bool "Enable GCC -g Option"
config GDB
bool "Enable gdb functions"
default n
help
Answer Y to add -g option in gcc command. But the LiteOS size will be much larger.
Answer Y to enable gdb functions.
config PLATFORM_ADAPT
bool "Enable Os_adapt"
@ -164,16 +193,10 @@ config ENABLE_MAGICKEY
config THUMB
bool "Enable Thumb"
default n
select INTERWORK_THUMB
depends on ARCH_ARM
help
Answer Y to build thumb version. This will make LiteOS smaller.
config INTERWORK_THUMB
bool "Enable interwork Thumb" if THUMB
default n
help
Answer Y to enable interwork thumb.
config PLATFORM_DVFS
bool "Enable Dvfs"
default n

View File

@ -60,7 +60,7 @@ CONFIG ?= $(PRODUCT_PATH)/kernel_configs/debug$(tee).config
endif
KCONFIG_CONFIG ?= $(CONFIG)
SYSROOT_PATH ?= $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot
SYSROOT_PATH ?= $(OUT)/sysroot
LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h
LITEOS_CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
@ -95,7 +95,6 @@ ROOTFS_DIR = $(OUT)/rootfs
ROOTFS_ZIP = $(OUT)/rootfs.zip
define HELP =
-------------------------------------------------------
Usage: make [TARGET]... [PARAMETER=VALUE]...
Targets:
@ -116,7 +115,6 @@ Parameters:
RELEASE: boolean value(1 or y for true), build release version
CONFIG: kernel config file to be use
args: arguments for xxconfig command
-------------------------------------------------------
endef
export HELP
@ -126,11 +124,21 @@ help:
$(HIDE)echo "$$HELP"
sysroot:
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
ifeq ($(wildcard $(SYSROOT_PATH)/usr/include/$(LLVM_TARGET)/),)
$(HIDE)$(MAKE) -C $(SYSROOT_PATH)/build TARGETS=liteos_a_user
endif
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
ifeq ($(origin SYSROOT_PATH),file)
$(HIDE)mkdir -p $(SYSROOT_PATH)/build && cd $(SYSROOT_PATH)/build && \
ln -snf $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/build/Makefile && \
$(MAKE) TARGETS=liteos_a_user \
ARCH=$(ARCH) \
TARGET=$(LOSCFG_LLVM_TARGET) \
ARCH_CFLAGS="$(LITEOS_CORE_COPTS) -w" \
TOPDIR="$(LITEOSTOPDIR)/../.." \
SYSROOTDIR="$(SYSROOT_PATH)" \
CLANG="$(LITEOS_COMPILER_PATH)clang" \
BUILD_ALL_MULTILIB=false \
BUILD_DEBUG=$(if $(patsubst y,,$(or $(RELEASE:1=y),n)),true,false)
endif
endif
$(KCONFIG_CMDS):
@ -142,7 +150,7 @@ $(LITEOS_CONFIG_FILE): $(KCONFIG_CONFIG)
update_config:
$(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig && savedefconfig --out "$(CONFIG)"
$(LITEOS_LIBS_TARGET):
$(LITEOS_LIBS_TARGET): sysroot
$(HIDE)for dir in $(LIB_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET)
@ -167,14 +175,14 @@ $(OUT)/$(LITEOS_TARGET).asm: $(OUT)/$(LITEOS_TARGET)
$(OUT)/$(LITEOS_TARGET).size: $(OUT)/$(LITEOS_TARGET)
$(NM) -S --size-sort $< >$@
$(APPS):
$(APPS): sysroot
$(HIDE)$(MAKE) -C apps all
$(ROOTFS): $(APPS)
$(HIDE)mkdir -p $(OUT)/musl
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
$(HIDE)cp -fp $$($(CC) --target=$(LLVM_TARGET) --sysroot=$(SYSROOT_PATH) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
$(HIDE)cp -fp $$($(GPP) --target=$(LLVM_TARGET) --sysroot=$(SYSROOT_PATH) $(LITEOS_CXXFLAGS) -print-file-name=libc++.so) $(OUT)/musl
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
$(HIDE)cp -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libc++.so) $(OUT)/musl
else
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libgcc_s.so.1) $(OUT)/musl
@ -189,6 +197,7 @@ endif
$(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS)
clean:
$(HIDE)if [ -d $(SYSROOT_PATH)/build ]; then $(MAKE) -C $(SYSROOT_PATH)/build clean; fi
$(HIDE)for dir in $(LIB_SUBDIRS) apps; do $(MAKE) -C $$dir clean || exit 1; done
$(HIDE)$(RM) $(LITEOS_MENUCONFIG_H)
$(HIDE)echo "clean $(LOSCFG_PLATFORM) finish"

View File

@ -34,20 +34,14 @@ export APPSTOPDIR
include $(APPSTOPDIR)/config.mk
HIDE := @
APPS := app
all: $(APPS)
# Make
$(APPS):
all:
ifneq ($(APP_SUBDIRS), )
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir || exit 1; done
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
endif
clean:
ifneq ($(APP_SUBDIRS), )
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir clean; done
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir clean || exit 1; done
endif
.PHONY: all $(APPS) clean
.PHONY: all clean

View File

@ -52,6 +52,17 @@ LOCAL_CPPGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CPPHS))
all : $(APP)
define ECHO =
ifeq ($$(HIDE),@)
_$(1) := $($(1))
$(1) = echo " $(1)" $$(patsubst $$(OUT)/%,%,$$@) && $$(_$(1))
endif
endef
$(foreach cmd,CC GPP AS,$(eval $(call ECHO,$(cmd))))
LOCAL_FLAGS += -MD -MP
-include $(LOCAL_OBJS:%.o=%.d)
$(LOCAL_COBJS): $(OBJOUT)/%.o: %.c
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@
@ -83,7 +94,7 @@ LOCAL_GCH := $(LOCAL_CGCH) $(LOCAL_CPPGCH)
$(LOCAL_OBJS): $(LOCAL_GCH)
$(APP): $(LOCAL_OBJS)
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(GPP) $(LDFLAGS) $^ -o $@
$(HIDE)$(GPP) $(LDFLAGS) -o $@ $^
clean:
$(HIDE)$(RM) $(APP) $(OBJOUT) $(LOCAL_GCH) *.bak *~

View File

@ -29,25 +29,16 @@
include $(LITEOSTOPDIR)/config.mk
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LLVM_SYSROOT := --sysroot=$(SYSROOT_PATH)
endif
# common flags config
BASE_OPTS := -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
BASE_OPTS += -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fno-common -fno-strict-aliasing
BASE_OPTS += -fstack-protector-strong -Wall -Werror -flto
BASE_OPTS += $(LITEOS_CORE_COPTS) $(LLVM_EXTRA_OPTS) $(LLVM_SYSROOT) $(LITEOS_GCOV_OPTS)
BASE_OPTS := -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE $(LITEOS_GCOV_OPTS)
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
OPTMIZE_OPTS = -Oz
else
OPTMIZE_OPTS = -O2
endif
ASFLAGS :=
CFLAGS := $(LITEOS_COPTS) $(BASE_OPTS) -fPIE
CXXFLAGS := $(LITEOS_CXXOPTS) $(BASE_OPTS) -fPIE
LDFLAGS := $(LITEOS_CORE_COPTS) -pie -Wl,-z,relro,-z,now -O2
CFLAGS := -std=c99 -fPIE -fno-exceptions $(BASE_OPTS) $(OPTMIZE_OPTS)
CXXFLAGS := -std=c++11 -fPIE -fexceptions -fpermissive -frtti $(BASE_OPTS) $(OPTMIZE_OPTS)
LDFLAGS := -pie -Wl,-z,relro,-z,now -O2 $(BASE_OPTS) $(LLVM_EXTRA_LD_OPTS)
CFLAGS := $(filter-out -fno-pic -fno-builtin -nostdinc -nostdlib,$(CFLAGS))
CXXFLAGS := $(filter-out -fno-pic -fno-builtin -nostdinc -nostdlib -nostdinc++,$(CXXFLAGS))
# alias variable config
HIDE := @
@ -57,9 +48,9 @@ CP := cp -rf
MV := mv -f
APP := $(APPSTOPDIR)/app.mk
APP_SUBDIRS :=
##build modules config##
APP_SUBDIRS :=
ifeq ($(LOSCFG_SHELL), y)
APP_SUBDIRS += shell
@ -74,3 +65,12 @@ endif
ifeq ($(LOSCFG_NET_LWIP_SACK_TFTP), y)
APP_SUBDIRS += tftp
endif
# clear all local variables
LOCAL_FLAGS :=
LOCAL_CFLAGS :=
LOCAL_CPPFLAGS :=
LOCAL_ASFLAGS :=
LOCAL_SRCS :=
LOCAL_CHS :=
LOCAL_CPPHS :=

View File

@ -31,18 +31,14 @@ include $(APPSTOPDIR)/config.mk
APP_NAME := $(notdir $(shell pwd))
SECUREC_INCLUDE := $(LITEOSTHIRDPARTY)/bounds_checking_function/include
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
LOCAL_SRCS = $(wildcard src/main.c)\
$(wildcard src/shcmd.c)\
$(wildcard src/shmsg.c)\
$(wildcard src/shcmdparse.c)\
$(wildcard builtin/cd.c)
LOCAL_SRCS += $(wildcard $(LITEOSTHIRDPARTY)/bounds_checking_function/src/*.c)
LOCAL_SRCS = $(wildcard src/*.c builtin/*.c)
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.c)
LOCAL_INCLUDE := \
-I include/ \
-I $(SECUREC_INCLUDE)\
-I include \
-I $(SECUREC_DIR)/include
LOCAL_FLAGS += $(LOCAL_INCLUDE)

View File

@ -42,10 +42,10 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
extern char *OsShellGetWorkingDirtectory();
extern unsigned int OsShellInit();
extern char *OsShellGetWorkingDirtectory(void);
extern unsigned int OsShellInit(void);
extern int OsShellDeinit(ShellCB *shellCB);
extern ShellCB *OsGetShellCb();
extern ShellCB *OsGetShellCb(void);
#ifdef __cplusplus
#if __cplusplus

View File

@ -34,14 +34,11 @@ APP_NAME := $(notdir $(shell pwd))
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
LOCAL_SRCS = $(wildcard src/*.c)
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/strncpy_s.c)
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/memcpy_s.c)
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/memset_s.c)
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/strncat_s.c)
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.c)
LOCAL_INCLUDE := \
-I include/ \
-I $(SECUREC_DIR)/include/\
-I include \
-I $(SECUREC_DIR)/include
LOCAL_FLAGS += $(LOCAL_INCLUDE)

View File

@ -31,17 +31,10 @@ import("//kernel/liteos_a/liteos.gni")
group("arm") {
deps = [ "gic" ]
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
deps += [ "arm" ]
}
deps += [ ARCH ]
}
config("public") {
include_dirs = [ "include" ]
configs = []
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
configs += [ "arm:public" ]
} else if (defined(LOSCFG_ARCH_ARM_AARCH64)) {
configs += [ "aarch64:public" ]
}
configs = [ "$ARCH:public" ]
}

View File

@ -36,15 +36,15 @@ LOSCFG_ARCH_FPU_STRIP := $(subst $\",,$(LOSCFG_ARCH_FPU))
LOSCFG_ARCH_FPU = $(LOSCFG_ARCH_FPU_STRIP)
ifeq ($(LOSCFG_ARCH_ARM_AARCH32), y)
LITEOS_ARCH_ARM := arm
ARCH := arm
else ifeq ($(LOSCFG_ARCH_ARM_AARCH64), y)
LITEOS_ARCH_ARM :=
ARCH := aarch64
endif
LITEOS_BASELIB += -l$(LOSCFG_ARCH_CPU)
LITEOS_BASELIB += -lgic
LIB_SUBDIRS += arch/arm/$(LITEOS_ARCH_ARM)
LIB_SUBDIRS += arch/arm/$(ARCH)
LIB_SUBDIRS += arch/arm/gic
# CPU compile options
@ -70,8 +70,8 @@ LITEOS_ASOPTS += $(LITEOS_CPU_OPTS)
LITEOS_CXXOPTS_BASE += $(LITEOS_CORE_COPTS)
ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \
-I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/include \
-I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/src/include
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/include \
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/src/include
LITEOS_PLATFORM_INCLUDE += $(ARCH_INCLUDE)
@ -84,10 +84,6 @@ else ifeq ($(LOSCFG_ARCH_FPU_VFP_D32), y)
LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_VFP_D32
endif
# extra definition for other module
LITEOS_CPU_TYPE = $(LOSCFG_ARCH_CPU)
LITEOS_ARM_ARCH := -march=$(subst $\",,$(LOSCFG_ARCH_ARM_VER))
# linux style macros
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7A) = -D__LINUX_ARM_ARCH__=7
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7R) = -D__LINUX_ARM_ARCH__=7

View File

@ -38,7 +38,7 @@ LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/kernel/extended/dynload/include \
-I $(LITEOSTOPDIR)/arch/arm/arm/include \
ifeq ($(LITEOS_ARM_ARCH), -march=armv7-a)
ifeq ($(LOSCFG_ARCH_ARM_VER), "armv7-a")
LOCAL_SRCS += $(wildcard src/armv7a/*.S)
endif

View File

@ -85,7 +85,7 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
taskContext->LR = (UINTPTR)OsTaskExit; /* LR should be kept, to distinguish it's THUMB or ARM instruction */
taskContext->R0 = taskID; /* R0 */
#ifdef LOSCFG_INTERWORK_THUMB
#ifdef LOSCFG_THUMB
taskContext->regCPSR = PSR_MODE_SVC_THUMB; /* CPSR (Enable IRQ and FIQ interrupts, THUMNB-mode) */
#else
taskContext->regCPSR = PSR_MODE_SVC_ARM; /* CPSR (Enable IRQ and FIQ interrupts, ARM-mode) */
@ -123,7 +123,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsUserTaskStackInit(TaskContext *context, UINTPTR tas
{
LOS_ASSERT(context != NULL);
#ifdef LOSCFG_INTERWORK_THUMB
#ifdef LOSCFG_THUMB
context->regCPSR = PSR_MODE_USR_THUMB;
#else
context->regCPSR = PSR_MODE_USR_ARM;

View File

@ -33,8 +33,8 @@ MODULE_NAME := $(notdir $(shell pwd))
LOCAL_SRCS := $(wildcard kern/*.c)
LOCAL_SRCS += $(wildcard $(LITEOS_ARCH_ARM)/*.c)
LOCAL_SRCS += $(wildcard $(LITEOS_ARCH_ARM)/*.S)
LOCAL_SRCS += $(wildcard $(ARCH)/*.c)
LOCAL_SRCS += $(wildcard $(ARCH)/*.S)
ifeq ($(LOSCFG_DRIVERS_RANDOM), y)
LOCAL_SRCS += $(wildcard crypto/rijndael/*.c) \

View File

@ -51,3 +51,11 @@ LITEOS_CXXFLAGS := $(LITEOS_CXXOPTS) $(LITEOS_CXXMACRO) \
LITEOS_LDFLAGS := $(LITEOS_LD_OPTS) $(LITEOS_LD_PATH) \
$(LITEOS_LD_SCRIPT)
# clear all local variables
LOCAL_FLAGS :=
LOCAL_CFLAGS :=
LOCAL_CPPFLAGS :=
LOCAL_ASFLAGS :=
LOCAL_SRCS :=
LOCAL_CHS :=
LOCAL_CPPHS :=

View File

@ -39,23 +39,14 @@ shared_library("OHOS-vdso") {
"$LITEOSTOPDIR/bsd/compat/linuxkpi/include",
]
cflags = [
"-fPIC",
"-fno-common",
"-fno-strict-aliasing",
]
configs = []
configs += [ "$LITEOSTOPDIR:los_common" ]
configs += [ "$LITEOSTOPDIR:los_nostdlib" ]
configs += [ "$LITEOSTOPDIR:arch_config" ]
defines = [ "_XOPEN_SOURCE=700" ]
configs -= [ "//build/lite/config:security" ]
ldflags = [
"-nostdlib",
"-Wl,-Bsymbolic",
"-Wl,-T" + rebase_path("los_vdso.ld", root_build_dir),
]
inputs = [ "los_vdso.ld" ]
output_dir = target_out_dir
}

View File

@ -37,12 +37,8 @@ VDSO_INCLUDE := -I $(LITEOSTOPDIR)/kernel/extended/vdso/include \
-I $(LITEOSTOPDIR)/platform \
-I $(LITEOSTOPDIR)/bsd/compat/linuxkpi/include
VDSO_CCFLAGS := -nostdlib -fPIC -fno-common -fno-strict-aliasing \
$(LITEOS_SSP) $(LITEOS_CORE_COPTS) $(WARNING_AS_ERROR) $(LITEOS_COPTS_OPTMIZE)
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
VDSO_CCFLAGS += $(LLVM_EXTRA_OPTS) --sysroot=$(SYSROOT_PATH)
VDSO_CCFLAGS += -O2
endif
VDSO_CCFLAGS := $(filter-out -nostdinc,$(LITEOS_COPTS))
VDSO_CCFLAGS += -fPIC -O2 -D_XOPEN_SOURCE=700
VDSO_LDFLAGS := -shared -Wl,-s,-Bsymbolic,-Tlos_vdso.ld

View File

@ -46,9 +46,8 @@ userinit = "lib$module_name.O"
executable(userinit) {
output_dir = target_out_dir
deps = [ ":$module_name" ]
configs = []
configs += [ "$LITEOSTOPDIR:los_config" ]
ldflags = [
"-nostdlib",
"-static",
"-Wl,-r",
]

View File

@ -42,15 +42,14 @@ LOCAL_FLAGS := $(LOCAL_INCLUDE)
include $(MODULE)
LIBO := $(OUT)/lib/lib$(MODULE_NAME).O
USERINIT := $(OUT)/lib/lib$(MODULE_NAME).O
$(LIBO): $(LIBA)
$(HIDE) $(LD) -r -o $@ --whole-archive $< --no-whole-archive
$(HIDE) $(RM) $<
$(USERINIT): $(MODULE)
$(HIDE)$(LD) -r -o $@ --whole-archive $< --no-whole-archive
clean2:
$(HIDE) $(RM) $(LIBO)
clean_userinit:
$(HIDE)$(RM) $(USERINIT)
all: $(LIBO)
clean: clean2
.PHONY: clean2
all: $(USERINIT)
clean: clean_userinit
.PHONY: clean_userinit

View File

@ -2,7 +2,6 @@ include $(LITEOSTOPDIR)/config.mk
MODULE_NAME := c
ARCH = arm
TOPDIR = $(LITEOSTOPDIR)/../..
MUSLDIR = $(TOPDIR)/third_party/musl
MUSLPORTINGDIR = $(MUSLDIR)/porting/liteos_a/kernel

View File

@ -33,6 +33,16 @@ LITEOSTOPDIR = "//kernel/liteos_a"
LITEOSTHIRDPARTY = "//third_party"
HDFTOPDIR = "//drivers/adapter/khdf/liteos"
ARCH = ""
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
ARCH = "arm"
} else if (defined(LOSCFG_ARCH_ARM_AARCH64)) {
ARCH = "aarch64"
}
assert(ARCH != "", "ARCH not set!")
assert(ARCH == arch, "ARCH not match! details: $ARCH != $arch")
template("kernel_module") {
current_dir_name = get_path_info(rebase_path("."), "file")
if (target_name != current_dir_name) {

View File

@ -60,7 +60,6 @@ kernel_module(module_name) {
group("platform") {
public_deps = [ ":$module_name" ]
deps = [ ":board.ld" ]
}
config("public") {

View File

@ -50,8 +50,9 @@ endif
ARFLAGS := cr
## platform relative ##
LITEOS_ARM_ARCH :=
LITEOS_CPU_TYPE :=
ifeq ($(ARCH),)
ARCH = $(error ARCH not set!)
endif
## c as cxx ld options ##
LITEOS_ASOPTS :=
LITEOS_COPTS_BASE :=
@ -88,14 +89,20 @@ 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-
ifeq ($(LOSCFG_COMPILER_GCC), y)
CROSS_COMPILE ?= $(LOSCFG_CROSS_COMPILE)
LITEOS_COMPILER_PATH ?= $(LITEOSTOPDIR)/../../prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/bin/
else ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
CROSS_COMPILE ?= llvm-
LITEOS_COMPILER_PATH ?= $(LITEOSTOPDIR)/../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/
ifneq ($(LOSCFG_LLVM_TARGET),)
LLVM_TARGET = -target $(LOSCFG_LLVM_TARGET)
endif
ifeq ($(wildcard $(LITEOS_COMPILER_PATH)),)
ifneq ($(SYSROOT_PATH),)
LLVM_SYSROOT = --sysroot=$(SYSROOT_PATH)
endif
endif
ifeq ($(wildcard $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)as),)
LITEOS_COMPILER_PATH := $(patsubst %/$(CROSS_COMPILE)as,%/,$(shell which $(CROSS_COMPILE)as))
endif
LITEOS_PLATFORM := $(LOSCFG_PLATFORM:"%"=%)
@ -425,17 +432,21 @@ ifneq ($(LOSCFG_DEBUG_VERSION), y)
endif
ifeq ($(LOSCFG_COMPILE_DEBUG), y)
LITEOS_COPTS_OPTMIZE = -O0
LITEOS_COPTS_OPTIMIZE = -O0
LITEOS_COPTS_OPTION = -g -gdwarf-2
else
endif
ifeq ($(LOSCFG_COMPILE_OPTIMIZE), y)
LITEOS_COPTS_OPTIMIZE = -O2
endif
ifeq ($(LOSCFG_COMPILE_OPTIMIZE_SIZE), y)
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LITEOS_COPTS_OPTMIZE = -Oz -flto
LITEOS_COPTS_OPTIMIZE = -Oz -flto
else
LITEOS_COPTS_OPTMIZE = -O2
LITEOS_COPTS_OPTIMIZE = -Os -flto
endif
endif
LITEOS_COPTS_DEBUG += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTMIZE)
LITEOS_CXXOPTS_BASE += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTMIZE)
LITEOS_COPTS_DEBUG += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTIMIZE)
LITEOS_CXXOPTS_BASE += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTIMIZE)
LITEOS_ASOPTS += $(LITEOS_COPTS_OPTION)
ifeq ($(LOSCFG_SHELL), y)
@ -452,10 +463,6 @@ ifeq ($(LOSCFG_NET_TELNET), y)
-I $(LITEOSTOPDIR)/net/telnet/include
endif
ifeq ($(LOSCFG_3RDPARTY), y)
-include $(LITEOSTOPDIR)/3rdParty/3rdParty.mk
endif
ifeq ($(LOSCFG_KERNEL_SYSCALL), y)
LITEOS_BASELIB += -lsyscall
LIB_SUBDIRS += syscall
@ -492,19 +499,16 @@ endif
############################# Security Option End ##############################
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
CC = $(LITEOS_COMPILER_PATH)clang
CC = $(LITEOS_COMPILER_PATH)clang $(LLVM_TARGET) $(LLVM_SYSROOT)
AS = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)as
AR = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)ar
LD = $(LITEOS_COMPILER_PATH)ld.lld
GPP = $(LITEOS_COMPILER_PATH)clang++
GPP = $(LITEOS_COMPILER_PATH)clang++ $(LLVM_TARGET) $(LLVM_SYSROOT)
OBJCOPY = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)objcopy -R .bss
OBJDUMP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)objdump
SIZE = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)size
NM = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)nm
STRIP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)strip
LLVM_TARGET := arm-liteos
LLVM_EXTRA_OPTS := -target $(LLVM_TARGET) -fms-extensions -Wno-address-of-packed-member
LLVM_EXTRA_LD_OPTS := -fuse-ld=lld --rtlib=compiler-rt
else
CC = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)gcc
AS = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)as
@ -518,11 +522,6 @@ NM = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)nm
STRIP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)strip
endif
FP = -fno-omit-frame-pointer
LITEOS_CXXOPTS_BASE += -std=c++11 -nostdlib -nostdinc -nostdinc++ -fexceptions -fpermissive -fno-use-cxa-atexit \
-fno-builtin -frtti -fno-pic -Winvalid-pch $(WARNING_AS_ERROR) $(LLVM_EXTRA_OPTS) $(FP)
LITEOS_EXTKERNEL_INCLUDE := $(LITEOS_CPPSUPPORT_INCLUDE) $(LITEOS_DYNLOAD_INCLUDE) \
$(LITEOS_TICKLESS_INCLUDE) $(LITEOS_TRACE_INCLUDE) \
$(LITEOS_VDSO_INCLUDE) $(LITEOS_LITEIPC_INCLUDE) \
@ -557,20 +556,22 @@ LITEOS_SECURITY_INCLUDE := $(LITEOS_SECURITY_CAP_INC) $(LITEOS_SECURITY_VID_I
LOSCFG_TOOLS_DEBUG_INCLUDE := $(LITEOS_SHELL_INCLUDE) $(LITEOS_UART_INCLUDE) \
$(LITEOS_TELNET_INCLUDE)
LITEOS_COPTS_BASE := -fno-pic -fno-builtin -nostdinc -nostdlib $(WARNING_AS_ERROR) $(LITEOS_SSP) $(LLVM_EXTRA_OPTS) \
-fno-strict-aliasing -fno-common -fsigned-char
LITEOS_COMMON_OPTS := -fno-pic -fno-builtin -nostdinc -nostdlib $(WARNING_AS_ERROR) -fms-extensions -fno-omit-frame-pointer -Wno-address-of-packed-member -Winvalid-pch
LITEOS_CXXOPTS_BASE += $(LITEOS_COMMON_OPTS) -std=c++11 -nostdinc++ -fexceptions -fpermissive -fno-use-cxa-atexit -frtti
LITEOS_COPTS_BASE += $(LITEOS_COMMON_OPTS) $(LITEOS_SSP) -fno-strict-aliasing -fno-common -fsigned-char -mno-unaligned-access
ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LITEOS_COPTS_BASE += -fno-aggressive-loop-optimizations
LITEOS_COPTS_BASE += -fno-aggressive-loop-optimizations
endif
LITEOS_COPTS_EXTRA := -std=c99 -Wpointer-arith -Wstrict-prototypes -Winvalid-pch \
-ffunction-sections -fdata-sections -fno-exceptions $(FP)
ifneq ($(LOSCFG_ARCH_ARM_AARCH64), y)
LITEOS_COPTS_EXTRA += -std=c99 -Wpointer-arith -Wstrict-prototypes -ffunction-sections -fdata-sections -fno-exceptions -fno-short-enums
ifeq ($(LOSCFG_ARCH_ARM_AARCH32), y)
ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LITEOS_COPTS_BASE += -mno-unaligned-access
LITEOS_COPTS_EXTRA += -mthumb-interwork
LITEOS_COPTS_EXTRA += -mthumb-interwork
endif
endif
LITEOS_COPTS_EXTRA += -fno-short-enums
ifeq ($(LOSCFG_THUMB), y)
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LITEOS_CFLAGS_INTERWORK := -mthumb -mimplicit-it=thumb
@ -595,9 +596,5 @@ LITEOS_LD_SCRIPT := -T$(LITEOSTOPDIR)/tools/build/liteos.ld
endif
##compiler##
_CC = $(CC) $(LITEOS_CORE_COPTS)
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
_CC += $(LLVM_EXTRA_OPTS) $(LLVM_EXTRA_LD_OPTS)
endif
LITEOS_BASELIB += $(shell $(_CC) "-print-libgcc-file-name")
LITEOS_LIB_INCLUDE += -isystem $(shell $(_CC) "-print-file-name=include")
LITEOS_BASELIB += $(shell $(CC) $(LITEOS_CORE_COPTS) "-print-libgcc-file-name")
LITEOS_LIB_INCLUDE += -isystem $(shell $(CC) $(LITEOS_CORE_COPTS) "-print-file-name=include")

View File

@ -1,129 +1,114 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OBJOUT := $(BUILD)$(dir $(subst $(LITEOSTOPDIR),,$(shell pwd)))$(MODULE_NAME)
ifeq ($(LOCAL_SO), y)
LIBSO := $(OUT)/lib/lib$(MODULE_NAME).so
LIBA := $(OUT)/lib/lib$(MODULE_NAME).a
else
LIBSO :=
LIBA := $(OUT)/lib/lib$(MODULE_NAME).a
endif
LIB := $(LIBA) $(LIBSO)
# create a separate list of objects per source type
LOCAL_CSRCS := $(filter %.c,$(LOCAL_SRCS))
LOCAL_CPPSRCS := $(filter %.cpp,$(LOCAL_SRCS))
LOCAL_ASMSRCS := $(filter %.S,$(LOCAL_SRCS))
LOCAL_ASMSRCS2 := $(filter %.s,$(LOCAL_SRCS))
LOCAL_CCSRCS := $(filter %.cc,$(LOCAL_SRCS))
LOCAL_COBJS := $(patsubst %.c,$(OBJOUT)/%.o,$(LOCAL_CSRCS))
LOCAL_CPPOBJS := $(patsubst %.cpp,$(OBJOUT)/%.o,$(LOCAL_CPPSRCS))
LOCAL_ASMOBJS := $(patsubst %.S,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS))
LOCAL_ASMOBJS2 := $(patsubst %.s,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS2))
LOCAL_CCOBJS := $(patsubst %.cc,$(OBJOUT)/%.o,$(LOCAL_CCSRCS))
LOCAL_OBJS := $(LOCAL_COBJS) $(LOCAL_CPPOBJS) $(LOCAL_ASMOBJS) $(LOCAL_ASMOBJS2) $(LOCAL_CCOBJS)
LOCAL_CGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CHS))
LOCAL_CPPGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CPPHS))
all : $(LIB)
$(LOCAL_COBJS): $(OBJOUT)/%.o: %.c
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@
$(LOCAL_CPPOBJS): $(OBJOUT)/%.o: %.cpp
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
$(LOCAL_ASMOBJS): $(OBJOUT)/%.o: %.S
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
$(LOCAL_ASMOBJS2): $(OBJOUT)/%.o: %.s
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(AS) $(LITEOS_ASFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
$(LOCAL_CCOBJS): $(OBJOUT)/%.o: %.cc
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
$(LOCAL_CGCH): %.h.gch : %.h
$(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) $> $^
$(LOCAL_CPPGCH): %.h.gch : %.h
$(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -x c++-header $> $^
LOCAL_GCH := $(LOCAL_CGCH) $(LOCAL_CPPGCH)
$(LOCAL_OBJS): $(LOCAL_GCH)
$(LIBA): $(LOCAL_OBJS)
$(HIDE)$(OBJ_MKDIR)
ifeq ($(OS), Linux)
$(HIDE)$(AR) $(ARFLAGS) $@ $(LOCAL_OBJS)
else
ifeq ($(LOCAL_MODULES),)
$(HIDE)$(AR) $(ARFLAGS) $@ $(LOCAL_OBJS)
else
$(HIDE)for i in $(LOCAL_MODULES); do \
pushd $(OBJOUT)/$$i 1>/dev/null; \
$(AR) $(ARFLAGS) $@ *.o;\
popd 1>/dev/null;\
done
endif
endif
ifeq ($(LOCAL_SO), y)
$(LIBSO): $(LOCAL_OBJS)
$(HIDE)$(CC) $(LITEOS_CFLAGS) -fPIC -shared $^ -o $@
endif
clean:
$(HIDE)$(RM) $(LIB) $(OBJOUT) $(LOCAL_GCH) *.bak *~
.PHONY: all clean
# clear some variables we set here
LOCAL_CSRCS :=
LOCAL_CPPSRCS :=
LOCAL_ASMSRCS :=
LOCAL_COBJS :=
LOCAL_CPPOBJS :=
LOCAL_ASMOBJS :=
LOCAL_ASMOBJS2 :=
# LOCAL_OBJS is passed back
#LOCAL_OBJS :=
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OBJOUT := $(BUILD)$(dir $(subst $(LITEOSTOPDIR),,$(shell pwd)))$(MODULE_NAME)
MODULE := $(OUT)/lib/lib$(MODULE_NAME).a
# create a separate list of objects per source type
LOCAL_CSRCS := $(filter %.c,$(LOCAL_SRCS))
LOCAL_CPPSRCS := $(filter %.cpp,$(LOCAL_SRCS))
LOCAL_ASMSRCS := $(filter %.S,$(LOCAL_SRCS))
LOCAL_ASMSRCS2 := $(filter %.s,$(LOCAL_SRCS))
LOCAL_CCSRCS := $(filter %.cc,$(LOCAL_SRCS))
LOCAL_COBJS := $(patsubst %.c,$(OBJOUT)/%.o,$(LOCAL_CSRCS))
LOCAL_CPPOBJS := $(patsubst %.cpp,$(OBJOUT)/%.o,$(LOCAL_CPPSRCS))
LOCAL_ASMOBJS := $(patsubst %.S,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS))
LOCAL_ASMOBJS2 := $(patsubst %.s,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS2))
LOCAL_CCOBJS := $(patsubst %.cc,$(OBJOUT)/%.o,$(LOCAL_CCSRCS))
LOCAL_OBJS := $(LOCAL_COBJS) $(LOCAL_CPPOBJS) $(LOCAL_ASMOBJS) $(LOCAL_ASMOBJS2) $(LOCAL_CCOBJS)
LOCAL_CGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CHS))
LOCAL_CPPGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CPPHS))
all : $(MODULE)
define ECHO =
ifeq ($$(HIDE),@)
_$(1) := $($(1))
$(1) = echo " $(1)" $$(patsubst $$(OUT)/%,%,$$@) && $$(_$(1))
endif
endef
$(foreach cmd,CC GPP AS AR,$(eval $(call ECHO,$(cmd))))
LOCAL_FLAGS += -MD -MP
-include $(LOCAL_OBJS:%.o=%.d)
$(LOCAL_COBJS): $(OBJOUT)/%.o: %.c
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@
$(LOCAL_CPPOBJS): $(OBJOUT)/%.o: %.cpp
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
$(LOCAL_ASMOBJS): $(OBJOUT)/%.o: %.S
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
$(LOCAL_ASMOBJS2): $(OBJOUT)/%.o: %.s
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(AS) $(LITEOS_ASFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
$(LOCAL_CCOBJS): $(OBJOUT)/%.o: %.cc
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
$(LOCAL_CGCH): %.h.gch : %.h
$(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) $> $^
$(LOCAL_CPPGCH): %.h.gch : %.h
$(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -x c++-header $> $^
LOCAL_GCH := $(LOCAL_CGCH) $(LOCAL_CPPGCH)
$(LOCAL_OBJS): $(LOCAL_GCH)
$(MODULE): $(LOCAL_OBJS)
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(AR) $(ARFLAGS) $@ $^
clean:
$(HIDE)$(RM) $(MODULE) $(OBJOUT) $(LOCAL_GCH) *.bak *~
.PHONY: all clean
# clear some variables we set here
LOCAL_CSRCS :=
LOCAL_CPPSRCS :=
LOCAL_ASMSRCS :=
LOCAL_COBJS :=
LOCAL_CPPOBJS :=
LOCAL_ASMOBJS :=
LOCAL_ASMOBJS2 :=
# LOCAL_OBJS is passed back
#LOCAL_OBJS :=