feat(cp02): add copy_o_files.sh for collecting .o files
- Add script to recursively copy .o files from build directory - Support command line arguments for source and target directories - Handle duplicate filenames with auto-incrementing suffix - Update README with usage documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
719c854fb9
commit
e5a9369440
@ -91,6 +91,14 @@
|
||||
- 第 64 个值仅写入第一个字节
|
||||
- 跳过 start/end 标记行
|
||||
|
||||
### copy_o_files.sh
|
||||
- **功能**: 递归复制目录中的所有 .o 文件到指定目标目录
|
||||
- **用法**: `./copy_o_files.sh <源目录> <目标目录>`
|
||||
- **描述**:
|
||||
- 递归搜索源目录中的所有 .o 文件
|
||||
- 自动处理重名文件(添加 _1, _2 等后缀)
|
||||
- 显示复制进度和统计信息
|
||||
|
||||
### merge_encrypted_firmware.py
|
||||
- **功能**: 合成已加密的固件和 IUM 为最终 programmer 固件
|
||||
- **用法**: `python3 merge_encrypted_firmware.py <base.bin> <encrypted.bin> <ium.bin> -o <output.bin>`
|
||||
@ -140,4 +148,7 @@ python3 txt_to_bin_converter.py ium11.txt ium11.bin # 文本转二
|
||||
|
||||
# 合成加密固件
|
||||
python3 merge_encrypted_firmware.py base.bin encrypted.bin ium.bin -o programmer.bin
|
||||
|
||||
# 复制 .o 文件
|
||||
./copy_o_files.sh /path/to/build /path/to/output
|
||||
```
|
||||
45
CP02/copy_o_files.sh
Executable file
45
CP02/copy_o_files.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "用法: $0 <源目录> <目标目录>"
|
||||
echo "示例: $0 /path/to/build /path/to/output"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SOURCE_DIR="$1"
|
||||
TARGET_DIR="$2"
|
||||
|
||||
if [ ! -d "$SOURCE_DIR" ]; then
|
||||
echo "错误: 源目录不存在: $SOURCE_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$TARGET_DIR"
|
||||
|
||||
echo "开始复制 .o 文件..."
|
||||
|
||||
find "$SOURCE_DIR" -name "*.o" -type f | while read -r file; do
|
||||
basename=$(basename "$file")
|
||||
base="${basename%.*}"
|
||||
ext="${basename##*.}"
|
||||
|
||||
if [ -f "$TARGET_DIR/$basename" ]; then
|
||||
counter=1
|
||||
new_name="${base}_${counter}.${ext}"
|
||||
|
||||
while [ -f "$TARGET_DIR/$new_name" ]; do
|
||||
((counter++))
|
||||
new_name="${base}_${counter}.${ext}"
|
||||
done
|
||||
|
||||
cp "$file" "$TARGET_DIR/$new_name"
|
||||
echo "复制: $file -> $TARGET_DIR/$new_name (重名文件)"
|
||||
else
|
||||
cp "$file" "$TARGET_DIR/$basename"
|
||||
echo "复制: $file -> $TARGET_DIR/$basename"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "复制完成!"
|
||||
echo "已复制的文件在: $TARGET_DIR"
|
||||
ls -la "$TARGET_DIR"/*.o | wc -l
|
||||
Loading…
x
Reference in New Issue
Block a user