param([switch]$ConfigureOnly, [switch]$CleanBeforeBuild) $ErrorActionPreference = 'Stop' $p1Repo = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '../..')) $p1Build = Join-Path $p1Repo '.starlet_diag_p1' $p1VS = 'C:\Program Files\Microsoft Visual Studio\18\Community' $p1CMake = Join-Path $p1VS 'Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe' $p1Ninja = Join-Path $p1VS 'Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe' $p1Setup = 'set VSLANG=1033&& call "' + (Join-Path $p1VS 'Common7\Tools\VsDevCmd.bat') + '" -arch=x64 -host_arch=x64 >nul' $p1Configure = $p1Setup + ' && "' + $p1CMake + '" -S "' + $p1Repo + '" -B "' + $p1Build + '" -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM="' + $p1Ninja + '" -DENABLE_QT=OFF -DENABLE_NOGUI=ON -DENABLE_TESTS=ON -DENABLE_VULKAN=OFF -DENABLE_LTO=OFF -DENABLE_LLVM=OFF -DUSE_SYSTEM_LIBS=OFF' cmd.exe /d /s /c $p1Configure if ($LASTEXITCODE) { throw 'P1 configuration failed.' } # CMake can decode French MSVC /showIncludes through the OEM code page even though # cl prints UTF-8 nonbreaking spaces. Then Ninja silently records no header deps. $p1PrefixFixed = $false foreach ($p1Info in Get-ChildItem -LiteralPath (Join-Path $p1Build 'CMakeFiles') -Recurse -File -Filter 'CMake*Compiler.cmake') { $p1Text = [IO.File]::ReadAllText($p1Info.FullName) $p1Corrected = $p1Text.Replace('Remarque : inclusion du fichier : ', 'Remarque' + [char]0xa0 + ': inclusion du fichier' + [char]0xa0 + ': ') if ($p1Corrected -cne $p1Text) { [IO.File]::WriteAllText($p1Info.FullName, $p1Corrected, [Text.UTF8Encoding]::new($false)) $p1PrefixFixed = $true } } if ($p1PrefixFixed) { cmd.exe /d /s /c $p1Configure if ($LASTEXITCODE) { throw 'P1 dependency prefix repair failed.' } } if ($ConfigureOnly) { return } if ($CleanBeforeBuild -and [IO.Path]::GetFullPath($p1Build) -cne [IO.Path]::GetFullPath((Join-Path $p1Repo '.starlet_diag_p1'))) { throw 'Unexpected build target: refusing clean.' } $p1Clean = if ($CleanBeforeBuild) { ' --clean-first' } else { '' } $p1Compile = $p1Setup + ' && "' + $p1CMake + '" --build "' + $p1Build + '"' + $p1Clean + ' --target dolphin-nogui tests TraceProbeP1 -j 6' cmd.exe /d /s /c $p1Compile if ($LASTEXITCODE) { throw 'P1 build failed.' } $p1NetworkTarget = Join-Path $p1Build 'Binaries/Network' if (-not (Test-Path -LiteralPath $p1NetworkTarget)) { $p1NetworkSource = Join-Path $p1Repo '.starlet_msvc2/Binaries/Network' if (-not (Test-Path -LiteralPath $p1NetworkSource)) { throw 'Local libslirp runtime absent; the network probe cannot run.' } New-Item -ItemType Directory -Path $p1NetworkTarget | Out-Null Get-ChildItem -LiteralPath $p1NetworkSource -File | Copy-Item -Destination $p1NetworkTarget } & $p1Ninja -C $p1Build -t deps 'Source/Core/Common/CMakeFiles/common.dir/PerformanceTrace.cpp.obj' | Select-Object -First 8