29 lines
878 B
Bash
Executable File
29 lines
878 B
Bash
Executable File
#!/bin/bash
|
|
# pack_web.sh — 将 test/web_root 前端文件打包成 C 字节数组
|
|
# 用法: ./pack_web.sh
|
|
# 输出: src/system/libweb_server/src/packed_fs.c
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PACK_SRC="$SCRIPT_DIR/tools/pack/pack.c"
|
|
PACK_BIN="/tmp/rtu_pack"
|
|
WEB_ROOT="$SCRIPT_DIR/../test/web_root"
|
|
OUTPUT="$SCRIPT_DIR/../src/system/libweb_server/src/packed_fs.c"
|
|
|
|
# 1. 编译打包工具
|
|
echo "[pack] compiling pack tool..."
|
|
gcc -O2 -o "$PACK_BIN" "$PACK_SRC"
|
|
|
|
# 2. 收集前端文件
|
|
FILES=()
|
|
cd "$WEB_ROOT"
|
|
for f in $(find . -type f \( -name "*.html" -o -name "*.css" -o -name "*.js" \) ! -name "*_old*" | sort); do
|
|
FILES+=("$f")
|
|
done
|
|
echo "[pack] packing ${#FILES[@]} files..."
|
|
for f in "${FILES[@]}"; do echo " $f"; done
|
|
|
|
# 3. 生成 packed_fs.c
|
|
"$PACK_BIN" -s "./" "${FILES[@]}" > "$OUTPUT"
|
|
echo "[pack] done: $OUTPUT ($(wc -c < "$OUTPUT") bytes)"
|