TIAN-LEIDA-JIANCE/quick_windows_package.ps1

248 lines
7.1 KiB
PowerShell
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

# 雷达检测系统 - 快速Windows打包脚本
Write-Host "🚀 快速创建Windows软件包..." -ForegroundColor Green
# 检查是否在正确的目录
if (!(Test-Path "CMakeLists.txt") -or !(Test-Path "src")) {
Write-Host "❌ 请在项目根目录运行此脚本" -ForegroundColor Red
exit 1
}
# 创建简单的软件包
$PACKAGE_DIR = "yushu-radar-windows"
if (Test-Path $PACKAGE_DIR) {
Remove-Item -Recurse -Force $PACKAGE_DIR
}
New-Item -ItemType Directory -Path $PACKAGE_DIR | Out-Null
Write-Host "🔨 检查编译程序..." -ForegroundColor Yellow
# 检查编译结果
$buildPaths = @(
"build\Release\yushu_leida_fixed.exe",
"build\Debug\yushu_leida_fixed.exe",
"cmake-build-debug\yushu_leida_fixed.exe",
"cmake-build-release\yushu_leida_fixed.exe"
)
$executablePath = $null
foreach ($path in $buildPaths) {
if (Test-Path $path) {
$executablePath = $path
break
}
}
if (!$executablePath) {
Write-Host "❌ 未找到编译好的程序文件" -ForegroundColor Red
Write-Host "请先编译程序,可能的位置:" -ForegroundColor Yellow
foreach ($path in $buildPaths) {
Write-Host " - $path" -ForegroundColor Gray
}
exit 1
}
Write-Host "✅ 找到程序文件: $executablePath" -ForegroundColor Green
Write-Host "📦 打包文件..." -ForegroundColor Yellow
# 复制主程序
Copy-Item $executablePath "$PACKAGE_DIR\yushu_leida_fixed.exe"
# 复制配置文件
if (Test-Path "config") {
Copy-Item -Recurse "config" "$PACKAGE_DIR\"
}
# 创建启动脚本
$startScript = @"
@echo off
chcp 65001 >nul
echo 🚀 ...
echo.
REM
if not exist "yushu_leida_fixed.exe" (
echo yushu_leida_fixed.exe
pause
exit /b 1
)
echo 🎯 ...
yushu_leida_fixed.exe
pause
"@
$startScript | Out-File -FilePath "$PACKAGE_DIR\start.bat" -Encoding UTF8
# 创建安装脚本
$installScript = @"
@echo off
chcp 65001 >nul
echo 📦 ...
echo.
echo 🔍 ...
REM Visual C++ Redistributable
echo Visual C++ ...
where vcruntime140.dll >nul 2>&1
if errorlevel 1 (
echo Visual C++ Redistributable
echo Visual C++ Redistributable
)
echo.
set /p choice="(Y/n): "
if /i "%choice%" neq "n" (
echo 🔗 ...
call create_shortcuts.bat
)
echo.
echo 🎉
echo.
echo 📋 使
echo 1. start.bat
echo 2.
echo 3. yushu_leida_fixed.exe
echo.
pause
"@
$installScript | Out-File -FilePath "$PACKAGE_DIR\install.bat" -Encoding UTF8
# 创建快捷方式创建脚本
$shortcutScript = @"
@echo off
chcp 65001 >nul
echo 🔗 ...
set "INSTALL_DIR=%~dp0"
set "DESKTOP=%USERPROFILE%\Desktop"
echo 📁 : %INSTALL_DIR%
REM
echo 🖥 ...
powershell -Command "& {`
`$WshShell = New-Object -comObject WScript.Shell; `
`$Shortcut = `$WshShell.CreateShortcut('%DESKTOP%\.lnk'); `
`$Shortcut.TargetPath = '%INSTALL_DIR%start.bat'; `
`$Shortcut.WorkingDirectory = '%INSTALL_DIR%'; `
`$Shortcut.Description = ''; `
`$Shortcut.Save() `
}"
if exist "%DESKTOP%\.lnk" (
echo : %DESKTOP%\.lnk
) else (
echo
)
echo.
echo 🎉
echo.
echo 📋 使
echo 1. ""
echo 2. start.bat
echo 3. yushu_leida_fixed.exe
echo.
pause
"@
$shortcutScript | Out-File -FilePath "$PACKAGE_DIR\create_shortcuts.bat" -Encoding UTF8
# 创建使用说明
$readme = @"
- Windows
📋
- 3D
-
- (20)
- (100)
-
📦 使
1.
install.bat
2.
start.bat
3.
-
- COM
- Visual C++ Redistributable
🔗
- : ""
- : create_shortcuts.bat
📁
- yushu_leida_fixed.exe:
- config/:
- start.bat:
- install.bat:
- create_shortcuts.bat:
🔧
config/config.yaml
- port: (WindowsCOM1, COM2)
- occlusion_detection.alert_distance: ( 0.20m)
- slope_detection.crack_threshold: ( 100.0m)
1. COM
2. Visual C++ Redistributable
3. DLL
4.
- Windows 10/11 (64)
- Visual C++ Redistributable 2019
- 4GB
- OpenGL
1.0.0
"@
$readme | Out-File -FilePath "$PACKAGE_DIR\README.txt" -Encoding UTF8
# 创建压缩包
Write-Host "🗜️ 创建压缩包..." -ForegroundColor Yellow
if (Get-Command Compress-Archive -ErrorAction SilentlyContinue) {
Compress-Archive -Path $PACKAGE_DIR -DestinationPath "yushu-radar-windows.zip" -Force
Write-Host "✅ 压缩包创建成功: yushu-radar-windows.zip" -ForegroundColor Green
} else {
Write-Host "⚠️ PowerShell版本较旧无法自动创建压缩包" -ForegroundColor Yellow
Write-Host "请手动将 $PACKAGE_DIR 文件夹压缩为zip文件" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "🎉 Windows软件包创建完成" -ForegroundColor Green
Write-Host ""
Write-Host "📁 软件包目录: $PACKAGE_DIR\" -ForegroundColor Cyan
Write-Host "📦 压缩包: yushu-radar-windows.zip" -ForegroundColor Cyan
Write-Host ""
Write-Host "🔗 新增功能:" -ForegroundColor Yellow
Write-Host "✅ Windows批处理脚本" -ForegroundColor Green
Write-Host "✅ 桌面快捷方式支持" -ForegroundColor Green
Write-Host "✅ 自动环境检查" -ForegroundColor Green
Write-Host "✅ 中文界面支持" -ForegroundColor Green
Write-Host ""
Write-Host "📋 分发方法:" -ForegroundColor Yellow
Write-Host "1. 直接使用目录: 进入 $PACKAGE_DIR 运行 install.bat" -ForegroundColor White
Write-Host "2. 分发压缩包: 解压后运行 install.bat" -ForegroundColor White
Write-Host ""
Write-Host "✅ 用户只需要:" -ForegroundColor Yellow
Write-Host " 1. 解压 yushu-radar-windows.zip" -ForegroundColor White
Write-Host " 2. 进入 yushu-radar-windows 文件夹" -ForegroundColor White
Write-Host " 3. 双击 install.bat" -ForegroundColor White
Write-Host " 4. 双击 start.bat 或桌面快捷方式启动程序" -ForegroundColor White
Write-Host ""