Files
build_infra/Cppcheck/Install.ps1
T
2026-07-28 17:55:29 +08:00

22 lines
602 B
PowerShell

param(
[string]$Version = "",
[switch]$Force
)
$ErrorActionPreference = "Stop"
$arguments = @("install", "--id", "Cppcheck.Cppcheck", "--exact", "--silent", "--accept-package-agreements", "--accept-source-agreements", "--disable-interactivity")
if ($Version) {
$arguments += @("--version", $Version)
}
if ($Force) {
$arguments += "--force"
}
& winget @arguments
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
$cppcheck = "C:\Program Files\Cppcheck\cppcheck.exe"
if (!(Test-Path -LiteralPath $cppcheck)) {
throw "Cppcheck was not installed at $cppcheck"
}
& $cppcheck --version