#!/bin/bash cd "$(dirname "$(readlink -f "$0")")" script_name=$(basename "$0") #if [ "$0" = "$script_name" ]; then echo "脚本被自身调用,请检查无效路径"; exit 1 ;fi # 显示脚本执行时间 start_time=$(date +%s); trap 'echo "$(print_execution_time $?)"' EXIT # 计算并打印脚本执行时间函数 function print_execution_time { end_time=$(date +%s); execution_time=$((end_time - start_time)); execution_time_formatted=$(date -u -d @$execution_time +"%T") if [ $1 -eq 0 ];then SET_COLOR="\e[32m "; else SET_COLOR="\e[31m error at $(pwd) \n\e[1m"; fi mydir_name="$(d=$(pwd); echo ${d##*/})" echo -e "${SET_COLOR} [$1] 执行时间:$execution_time_formatted ( $mydir_name )\e[0m " } current_project_path=$(pwd) export current_project_name=`echo ${current_project_path##*/}` echo "current_project_path = ${current_project_path}" echo "====================================================build shell start [ ${current_project_name} ]====================================================" pd_complier_type=`../../complier.sh temp $@` if [ "$pd_complier_type" = "arm" ]; then echo -e " ready to build\e[34;1m ARM \e[0m target [ ${current_project_name} ] ......" unset LD_LIBRARY_PATH sourc_path="/opt/fsl-imx-wayland/5.10-hardknott/environment-setup-cortexa53-crypto-poky-linux" source $sourc_path export pd_complier_name="complier_arm" # export arm_sysroot_path=`cat ../../../arm_sysroot_path` # export arm_compile_flags=`cat ../../../arm_compile_flags` # export arm_sysroot_path="/opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa53-crypto-poky-linux" # export arm_compile_flags="-mcpu=cortex-a53 -march=armv8-a+crc+crypto -D_FORTIFY_SOURCE=2" else echo -e " ready to build\e[34;1m x86 \e[0m target [ ${current_project_name} ] ......" export pd_complier_name="complier_x86" fi # set obj at: platform/out/build/xxxx/build build_path=$(echo "$current_project_path" | sed "s|/platform/|/platform/out/build/${pd_complier_type}/|g") echo "build_path = ${build_path}" if [[ $1 == "clean" ]] || [[ $1 == "-c" ]] || [[ $1 == "all" ]];then rm -rvf ${build_path} echo " clean done." echo "====================================================build shell end [ ${current_project_name} ]====================================================" if [[ $1 != "all" ]]; then exit 0; fi fi # build path mkdir -p ${build_path} cmake -B ${build_path} cd ${build_path} && \ echo "----------------make start----------------" && \ make -j4 || exit $? && \ cd - echo "====================================================build shell end [ ${current_project_name} ] [${pd_complier_type}]====================================================" # for Test: x86时,编译完成后可以直接运行 if [[ "$1" == "-r" ]] && [[ "$pd_complier_type" = "x86" ]];then cmd="../../board_dir/x86_bin/${current_project_name}" echo "${cmd}" eval "${cmd}" fi