azahar/build-azahar.ps1
Masamune3210 e59960c518 HTTP: implement streaming ReceiveData, fix GetDownloadSizeState, add cert chain stubs
- ReceiveData now streams body data in chunks via content_receiver + stream_cv
  instead of blocking until the full response body is downloaded; fixes downloads
  of large files that would time out before the body completed
- GetDownloadSizeState returns Content-Length from response headers immediately
  (via response_headers_future) rather than waiting for the progress callback,
  matching real hardware behavior
- GetResponseStatusCode and GetResponseHeader resolve from response_headers_future
  so they return as soon as headers arrive, not after full body download
- CancelConnection implemented: cancel_mutex + cancel_stop_fn set/cleared around
  client->send(); calling stop() aborts any in-flight request
- Cert chain stubs: CreateRootCertChain, DestroyRootCertChain, RootCertChainAddCert,
  RootCertChainAddDefaultCert, RootCertChainRemoveCert, SelectRootCertChain
- Shutdown fix: HTTP_C destructor sets async_shutdown and spin-waits for
  async_pending==0; async lambdas bail early on shutdown to prevent
  use-after-free of freed KernelSystem
- AM: remove redundant encrypted CIA check that blocked legitimate installs
- build-azahar.ps1: deploy now copies per-file with error counting instead of
  Move-Item so locked files (emulator open) produce warnings rather than silent failure

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 15:52:32 -05:00

92 lines
3.4 KiB
PowerShell

# Build script for Azahar
# Uses ninja + MSVC (VS 2026 Community) + VS-bundled cmake
$SourceDir = "$PSScriptRoot"
$BuildDir = "$PSScriptRoot\build"
$VSPath = "D:\Program Files\Microsoft Visual Studio\18\Community"
$MSVCBin = "$VSPath\VC\Tools\MSVC\14.50.35717\bin\Hostx64\x64"
$NinjaPath = "C:\Strawberry\c\bin\ninja.exe"
$CcachePath = "C:\Strawberry\c\bin\ccache.exe"
$CMakePath = "$VSPath\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
$Qt6Dir = "$BuildDir\externals\qt\6.9.3\msvc2022_64\lib\cmake\Qt6"
foreach ($tool in @($NinjaPath, $CMakePath)) {
if (-not (Test-Path $tool)) { Write-Error "Tool not found: $tool"; exit 1 }
}
# Import MSVC environment via VsDevCmd
$VsDevCmd = "$VSPath\Common7\Tools\VsDevCmd.bat"
if (-not (Test-Path $VsDevCmd)) { Write-Error "VsDevCmd.bat not found at: $VsDevCmd"; exit 1 }
$envVars = & "C:\Windows\System32\cmd.exe" /c "`"$VsDevCmd`" -arch=x64 -no_logo && set" 2>&1
foreach ($line in $envVars) {
if ($line -match '^([^=]+)=(.*)$') {
[System.Environment]::SetEnvironmentVariable($Matches[1], $Matches[2], 'Process')
}
}
# Delete stale CMakeCache.txt if it points to a different source directory
$cacheFile = "$BuildDir\CMakeCache.txt"
if (Test-Path $cacheFile) {
$cachedSource = Select-String -Path $cacheFile -Pattern "^CMAKE_HOME_DIRECTORY:INTERNAL=(.+)" |
ForEach-Object { $_.Matches[0].Groups[1].Value.Trim() }
if ($cachedSource -and ($cachedSource -ne $SourceDir.Replace('\','/'))) {
Write-Host "Stale CMakeCache.txt detected (was: $cachedSource), removing..." -ForegroundColor Yellow
Remove-Item $cacheFile -Force
}
}
# Configure cmake
Write-Host "Configuring cmake..." -ForegroundColor Cyan
$cmakeArgs = @(
"-S", $SourceDir,
"-B", $BuildDir,
"-G", "Ninja",
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_MAKE_PROGRAM=$NinjaPath",
"-DCMAKE_C_COMPILER=$MSVCBin\cl.exe",
"-DCMAKE_CXX_COMPILER=$MSVCBin\cl.exe",
"-DQt6_DIR=$Qt6Dir"
)
if (Test-Path $CcachePath) {
$cmakeArgs += "-DCMAKE_C_COMPILER_LAUNCHER=$CcachePath"
$cmakeArgs += "-DCMAKE_CXX_COMPILER_LAUNCHER=$CcachePath"
}
& $CMakePath @cmakeArgs
if ($LASTEXITCODE -ne 0) { Write-Error "cmake configure failed"; exit $LASTEXITCODE }
# Build
$jobs = $args[0]
if (-not $jobs) { $jobs = [Environment]::ProcessorCount }
Write-Host "Building Azahar with $jobs parallel jobs..." -ForegroundColor Cyan
Push-Location $BuildDir
try {
& $NinjaPath -j $jobs citra_meta
if ($LASTEXITCODE -ne 0) {
Write-Host "Build FAILED (exit code $LASTEXITCODE)" -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host "Build succeeded." -ForegroundColor Green
} finally {
Pop-Location
}
# Only reached if build succeeded (failures call exit above)
$ReleaseDir = "$BuildDir\bin\Release"
$DeployDir = "F:\Emulation\Emulators\Azahar"
Write-Host "Deploying $ReleaseDir -> $DeployDir..." -ForegroundColor Cyan
$deployFailed = 0
foreach ($item in Get-ChildItem $ReleaseDir) {
try {
Copy-Item $item.FullName -Destination $DeployDir -Force -ErrorAction Stop
Remove-Item $item.FullName -Recurse -Force -ErrorAction Stop
} catch {
Write-Warning "Failed to deploy $($item.Name): $_"
$deployFailed++
}
}
if ($deployFailed -gt 0) {
Write-Host "Deploy finished with $deployFailed file(s) that could not be replaced (emulator still open?)." -ForegroundColor Yellow
exit 1
}
Write-Host "Deploy complete." -ForegroundColor Green