60 lines
2.0 KiB
PowerShell
60 lines
2.0 KiB
PowerShell
param(
|
||
[ValidateSet("msvc")]
|
||
[string]$Toolchain = "msvc",
|
||
[string]$BuildDir = "$PSScriptRoot\..\build-windows",
|
||
[string]$DistDir = "$PSScriptRoot\..\dist-windows"
|
||
)
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
|
||
$ProjectRoot = Resolve-Path "$PSScriptRoot\.."
|
||
$BuildDir = [System.IO.Path]::GetFullPath($BuildDir)
|
||
$DistDir = [System.IO.Path]::GetFullPath($DistDir)
|
||
$PackageName = "chengnan-windows-x86_64"
|
||
$PackageDir = Join-Path $DistDir $PackageName
|
||
$ZipPath = Join-Path $DistDir "$PackageName.zip"
|
||
$HashPath = "$ZipPath.sha256"
|
||
|
||
Write-Host "[package] ProjectRoot: $ProjectRoot"
|
||
Write-Host "[package] BuildDir: $BuildDir"
|
||
Write-Host "[package] DistDir: $DistDir"
|
||
|
||
& "$ProjectRoot\docs\windows\build-windows.ps1" -Toolchain $Toolchain -BuildDir $BuildDir -Deploy
|
||
|
||
$DeployDir = Join-Path $BuildDir "deploy"
|
||
$Exe = Join-Path $DeployDir "chengnan.exe"
|
||
if (!(Test-Path $Exe)) {
|
||
throw "未找到部署后的 Windows 可执行文件:$Exe"
|
||
}
|
||
|
||
if (Test-Path $PackageDir) { Remove-Item -Recurse -Force $PackageDir }
|
||
if (Test-Path $ZipPath) { Remove-Item -Force $ZipPath }
|
||
if (Test-Path $HashPath) { Remove-Item -Force $HashPath }
|
||
New-Item -ItemType Directory -Force -Path $DistDir | Out-Null
|
||
Copy-Item -Recurse -Force $DeployDir $PackageDir
|
||
|
||
$ReadmePath = Join-Path $PackageDir "README.txt"
|
||
@"
|
||
chengnan Windows x86_64 发布包
|
||
|
||
运行方式:
|
||
1. 解压整个目录。
|
||
2. 双击 chengnan.exe 运行。
|
||
|
||
说明:
|
||
- 本目录已包含 Qt 运行时和 OpenCV DLL。
|
||
- 请不要只复制 chengnan.exe,需保留同目录 DLL 和 Qt plugins 子目录。
|
||
"@ | Set-Content -Encoding UTF8 $ReadmePath
|
||
|
||
Compress-Archive -Path (Join-Path $PackageDir "*") -DestinationPath $ZipPath -Force
|
||
|
||
$Hash = Get-FileHash -Algorithm SHA256 $ZipPath
|
||
"$($Hash.Hash.ToLower()) $(Split-Path -Leaf $ZipPath)" | Set-Content -Encoding ASCII $HashPath
|
||
|
||
if (!(Test-Path $ZipPath) -or ((Get-Item $ZipPath).Length -le 0)) {
|
||
throw "发布包生成失败:$ZipPath"
|
||
}
|
||
|
||
Write-Host "[package] 发布包:$ZipPath"
|
||
Write-Host "[package] 校验文件:$HashPath"
|