#!/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=${TARGET_PRODUCT} if [ -z ${TARGET_PRODUCT} ];then PROJECT_ROOT=$(while [ ! -f "build/envsetup.sh" ]; do [ "$(pwd)" = "/" ] && exit 1; cd ..; done; pwd) if [ ! -z ${PROJECT_ROOT} ];then source ${PROJECT_ROOT}/build/envsetup.sh && lunch LAST if [ $? -eq 255 ];then exit 0; fi pd_complier_type=${TARGET_PRODUCT} fi fi echo -e " ready to build\e[34;1m ${pd_complier_type} \e[0m target [\e[34;1m ${current_project_name}\e[0m ] ......" if [ -f "../../.config" ]; then if grep -q "TARGET_PRODUCT=imx9" ../../.config; then echo "imx9 not have hmi, exit" exit; fi fi unset LD_LIBRARY_PATH export pd_complier_name="$(if [[ "${TARGET_PRODUCT}" =~ "imx"* ]]; then echo "complier_arm"; else echo "complier_x86"; fi)" export arm_sysroot_path=${SYSROOT} export arm_compile_flags=${CFLAGS} echo "============================build shell start [${current_project_name}]====================================================" # set obj at: platform/out/build/xxxx/build check_dirs() { # check dir: process/ script/ local dir="$1"; if [[ -d "$dir/process" && -d "$dir/script" ]]; then echo "$dir"; exit 0;fi local parent="${dir%/*}"; if [[ "$parent" != "$dir" ]]; then check_dirs "$parent"; else echo "$(pwd)"; fi } base_folder="$(echo ${PROJECT_ROOT}|tr -s '/')" if [[ $current_project_path =~ "$base_folder" ]] && [ ! -z $base_folder ]; then echo "" else echo "base_folder = $base_folder" echo "current_project_path = $current_project_path" echo -e "\e[31m Error: 环境配置不匹配,在当前项目下请重新配置:\n\e[35m\t source build/envsetup.sh \e[0m" exit -2 fi build_path=$(echo "$current_project_path" | sed "s|${base_folder}|${base_folder}/out/build/${pd_complier_type}/|g") echo "build_path = ${build_path}" echo "PATH: qmake ..." /opt/fsl-imx-wayland/5.10-hardknott/sysroots/x86_64-pokysdk-linux/usr/bin/qmake -o GNUmakefile # #配置更新同步翻译文件操作 lupdate EMS_Hmi.pro lrelease EMS_Hmi.pro #if [ $# -eq 0 ];then #echo "make -f GNUmakefile clean" # DO NOT ADD -j # make -f GNUmakefile -j4 && find -name "ems_hmi" | xargs ls -t | head -n1 | xargs cp -vt ../../board_dir/bin/ pwd if [[ $1 == "clean" ]] || [[ $1 == "-c" ]];then make -f GNUmakefile clean echo " clean done." if [[ "$1" != "all" ]];then needClean=clean fi fi if [[ "$needClean" != "clean" ]];then make -f GNUmakefile -j4 fi #fi