44 lines
1.8 KiB
Bash
44 lines
1.8 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] 执行时间:$execution_time_formatted ( $mydir_name )\e[0m "
|
||
|
|
}
|
||
|
|
|
||
|
|
# auto find build
|
||
|
|
lib_src_dir_list=$(find */ -maxdepth 1 -type f -name build.sh -exec dirname {} \;)
|
||
|
|
statistical_lists=""
|
||
|
|
ignore_lists=""
|
||
|
|
for dir in ${lib_src_dir_list[@]}; do
|
||
|
|
if [[ "$dir" =~ "testui" ]]; then
|
||
|
|
echo -e "\e[35mignore dir: \e[34m$dir\e[0m"
|
||
|
|
ignore_lists+=("\n\t\t\t\t${dir}")
|
||
|
|
#cd "$dir" || { echo "Failed to change to directory $dir"; continue; } && \
|
||
|
|
#echo -e "\e[33;42;1mcd `pwd`/ \e[0m" && \
|
||
|
|
#sh build.sh $@ || exit $? || { echo "Failed to execute build.sh in directory $dir"; cd - > /dev/null; continue; } && \
|
||
|
|
#cd -
|
||
|
|
else
|
||
|
|
if [ -f "$dir"/build.sh ];then
|
||
|
|
echo -e "\e[32m enter dir: \e[34m$dir\e[0m"
|
||
|
|
cd "$dir" || { echo "Failed to change to directory $dir"; continue; } && \
|
||
|
|
sh build.sh $@ || exit $? || { echo "Failed to execute build.sh in directory $dir"; cd - > /dev/null; continue; } && \
|
||
|
|
cd -
|
||
|
|
statistical_lists+=("\n\t\t\t\t$dir")
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
|
||
|
|
echo -e "\e[34m build Statistical Lists [$((${#statistical_lists[@]}-1))]: ${statistical_lists[@]} \e[0m"
|
||
|
|
echo -e "\e[37m Ignore Lists[$((${#ignore_lists[@]}-1))]: ${ignore_lists[@]} \e[0m"
|