Files
he/process/cloud_apps/build.sh
T
2026-06-22 15:35:18 +08:00

40 lines
1.6 KiB
Bash

#!/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] Compilation Time: $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}]===================================================="
#再编译可执行程序:进入非EXCLUDED_DIRECTORIES子目录下执行编译
EXCLUDED_SUBDIRS="processers reuse_utils"
for fn in `ls`
do
#仅判定文件夹
if [ -d "$fn" ]; then
#不在EXCLUDED_SUBDIRS的子文件夹,才需要进入编译
if [[ ! "${EXCLUDED_SUBDIRS[@]}" =~ "$fn" ]]; then
if [ -f $fn/build.sh ];then
cd $fn
echo -e "\e[33;42;1mcd `pwd`/ \e[0m"
sh build.sh $@ || exit $?
cd ../
fi
fi
fi
done