Initial project
This commit is contained in:
48
scripts/build_windows.sh
Normal file
48
scripts/build_windows.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
# Windows Release 打包脚本
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/build_windows.sh # 使用默认 config(dev 配置)
|
||||
# bash scripts/build_windows.sh prod # 写入 prod 配置后打包(CI 使用)
|
||||
#
|
||||
# Via melos:
|
||||
# melos run build:windows
|
||||
#
|
||||
# 产物路径:
|
||||
# EXE → apps/im_app/build/windows/x64/runner/Release/
|
||||
# 符号表 → apps/im_app/build/debug-info/windows/
|
||||
#
|
||||
# 注意:需在 Windows 环境下运行(或 Windows CI Runner)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
APP_DIR="$ROOT_DIR/apps/im_app"
|
||||
CONFIG_FILE="$APP_DIR/config/config.json"
|
||||
DEBUG_INFO_DIR="$APP_DIR/build/debug-info/windows"
|
||||
|
||||
# ── 可选:写入 prod 配置 ────────────────────────────────────────────────────
|
||||
if [ "${1:-}" = "prod" ]; then
|
||||
echo "==> Writing prod config..."
|
||||
cat > "$CONFIG_FILE" <<EOF
|
||||
{
|
||||
"IS_DEV": false,
|
||||
"API_BASE_URL": "${PROD_API_BASE_URL:?PROD_API_BASE_URL is not set}"
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
|
||||
# ── 打包 ────────────────────────────────────────────────────────────────────
|
||||
echo "==> Building Windows release..."
|
||||
cd "$APP_DIR"
|
||||
|
||||
flutter build windows \
|
||||
--release \
|
||||
--dart-define-from-file=config/config.json \
|
||||
--split-debug-info="$DEBUG_INFO_DIR" \
|
||||
--obfuscate
|
||||
|
||||
echo ""
|
||||
echo "✓ EXE: $APP_DIR/build/windows/x64/runner/Release/"
|
||||
echo "✓ 符号表: $DEBUG_INFO_DIR(请妥善保存,用于线上崩溃堆栈还原)"
|
||||
Reference in New Issue
Block a user