CMake 3.25+, C++20, avertissements stricts, règles de déterminisme (pas de fast-math ni de contraction FMA), sanitizers et clang-tidy optionnels, doctest. Presets Windows/Linux/macOS, scripts build.ps1, build.sh et check.ps1 (pas de CI serveur). README de core, 3d et schema.
61 lines
2.2 KiB
PowerShell
61 lines
2.2 KiB
PowerShell
# SPDX-License-Identifier: MPL-2.0
|
|
#
|
|
# Build local Windows : configure, compile et teste un preset CMake.
|
|
# Utilise MSVC, CMake et Ninja fournis par Visual Studio (pas de runner CI).
|
|
# Messages en ASCII : compatible Windows PowerShell 5.1 sans BOM.
|
|
#
|
|
# .\scripts\build.ps1 # windows-msvc-debug
|
|
# .\scripts\build.ps1 -Preset windows-msvc-asan
|
|
# .\scripts\build.ps1 -Clean -NoTests
|
|
|
|
[CmdletBinding()]
|
|
param(
|
|
[string]$Preset = "windows-msvc-debug",
|
|
[switch]$Clean,
|
|
[switch]$NoTests
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
|
|
function Initialize-VsEnvironment {
|
|
$vswhere = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe"
|
|
if (-not (Test-Path $vswhere)) { throw "vswhere introuvable : Visual Studio n'est pas installe." }
|
|
|
|
$vs = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
|
|
if (-not $vs) { throw "Aucune installation Visual Studio avec les outils C++ x64." }
|
|
|
|
if (-not (Get-Command cl.exe -ErrorAction SilentlyContinue)) {
|
|
Import-Module (Join-Path $vs "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
|
|
Microsoft.VisualStudio.DevShell\Enter-VsDevShell -VsInstallPath $vs -SkipAutomaticLocation `
|
|
-DevCmdArguments "-arch=x64 -host_arch=x64" | Out-Null
|
|
}
|
|
|
|
# CMake et Ninja de Visual Studio en tete du PATH.
|
|
$cmakeExt = Join-Path $vs "Common7\IDE\CommonExtensions\Microsoft\CMake"
|
|
$env:PATH = "$cmakeExt\CMake\bin;$cmakeExt\Ninja;$env:PATH"
|
|
}
|
|
|
|
function Invoke-Step([string]$label, [scriptblock]$cmd) {
|
|
Write-Host "==> $label" -ForegroundColor Cyan
|
|
& $cmd
|
|
if ($LASTEXITCODE -ne 0) { throw "Echec : $label (code $LASTEXITCODE)" }
|
|
}
|
|
|
|
Initialize-VsEnvironment
|
|
Push-Location $root
|
|
try {
|
|
if ($Clean) {
|
|
$dir = Join-Path $root "build\$Preset"
|
|
if (Test-Path $dir) { Remove-Item -Recurse -Force $dir }
|
|
}
|
|
Invoke-Step "configure $Preset" { cmake --preset $Preset }
|
|
Invoke-Step "build $Preset" { cmake --build --preset $Preset }
|
|
if (-not $NoTests) {
|
|
Invoke-Step "test $Preset" { ctest --preset $Preset }
|
|
}
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|