Files
mandy/tools/conformance/native/scripts/build.ps1
Leeahmy 0506f2f8bb conformance build.ps1: find Visual Studio's CMake and name no Visual Studio version
The script took CMake from PATH or C:/Program Files/CMake only, so it failed on
a Visual Studio Build Tools install, which includes its own. It also always
asked for Visual Studio 2022. Look for CMake as scripts/build_runtime.ps1 does
and leave the generator to CMake.

The CMake lookup was found by evilclanker9000.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 19:34:42 +07:00

50 lines
2.1 KiB
PowerShell

# Builds conform_native. Run from anywhere:
# powershell -NoProfile -ExecutionPolicy Bypass -File tools\conformance\native\scripts\build.ps1
$ErrorActionPreference = 'Stop'
# The CMake Visual Studio includes, then one on PATH that has the Visual Studio generators (MSYS's does not), as in
# scripts\build_runtime.ps1; then the CMake installer's default folder. Empty when there is none.
function Find-CMake([string]$VisualStudio) {
$ErrorActionPreference = 'Continue'
if ($VisualStudio) {
$bundled = Join-Path $VisualStudio 'Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe'
if (Test-Path -LiteralPath $bundled -PathType Leaf) { return $bundled }
}
foreach ($command in @(Get-Command cmake -CommandType Application -All -ErrorAction SilentlyContinue)) {
if ((& $command.Path --help 2>$null) -match 'Visual Studio') { return $command.Path }
}
$installed = Join-Path $env:ProgramFiles 'CMake\bin\cmake.exe'
if (Test-Path -LiteralPath $installed -PathType Leaf) { return $installed }
return ''
}
$root = Split-Path -Parent $PSScriptRoot
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
$vs = ''
if (Test-Path -LiteralPath $vswhere -PathType Leaf) {
$vs = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
}
$cmake = Find-CMake $vs
if (-not $cmake) {
Write-Output "CMake was not found: install Visual Studio's C++ CMake tools or CMake"
exit 1
}
$source = $root
$build = Join-Path $root 'build'
# No -G: CMake takes the newest Visual Studio it knows, so the script names no version. CMAKE_GENERATOR would replace
# that choice, with one that may not take -A.
$generator = $env:CMAKE_GENERATOR
$env:CMAKE_GENERATOR = $null
try {
& $cmake -S $source -B $build -A x64
} finally {
$env:CMAKE_GENERATOR = $generator
}
if ($LASTEXITCODE -ne 0) { Write-Output "CONFIGURE EXIT $LASTEXITCODE"; exit $LASTEXITCODE }
& $cmake --build $build --config Release --parallel
$buildExit = $LASTEXITCODE
Write-Output "BUILD EXIT $buildExit"
exit $buildExit