#!/bin/bash # Author: qinzhenghui # Description: 编译项目脚本 # Update Date: 2025-06-18 # 定义函数用于处理错误并退出 handle_error() { local error_message=$1 echo "错误: $error_message" return 1 } scons --clean scons -j3 if [ $? -ne 0 ]; then handle_error "scons -j3 编译失败" exit 1 fi files=("build/app.map" "build/app.asm" "build/app.elf" "build/app.bin") declare -a file_infos for file in "${files[@]}"; do if [ -f "$file" ]; then file_name=$(basename "$file") # 调整此处提取时间,只保留到秒 modification_time=$(stat -c %y "$file" | awk '{print $1 " " substr($2, 1, 8)}') file_size=$(stat -c %s "$file") file_size=$((file_size)) file_infos+=("$file_name $modification_time $file_size") fi done echo -e "文件名称\t修改时间\t文件大小(B)" for info in "${file_infos[@]}"; do IFS=' ' read -ra parts <<< "$info" echo -e "${parts[0]}\t\t${parts[1]}/${parts[2]}\t${parts[3]}" done | column -t exit 0