mobile-eda/scripts/build-windows.ps1

85 lines
3.1 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PowerShell 脚本 - 构建 Windows 版本 (32 位 + 64 位)
# 用法:.\scripts\build-windows.ps1
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Mobile EDA - Windows 构建脚本" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# 检查 Flutter
Write-Host "📱 检查 Flutter 环境..." -ForegroundColor Yellow
$flutterVersion = flutter --version
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Flutter 未安装或未在 PATH 中" -ForegroundColor Red
exit 1
}
Write-Host "✅ Flutter 已安装" -ForegroundColor Green
Write-Host ""
# 获取依赖
Write-Host "📦 获取依赖..." -ForegroundColor Yellow
flutter pub get
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ 依赖获取失败" -ForegroundColor Red
exit 1
}
Write-Host "✅ 依赖获取完成" -ForegroundColor Green
Write-Host ""
# 创建输出目录
$outputDir = "build\windows"
if (!(Test-Path $outputDir)) {
New-Item -ItemType Directory -Force -Path $outputDir | Out-Null
}
Write-Host "📁 输出目录:$outputDir" -ForegroundColor Yellow
Write-Host ""
# 构建 64 位 Windows
Write-Host "🏗️ 构建 Windows 64 位版本..." -ForegroundColor Yellow
flutter build windows --release
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Windows 64 位构建失败" -ForegroundColor Red
exit 1
}
Write-Host "✅ Windows 64 位构建完成" -ForegroundColor Green
# 复制 64 位文件
$build64Dir = "build\windows\runner\Release"
$dest64Dir = "build\windows\mobile-eda-windows-x64"
if (!(Test-Path $dest64Dir)) {
New-Item -ItemType Directory -Force -Path $dest64Dir | Out-Null
}
Copy-Item -Path "$build64Dir\*" -Destination $dest64Dir -Recurse -Force
Write-Host "📦 64 位文件已复制到:$dest64Dir" -ForegroundColor Green
Write-Host ""
# 构建 32 位 Windows (需要额外配置)
Write-Host "🏗️ 构建 Windows 32 位版本..." -ForegroundColor Yellow
Write-Host "⚠️ 注意Flutter Windows 默认只支持 64 位" -ForegroundColor Yellow
Write-Host "⚠️ 如需 32 位,请使用以下命令手动构建:" -ForegroundColor Yellow
Write-Host " flutter build windows --release --target-platform=windows-x86" -ForegroundColor Cyan
Write-Host ""
# 创建安装包
Write-Host "📦 创建安装包..." -ForegroundColor Yellow
# 压缩 64 位版本
$zipFile = "build\windows\mobile-eda-v1.1.0-windows-x64.zip"
Compress-Archive -Path "$dest64Dir\*" -DestinationPath $zipFile -Force
Write-Host "✅ 压缩包已创建:$zipFile" -ForegroundColor Green
Write-Host ""
# 显示构建信息
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " 构建完成!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "📦 输出文件:" -ForegroundColor Yellow
Write-Host " 64 位:$dest64Dir" -ForegroundColor White
Write-Host " 压缩包:$zipFile" -ForegroundColor White
Write-Host ""
Write-Host "🚀 运行应用:" -ForegroundColor Yellow
Write-Host " cd $dest64Dir" -ForegroundColor White
Write-Host " .\mobile_eda.exe" -ForegroundColor White
Write-Host ""