!359 sysroot和CPU架构参数通过BUILD.gn传递给Make
Merge pull request !359 from Caoruihong/sysroot
This commit is contained in:
commit
abbeca1cb2
5
BUILD.gn
5
BUILD.gn
|
@ -77,7 +77,8 @@ build_ext_component("make") {
|
||||||
if (board_name == "hi3516dv300" && enable_tee_ree) {
|
if (board_name == "hi3516dv300" && enable_tee_ree) {
|
||||||
tee_enable = "tee"
|
tee_enable = "tee"
|
||||||
}
|
}
|
||||||
prebuilts = "sh build.sh ${board_name} ${ohos_build_compiler} ${root_build_dir} ${ohos_build_type} ${tee_enable} \"${device_company}\" \"${product_path}\""
|
|
||||||
outdir = rebase_path(get_path_info(".", "out_dir"))
|
outdir = rebase_path(get_path_info(".", "out_dir"))
|
||||||
command = "make clean OUTDIR=$outdir PRODUCT_PATH=\"${product_path}\" && make rootfs VERSION=\"${ohos_version}\" PRODUCT_PATH=\"${product_path}\" -j 16 OUTDIR=$outdir"
|
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} \"${device_company}\" \"${product_path}\" $outdir \"${ohos_version}\" ${sysroot_path} \"${arch_cflags}\""
|
||||||
}
|
}
|
||||||
|
|
11
Makefile
11
Makefile
|
@ -82,6 +82,9 @@ ROOTFS_DIR = $(OUT)/rootfs
|
||||||
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
||||||
VERSION =
|
VERSION =
|
||||||
|
|
||||||
|
SYSROOT_PATH ?= $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot
|
||||||
|
export SYSROOT_PATH
|
||||||
|
|
||||||
all: $(OUT) $(BUILD) $(LITEOS_TARGET) $(APPS)
|
all: $(OUT) $(BUILD) $(LITEOS_TARGET) $(APPS)
|
||||||
lib: $(OUT) $(BUILD) $(LITEOS_LIBS_TARGET)
|
lib: $(OUT) $(BUILD) $(LITEOS_LIBS_TARGET)
|
||||||
|
|
||||||
|
@ -165,11 +168,15 @@ $(LITEOS_TARGET): $(__LIBS)
|
||||||
$(APPS): $(LITEOS_TARGET)
|
$(APPS): $(LITEOS_TARGET)
|
||||||
$(HIDE)$(MAKE) -C apps all
|
$(HIDE)$(MAKE) -C apps all
|
||||||
|
|
||||||
|
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||||
|
MULTILIB := $(patsubst $(shell $(CC) --target=$(LLVM_TARGET) $(ARCH_CFLAGS) -print-file-name=lib/$(LLVM_TARGET)/)%,%,$(dir $(shell $(CC) --target=$(LLVM_TARGET) $(ARCH_CFLAGS) -print-libgcc-file-name)))
|
||||||
|
endif
|
||||||
|
|
||||||
prepare:
|
prepare:
|
||||||
$(HIDE)mkdir -p $(OUT)/musl
|
$(HIDE)mkdir -p $(OUT)/musl
|
||||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||||
$(HIDE)cp -f $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/usr/lib/$(LLVM_TARGET)/a7_softfp_neon-vfpv4/libc.so $(OUT)/musl
|
$(HIDE)cp -f $(SYSROOT_PATH)/usr/lib/$(LLVM_TARGET)/$(MULTILIB)/libc.so $(OUT)/musl
|
||||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/lib/$(LLVM_TARGET)/c++/a7_softfp_neon-vfpv4/libc++.so $(OUT)/musl
|
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/lib/$(LLVM_TARGET)/c++/$(MULTILIB)/libc++.so $(OUT)/musl
|
||||||
else
|
else
|
||||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/target/usr/lib/libc.so $(OUT)/musl
|
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/target/usr/lib/libc.so $(OUT)/musl
|
||||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libstdc++.so.6 $(OUT)/musl
|
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libstdc++.so.6 $(OUT)/musl
|
||||||
|
|
|
@ -44,7 +44,7 @@ CFLAGS := -std=c99 -fno-exceptions $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
||||||
CXXFLAGS := -std=c++11 -fexceptions -fpermissive -frtti $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
CXXFLAGS := -std=c++11 -fexceptions -fpermissive -frtti $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
||||||
LDCFLAGS := -lc
|
LDCFLAGS := -lc
|
||||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||||
LLVM_SYSROOT := --sysroot=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/
|
LLVM_SYSROOT := --sysroot=$(SYSROOT_PATH) $(ARCH_CFLAGS)
|
||||||
LDCXXFLGS := -lc++ -lc++abi -lc
|
LDCXXFLGS := -lc++ -lc++abi -lc
|
||||||
else
|
else
|
||||||
BASE_OPTS += -Wl,-z,relro,-z,now
|
BASE_OPTS += -Wl,-z,relro,-z,now
|
||||||
|
|
|
@ -38,11 +38,11 @@ BUILD_DIR := $(MKSH_DIR)/build
|
||||||
BUILD_LOG := $(MKSH_DIR)/build.log
|
BUILD_LOG := $(MKSH_DIR)/build.log
|
||||||
TARGET_OS := OpenHarmony
|
TARGET_OS := OpenHarmony
|
||||||
|
|
||||||
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -Oz -fstack-protector-strong -D_FORTIFY_SOURCE=2 -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4
|
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -Oz -fstack-protector-strong -D_FORTIFY_SOURCE=2
|
||||||
LOCAL_CFLAGS += --target=arm-liteos --sysroot=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/
|
LOCAL_CFLAGS += --target=arm-liteos $(LLVM_SYSROOT)
|
||||||
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_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_CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
|
||||||
LOCAL_LDFLAGS := -Wl,--gc-sections -flto -O2
|
LOCAL_LDFLAGS := -Wl,--gc-sections -flto -O2 --target=arm-liteos $(LLVM_SYSROOT)
|
||||||
|
|
||||||
all:$(MKSH)
|
all:$(MKSH)
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ else
|
||||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(TOYBOX)/. $(BUILD_DIR)
|
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(TOYBOX)/. $(BUILD_DIR)
|
||||||
$(HIDE)$(CP) -p $(LITEOSTHIRDPARTY)/$(TOYBOX)/porting/liteos_a/. $(BUILD_DIR)
|
$(HIDE)$(CP) -p $(LITEOSTHIRDPARTY)/$(TOYBOX)/porting/liteos_a/. $(BUILD_DIR)
|
||||||
endif
|
endif
|
||||||
$(HIDE)CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong --target=arm-liteos \
|
$(HIDE)CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong --target=arm-liteos $(LLVM_SYSROOT)" CC="$(CC)" OUTNAME=$(OUTNAME) \
|
||||||
--sysroot=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/" CC="$(CC)" OUTNAME=$(OUTNAME) \
|
LDFLAGS="--target=arm-liteos $(LLVM_SYSROOT)" \
|
||||||
make -C $(BUILD_DIR) toybox -j> $(BUILD_LOG) 2>&1
|
make -C $(BUILD_DIR) toybox -j> $(BUILD_LOG) 2>&1
|
||||||
$(HIDE)$(CP) $(BUILD_DIR)/$(TOYBOX) .
|
$(HIDE)$(CP) $(BUILD_DIR)/$(TOYBOX) .
|
||||||
$(HIDE)$(STRIP) $(TOYBOX)
|
$(HIDE)$(STRIP) $(TOYBOX)
|
||||||
|
|
|
@ -65,7 +65,7 @@ LITEOS_FPU_OPTS := -mfpu=$(LOSCFG_ARCH_FPU)
|
||||||
LITEOS_GCCLIB := $(subst cortex-,,$(LOSCFG_ARCH_CPU))_softfp_$(LOSCFG_ARCH_FPU)
|
LITEOS_GCCLIB := $(subst cortex-,,$(LOSCFG_ARCH_CPU))_softfp_$(LOSCFG_ARCH_FPU)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LITEOS_CORE_COPTS = $(LITEOS_CPU_OPTS) $(LITEOS_FLOAT_OPTS) $(LITEOS_FPU_OPTS)
|
LITEOS_CORE_COPTS = $(or $(ARCH_CFLAGS),$(LITEOS_CPU_OPTS) $(LITEOS_FLOAT_OPTS) $(LITEOS_FPU_OPTS))
|
||||||
LITEOS_INTERWORK += $(LITEOS_CORE_COPTS)
|
LITEOS_INTERWORK += $(LITEOS_CORE_COPTS)
|
||||||
LITEOS_NODEBUG += $(LITEOS_CORE_COPTS)
|
LITEOS_NODEBUG += $(LITEOS_CORE_COPTS)
|
||||||
LITEOS_ASOPTS += $(LITEOS_CPU_OPTS)
|
LITEOS_ASOPTS += $(LITEOS_CPU_OPTS)
|
||||||
|
|
105
build.sh
105
build.sh
|
@ -30,44 +30,71 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "sh param:$1,$2,$3,$4,$5,$6,$7"
|
board_name=${1}
|
||||||
destination=".config"
|
ohos_build_compiler=${2}
|
||||||
config_file=""
|
root_build_dir=${3}
|
||||||
tee=""
|
ohos_build_type=${4}
|
||||||
outdir="../..$3/test_info/gen/kernel/test"
|
tee_enable=${5}
|
||||||
if [ "$5" = "tee" ]; then
|
device_company=${6}
|
||||||
tee="_tee"
|
product_path=${7}
|
||||||
fi
|
outdir=${8}
|
||||||
product_name="$(basename $7)"
|
ohos_version=${9}
|
||||||
source="tools/build/config/${product_name}_release.config"
|
sysroot_path=${10}
|
||||||
if [ "$2" = "clang" ]; then
|
arch_cflags=${11}
|
||||||
if [ "$4" = "debug" ]; then
|
|
||||||
config_file="${product_name}_$2$tee.config"
|
|
||||||
source="tools/build/config/debug/$config_file"
|
|
||||||
else
|
|
||||||
config_file="${product_name}_$2_release$tee.config"
|
|
||||||
source="tools/build/config/$config_file"
|
|
||||||
fi
|
|
||||||
elif [ "$2" = "gcc" ]; then
|
|
||||||
if [ "$4" = "debug" ]; then
|
|
||||||
config_file="${product_name}_debug_shell$tee.config"
|
|
||||||
source="tools/build/config/$config_file"
|
|
||||||
else
|
|
||||||
config_file="${product_name}_release$tee.config"
|
|
||||||
source="tools/build/config/$config_file"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ -d "./out" ]; then
|
|
||||||
rm -rf ./out
|
|
||||||
fi
|
|
||||||
if [ -f "$destination" ]; then
|
|
||||||
rm -rf $destination
|
|
||||||
fi
|
|
||||||
if [ ! -f "$source" ]; then
|
|
||||||
source="$7/config/sys/$config_file"
|
|
||||||
fi
|
|
||||||
cp $source $destination
|
|
||||||
|
|
||||||
mkdir -p $outdir
|
echo "${board_name}" "${device_company}"
|
||||||
cp kernel_test.sources $outdir
|
echo "sh param:" "$@"
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
destination=".config"
|
||||||
|
config_file=""
|
||||||
|
tee=""
|
||||||
|
if [ "${tee_enable}" = "tee" ]; then
|
||||||
|
tee="_tee"
|
||||||
|
fi
|
||||||
|
product_name=$(basename "${product_path}")
|
||||||
|
source="tools/build/config/${product_name}_release.config"
|
||||||
|
if [ "${ohos_build_compiler}" = "clang" ]; then
|
||||||
|
if [ "${ohos_build_type}" = "debug" ]; then
|
||||||
|
config_file="${product_name}_${ohos_build_compiler}${tee}.config"
|
||||||
|
source="tools/build/config/debug/${config_file}"
|
||||||
|
else
|
||||||
|
config_file="${product_name}_${ohos_build_compiler}_release${tee}.config"
|
||||||
|
source="tools/build/config/${config_file}"
|
||||||
|
fi
|
||||||
|
elif [ "${ohos_build_compiler}" = "gcc" ]; then
|
||||||
|
if [ "${ohos_build_type}" = "debug" ]; then
|
||||||
|
config_file="${product_name}_debug_shell${tee}.config"
|
||||||
|
source="tools/build/config/${config_file}"
|
||||||
|
else
|
||||||
|
config_file="${product_name}_release${tee}.config"
|
||||||
|
source="tools/build/config/${config_file}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -d "./out" ]; then
|
||||||
|
rm -rf ./out
|
||||||
|
fi
|
||||||
|
if [ -f "${destination}" ]; then
|
||||||
|
rm -rf ${destination}
|
||||||
|
fi
|
||||||
|
if [ ! -f "${source}" ]; then
|
||||||
|
source="${product_path}/config/sys/${config_file}"
|
||||||
|
fi
|
||||||
|
cp "${source}" ${destination}
|
||||||
|
|
||||||
|
test_info_outdir="../..${root_build_dir}/test_info/gen/kernel/test"
|
||||||
|
mkdir -p "${test_info_outdir}"
|
||||||
|
cp kernel_test.sources "${test_info_outdir}"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "x" != "x${sysroot_path}" ]; then
|
||||||
|
export SYSROOT_PATH=${sysroot_path}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x" != "x${arch_cflags}" ]; then
|
||||||
|
export ARCH_CFLAGS="${arch_cflags}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
main && \
|
||||||
|
make clean OUTDIR="${outdir}" PRODUCT_PATH="${product_path}" && \
|
||||||
|
make -j rootfs VERSION="${ohos_version}" OUTDIR="${outdir}" PRODUCT_PATH="${product_path}"
|
||||||
|
|
|
@ -40,7 +40,7 @@ VDSO_INCLUDE := -I $(LITEOSTOPDIR)/kernel/extended/vdso/include \
|
||||||
VDSO_CCFLAGS := -nostdlib -fPIC -fno-common -fno-strict-aliasing \
|
VDSO_CCFLAGS := -nostdlib -fPIC -fno-common -fno-strict-aliasing \
|
||||||
$(LITEOS_SSP) $(LITEOS_CORE_COPTS) $(WARNING_AS_ERROR) $(LITEOS_COPTS_OPTMIZE)
|
$(LITEOS_SSP) $(LITEOS_CORE_COPTS) $(WARNING_AS_ERROR) $(LITEOS_COPTS_OPTMIZE)
|
||||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||||
VDSO_CCFLAGS += $(LLVM_EXTRA_OPTS) --sysroot=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/
|
VDSO_CCFLAGS += $(LLVM_EXTRA_OPTS) --sysroot=$(SYSROOT_PATH) $(ARCH_CFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
VDSO_LDFLAGS := -shared -s -Bsymbolic -T los_vdso.ld
|
VDSO_LDFLAGS := -shared -s -Bsymbolic -T los_vdso.ld
|
||||||
|
|
Loading…
Reference in New Issue