mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-06 02:33:44 -04:00
add build script
This commit is contained in:
parent
4edda3eb6b
commit
78e6aef690
1 changed files with 72 additions and 0 deletions
72
build-azahar.ps1
Normal file
72
build-azahar.ps1
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# 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
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue