chore: enable make of mksh and toybox
Signed-off-by: Caoruihong <crh.cao@huawei.com> Change-Id: Ie152b0ad21af5dc8e8c31c71f236500e5726e1c4
This commit is contained in:
parent
45a128a4f0
commit
682ae82158
2
BUILD.gn
2
BUILD.gn
|
@ -378,7 +378,7 @@ group("liteos_a") {
|
|||
|
||||
build_ext_component("make") {
|
||||
exec_path = rebase_path(".", root_build_dir)
|
||||
outdir = rebase_path(get_path_info(".", "out_dir"))
|
||||
outdir = rebase_path("$target_out_dir/${target_name}_out")
|
||||
sysroot_path = rebase_path(ohos_current_sysroot)
|
||||
arch_cflags = string_join(" ", target_arch_cflags)
|
||||
command = "./build.sh \"$board_name\" \"$ohos_build_compiler\" \"$root_build_dir\" \"$ohos_build_type\" \"$tee_enable\""
|
||||
|
|
2
Makefile
2
Makefile
|
@ -180,8 +180,8 @@ else
|
|||
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libgcc_s.so.1) $(OUT)/musl
|
||||
$(HIDE)cp -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libstdc++.so.6) $(OUT)/musl
|
||||
endif
|
||||
$(HIDE)$(STRIP) $(OUT)/musl/*
|
||||
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR)
|
||||
$(HIDE)shopt -s nullglob && $(STRIP) $(ROOTFS_DIR)/bin/* $(ROOTFS_DIR)/lib/*
|
||||
ifneq ($(VERSION),)
|
||||
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR)
|
||||
endif
|
||||
|
|
|
@ -30,16 +30,24 @@
|
|||
include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LLVM_SYSROOT := --sysroot=$(SYSROOT_PATH) $(ARCH_CFLAGS)
|
||||
LLVM_SYSROOT := --sysroot=$(SYSROOT_PATH)
|
||||
endif
|
||||
|
||||
# common flags config
|
||||
BASE_OPTS := -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fno-common -fno-strict-aliasing -D_GNU_SOURCE \
|
||||
$(LITEOS_SSP) $(LITEOS_CORE_COPTS) $(WARNING_AS_ERROR) $(LLVM_EXTRA_OPTS) $(LLVM_SYSROOT) $(LITEOS_GCOV_OPTS)
|
||||
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)
|
||||
|
||||
CFLAGS := -std=c99 -fPIE -fno-exceptions $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
||||
CXXFLAGS := -std=c++11 -fPIE -fexceptions -fpermissive -frtti $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
||||
LDFLAGS := -pie -s -Wl,-z,relro,-z,now $(BASE_OPTS) $(LLVM_EXTRA_LD_OPTS)
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
OPTMIZE_OPTS = -Oz
|
||||
else
|
||||
OPTMIZE_OPTS = -O2
|
||||
endif
|
||||
|
||||
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)
|
||||
|
||||
# alias variable config
|
||||
HIDE := @
|
||||
|
@ -55,8 +63,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)
|
||||
|
|
|
@ -32,22 +32,8 @@ import("//kernel/liteos_a/liteos.gni")
|
|||
executable("init") {
|
||||
sources = [ "src/init.c" ]
|
||||
|
||||
cflags = [ "-fPIE" ]
|
||||
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [
|
||||
"-Wno-shift-op-parentheses",
|
||||
"-Wno-bitwise-op-parentheses",
|
||||
"-Wnonnull",
|
||||
]
|
||||
}
|
||||
|
||||
ldflags = [
|
||||
"-pie",
|
||||
"-s",
|
||||
]
|
||||
|
||||
if (defined(LOSCFG_QUICK_START)) {
|
||||
ldflags += [ "--static" ]
|
||||
ldflags = [ "--static" ]
|
||||
defines = [ "LOSCFG_QUICK_START" ]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ build_ext_component("build_mksh") {
|
|||
"-flto",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-Oz",
|
||||
"-fstack-protector-strong",
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
"-DMKSH_DISABLE_TTY_WARNING",
|
||||
|
@ -62,6 +61,11 @@ build_ext_component("build_mksh") {
|
|||
"-DMKSH_NO_INITCOMS",
|
||||
"-DADAPT_FOR_LITEOS_A",
|
||||
]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-Oz" ]
|
||||
} else {
|
||||
cflags += [ "-O2" ]
|
||||
}
|
||||
cflags = string_join(" ", cflags)
|
||||
|
||||
extra_flags = string_join(" ", target_arch_cflags)
|
||||
|
|
|
@ -29,50 +29,28 @@
|
|||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
MKSH := mksh
|
||||
BUILD_DIR := $(OUT)/mksh_build
|
||||
BUILD_LOG := $(BUILD_DIR)/build.log
|
||||
|
||||
MKSH_DIR := $(shell pwd)/
|
||||
CFLAGS += -DMKSH_DISABLE_TTY_WARNING -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=1 -DMKSH_SMALL_BUT_FAST=0 -DMKSH_S_NOVI=1 -DHAVE_CAN_FSTACKPROTECTORSTRONG=1
|
||||
CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
|
||||
CFLAGS += -Wno-error
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
APPS_OUT := $(OUT)/bin
|
||||
ETC_OUT := $(OUT)/etc
|
||||
BUILD_DIR := $(MKSH_DIR)/build
|
||||
BUILD_LOG := $(MKSH_DIR)/build.log
|
||||
TARGET_OS := OpenHarmony
|
||||
|
||||
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -fstack-protector-strong -D_FORTIFY_SOURCE=2
|
||||
LOCAL_CFLAGS += -DMKSH_DISABLE_TTY_WARNING -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=1 -DMKSH_SMALL_BUT_FAST=0 -DMKSH_S_NOVI=1 -DHAVE_CAN_FSTACKPROTECTORSTRONG=1
|
||||
LOCAL_CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
|
||||
LOCAL_LDFLAGS := -Wl,--gc-sections -flto -O2
|
||||
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LOCAL_CFLAGS += -Oz --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
|
||||
else
|
||||
LOCAL_CFLAGS += -O2
|
||||
endif
|
||||
|
||||
all:$(MKSH)
|
||||
|
||||
$(MKSH):
|
||||
all:
|
||||
ifneq ($(wildcard $(BUILD_DIR)/Rebuild.sh),)
|
||||
$(HIDE)echo "not clean, rebuilding now"
|
||||
$(HIDE)chmod +x $(BUILD_DIR)/Rebuild.sh
|
||||
$(HIDE)cd $(BUILD_DIR) && ./Rebuild.sh > $(BUILD_LOG) 2>&1
|
||||
$(HIDE)cd $(BUILD_DIR) && sh ./Rebuild.sh > $(BUILD_LOG) 2>&1
|
||||
else
|
||||
$(HIDE)mkdir -p $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(MKSH)/. $(BUILD_DIR)
|
||||
$(HIDE)chmod +x $(BUILD_DIR)/Build.sh
|
||||
$(HIDE)cd $(BUILD_DIR) && CC=$(CC) TARGET_OS=$(TARGET_OS) CFLAGS="$(LOCAL_CFLAGS)" LDFLAGS="$(LOCAL_LDFLAGS)" ./Build.sh -r > $(BUILD_LOG) 2>&1
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/mksh/. $(BUILD_DIR)
|
||||
$(HIDE)cd $(BUILD_DIR) && CC="$(CC)" TARGET_OS=OpenHarmony CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" sh ./Build.sh -r > $(BUILD_LOG) 2>&1
|
||||
endif
|
||||
$(HIDE)$(CP) -rf $(BUILD_DIR)/$(MKSH) .
|
||||
$(HIDE)$(STRIP) $(MKSH)
|
||||
$(HIDE)mkdir -p $(APPS_OUT)
|
||||
$(HIDE)$(CP) $(MKSH) $(APPS_OUT)
|
||||
$(HIDE)mkdir -p $(ETC_OUT)
|
||||
$(HIDE)$(CP) -rf $(BUILD_DIR)/.mkshrc $(ETC_OUT)/
|
||||
$(HIDE)$(RM) $(BUILD_DIR) $(BUILD_LOG)
|
||||
$(HIDE)mkdir -p $(OUT)/bin/ $(OUT)/etc/
|
||||
$(HIDE)$(STRIP) $(BUILD_DIR)/mksh -o $(OUT)/bin/mksh
|
||||
$(HIDE)$(CP) $(BUILD_DIR)/.mkshrc $(OUT)/etc/
|
||||
|
||||
clean:
|
||||
$(HIDE)$(RM) $(MKSH) $(BUILD_DIR) $(BUILD_LOG)
|
||||
$(HIDE)$(RM) $(BUILD_DIR)
|
||||
|
||||
|
||||
.PHONY: all $(MKSH) clean
|
||||
.PHONY: all clean
|
||||
|
|
|
@ -41,18 +41,4 @@ executable("shell") {
|
|||
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
||||
|
||||
include_dirs = [ "include" ]
|
||||
|
||||
cflags = [ "-fPIE" ]
|
||||
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [
|
||||
"-Wno-shift-op-parentheses",
|
||||
"-Wno-bitwise-op-parentheses",
|
||||
]
|
||||
}
|
||||
|
||||
ldflags = [
|
||||
"-pie",
|
||||
"-s",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -38,18 +38,4 @@ executable("tftp") {
|
|||
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
||||
|
||||
include_dirs = [ "include" ]
|
||||
|
||||
cflags = [ "-fPIE" ]
|
||||
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [
|
||||
"-Wno-shift-op-parentheses",
|
||||
"-Wno-bitwise-op-parentheses",
|
||||
]
|
||||
}
|
||||
|
||||
ldflags = [
|
||||
"-pie",
|
||||
"-s",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -29,40 +29,25 @@
|
|||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
TOYBOX:= toybox
|
||||
BUILD_DIR := $(OUT)/toybox_build
|
||||
BUILD_LOG := $(BUILD_DIR)/build.log
|
||||
|
||||
TOYBOX_DIR := $(shell pwd)
|
||||
CFLAGS += -Wno-error
|
||||
|
||||
APPS_OUT := $(OUT)/bin
|
||||
BUILD_DIR := $(TOYBOX_DIR)/build
|
||||
BUILD_LOG := $(TOYBOX_DIR)/build.log
|
||||
OUTNAME := $(TOYBOX)
|
||||
|
||||
CFLAGS := -D_FORTIFY_SOURCE=2 -fstack-protector-strong
|
||||
LDFLAGS :=
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
CFLAGS += --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
|
||||
LDFLAGS += --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
|
||||
endif
|
||||
|
||||
$(TOYBOX):
|
||||
all:
|
||||
ifneq ($(wildcard $(BUILD_DIR)),)
|
||||
$(HIDE)echo "not clean, rebuilding now";
|
||||
$(HIDE)echo "not clean, rebuilding now"
|
||||
else
|
||||
$(HIDE)mkdir $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(TOYBOX)/. $(BUILD_DIR)
|
||||
$(HIDE)$(CP) -p $(LITEOSTHIRDPARTY)/$(TOYBOX)/porting/liteos_a/. $(BUILD_DIR)
|
||||
$(HIDE)mkdir -p $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/. $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/porting/liteos_a/. $(BUILD_DIR)
|
||||
$(HIDE)$(CP) liteos_a_custom.config $(BUILD_DIR)/../
|
||||
endif
|
||||
|
||||
$(HIDE)CFLAGS="$(CFLAGS)" CC="$(CC)" OUTNAME="$(OUTNAME)" \
|
||||
LDFLAGS="$(LDFLAGS)" STRIP="$(STRIP)" \
|
||||
$(HIDE)unset KCONFIG_CONFIG CROSS_COMPILE && \
|
||||
env CC="$(CC)" OUTNAME="$(OUT)/bin/toybox" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" STRIP="$(STRIP)" \
|
||||
make -C $(BUILD_DIR) toybox -j> $(BUILD_LOG) 2>&1
|
||||
$(HIDE)$(CP) $(BUILD_DIR)/$(TOYBOX) .
|
||||
$(HIDE)mkdir -p $(APPS_OUT)
|
||||
$(HIDE)$(CP) $(TOYBOX) $(APPS_OUT)
|
||||
$(HIDE)$(RM) $(BUILD_DIR) $(BUILD_LOG)
|
||||
|
||||
clean:
|
||||
$(HIDE)$(RM) $(TOYBOX) $(BUILD_DIR) $(BUILD_LOG)
|
||||
$(HIDE)$(RM) $(BUILD_DIR)
|
||||
|
||||
.PHONY: all $(TOYBOX) clean
|
||||
.PHONY: all clean
|
||||
|
|
|
@ -595,12 +595,9 @@ LITEOS_LD_SCRIPT := -T$(LITEOSTOPDIR)/tools/build/liteos.ld
|
|||
endif
|
||||
|
||||
##compiler##
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
_CC = $(CC) $(LLVM_EXTRA_OPTS) $(LLVM_EXTRA_LD_OPTS) $(LITEOS_CORE_COPTS)
|
||||
LITEOS_BASELIB += $(shell $(_CC) "-print-file-name=libunwind.a") --no-dependent-libraries
|
||||
else
|
||||
_CC = $(CC) $(LITEOS_CORE_COPTS)
|
||||
LITEOS_BASELIB += $(shell $(_CC) "-print-file-name=libgcc_eh.a")
|
||||
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")
|
||||
|
|
Loading…
Reference in New Issue