Files
cavity_LIBS/msvc-deps/cleanup-verify.ps1
T
2026-11-06 14:45:09 +08:00

66 lines
3.5 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.
# ===========================================================================
# 1) 在真实工程里验证 Debug 预设构建 2) 清理临时文件 3) 旧 README 加指路
# ===========================================================================
$ErrorActionPreference = 'Stop'
$root = 'D:\Code\cavity_LIBS_system-master'
# ---- 1. Debug 预设构建 ---------------------------------------------------
$vc = 'C:\Program Files\Microsoft Visual Studio\18\Community\VC\Auxiliary\Build\vcvars64.bat'
$cmakeDir = 'C:\Program Files\Microsoft Visual Studio\18\Community\Common7\IDE\CommonExtensions\Microsoft\CMake'
$env:PATH = "$cmakeDir\CMake\bin;$cmakeDir\Ninja;" + $env:PATH
& cmd /c "`"$vc`" >nul && set" | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') { Set-Item -Path "Env:$($matches[1])" -Value $matches[2] -ErrorAction SilentlyContinue }
}
Push-Location $root
try {
Write-Host '==== cmake --preset msvc-x64-debug ===='
& cmake --preset msvc-x64-debug | Select-Object -Last 12
if ($LASTEXITCODE -ne 0) { throw "configure debug 失败 ($LASTEXITCODE)" }
Write-Host '==== build debug ===='
& cmake --build --preset msvc-x64-debug | Select-Object -Last 3
if ($LASTEXITCODE -ne 0) { throw "build debug 失败 ($LASTEXITCODE)" }
}
finally { Pop-Location }
$exe = Join-Path $root 'out\build\msvc-x64-debug\bin\CavityLIBS.exe'
if (-not (Test-Path $exe)) { throw "没有生成 $exe" }
Write-Host "[ok] Debug 产物: $exe"
# ---- 2. 清理临时文件 -----------------------------------------------------
Remove-Item (Join-Path $root 'msvc-deps\stage') -Recurse -Force -ErrorAction SilentlyContinue
foreach ($f in 'build-qwt.bat','build-qwt-nmake.bat','build-qwt2.bat','build-qwt-release-log.bat',
'build-qwt-nmake.bat','release-build.log','debug-build.log','conf.out','conf.err') {
Remove-Item (Join-Path $root "msvc-deps\$f") -Force -ErrorAction SilentlyContinue
}
Remove-Item (Join-Path $root 'msvc-deps\install.ps1') -Force -ErrorAction SilentlyContinue
Remove-Item (Join-Path $root 'msvc-deps\compat') -Recurse -Force -ErrorAction SilentlyContinue
Write-Host '[ok] 已清理 msvc-deps\stage 与中间脚本'
# ---- 3. 旧 README 顶部加一句指路 ----------------------------------------
$oldReadme = Join-Path $root 'README-构建运行.md'
$text = [System.IO.File]::ReadAllText($oldReadme, [System.Text.Encoding]::UTF8)
if ($text -notmatch 'README-VS2026') {
$marker = "# 构建与运行说明(MinGW 32 / 64 位)`r`n"
$note = @(
"# 构建与运行说明(MinGW 32 / 64 位)",
"",
"> **本机现在请先看 [README-VS2026-构建运行.md](README-VS2026-构建运行.md)。**",
"> 本文的 MinGW 方案需要 `G:` 盘那套 Qt 5.15.2 mingw81_64 + mingw810_64 + qwt + aris_0411,",
"> 本机 `G:` 盘已不存在;现用 Visual Studio 2026 / MSVC 编译,光谱仪走内置兼容桩。",
"#MINIGW_HEADING#"
) -join "`r`n"
$text = $text.Replace($marker, $note).Replace("#MINIGW_HEADING#`r`n", "")
[System.IO.File]::WriteAllText($oldReadme, $text, (New-Object System.Text.UTF8Encoding($false)))
Write-Host '[ok] README-构建运行.md 已加指路说明'
} else {
Write-Host '[skip] README-构建运行.md 已有指路说明'
}
Write-Host ''
Write-Host '==== 最终产物 ===='
foreach ($cfg in 'msvc-x64-debug','msvc-x64-release') {
$p = Join-Path $root "out\build\$cfg\bin\CavityLIBS.exe"
if (Test-Path $p) { Write-Host ("{0,-18} {1,8} KB {2}" -f $cfg, [int]((Get-Item $p).Length/1KB), $p) }
}