#!/bin/bash
# waveform_trace 打包脚本 (Linux/macOS)
# 用法: ./build.sh

set -e

echo "========================================"
echo "  waveform_trace 打包脚本"
echo "========================================"

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR/src"

echo ""
echo "[1/4] 安装依赖..."
pip install -r requirements.txt

echo ""
echo "[2/4] 清理旧文件..."
rm -rf build dist *.spec

echo ""
echo "[3/4] PyInstaller 打包..."
pyinstaller --onefile --name waveform_trace --collect-all pyverilog waveform_trace_cli.py

echo ""
echo "[4/4] 复制到 bin 目录..."
mkdir -p ../bin
cp dist/waveform_trace ../bin/

echo ""
echo "========================================"
echo "  打包完成!"
echo "  输出: tools/waveform_trace/bin/waveform_trace"
echo "========================================"
