diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 00000000..d8b1638c --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,143 @@ +# YAZE Build Scripts + +This directory contains build and setup scripts for YAZE development on different platforms. + +## Windows Scripts + +### Setup Scripts +- **`setup-windows-dev.ps1`** - Complete Windows development environment setup (PowerShell) +- **`setup-vcpkg-windows.ps1`** - vcpkg setup only (PowerShell) +- **`setup-vcpkg-windows.bat`** - vcpkg setup only (Batch) + +### Build Scripts +- **`build-windows.ps1`** - Build YAZE on Windows (PowerShell) +- **`build-windows.bat`** - Build YAZE on Windows (Batch) + +### Validation Scripts +- **`validate-windows-build.ps1`** - Validate Windows build environment + +### Project Generation +- **`generate-vs-projects.py`** - Generate Visual Studio project files (Cross-platform Python) +- **`generate-vs-projects.ps1`** - Generate Visual Studio project files (PowerShell) +- **`generate-vs-projects.bat`** - Generate Visual Studio project files (Batch) + +## Quick Start (Windows) + +### Option 1: Automated Setup (Recommended) +```powershell +.\scripts\setup-windows-dev.ps1 +``` + +### Option 2: Manual Setup +```powershell +# 1. Setup vcpkg +.\scripts\setup-vcpkg-windows.ps1 + +# 2. Generate project files +python scripts/generate-vs-projects.py + +# 3. Build +.\scripts\build-windows.ps1 +``` + +### Option 3: Using Batch Scripts +```batch +REM Setup vcpkg +.\scripts\setup-vcpkg-windows.bat + +REM Generate project files +python scripts/generate-vs-projects.py + +REM Build +.\scripts\build-windows.bat +``` + +## Script Options + +### setup-windows-dev.ps1 +- `-SkipVcpkg` - Skip vcpkg setup +- `-SkipVS` - Skip Visual Studio check +- `-SkipBuild` - Skip test build + +### build-windows.ps1 +- `-Configuration` - Build configuration (Debug, Release, RelWithDebInfo, MinSizeRel) +- `-Platform` - Target platform (x64, x86, ARM64) +- `-Clean` - Clean build directories before building +- `-Verbose` - Verbose build output + +### build-windows.bat +- First argument: Configuration (Debug, Release, RelWithDebInfo, MinSizeRel) +- Second argument: Platform (x64, x86, ARM64) +- `clean` - Clean build directories +- `verbose` - Verbose build output + +## Examples + +```powershell +# Build Release x64 (default) +.\scripts\build-windows.ps1 + +# Build Debug x64 +.\scripts\build-windows.ps1 -Configuration Debug -Platform x64 + +# Build Release x86 +.\scripts\build-windows.ps1 -Configuration Release -Platform x86 + +# Clean build +.\scripts\build-windows.ps1 -Clean + +# Verbose build +.\scripts\build-windows.ps1 -Verbose + +# Validate environment +.\scripts\validate-windows-build.ps1 +``` + +```batch +REM Build Release x64 (default) +.\scripts\build-windows.bat + +REM Build Debug x64 +.\scripts\build-windows.bat Debug x64 + +REM Build Release x86 +.\scripts\build-windows.bat Release x86 + +REM Clean build +.\scripts\build-windows.bat clean +``` + +## Troubleshooting + +### Common Issues + +1. **PowerShell Execution Policy** + ```powershell + Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + ``` + +2. **MSBuild Not Found** + - Install Visual Studio 2022 with C++ workload + - Or add MSBuild to PATH + +3. **vcpkg Issues** + - Run `.\scripts\setup-vcpkg-windows.ps1` to reinstall + - Check internet connection for dependency downloads + +4. **Python Not Found** + - Install Python 3.8+ from python.org + - Make sure Python is in PATH + +### Getting Help + +1. Run validation script: `.\scripts\validate-windows-build.ps1` +2. Check the [Windows Development Guide](../docs/windows-development-guide.md) +3. Review build output for specific error messages + +## Other Scripts + +- **`create_release.sh`** - Create GitHub releases (Linux/macOS) +- **`extract_changelog.py`** - Extract changelog for releases +- **`quality_check.sh`** - Code quality checks (Linux/macOS) +- **`test_asar_integration.py`** - Test Asar integration +- **`agent.sh`** - AI agent helper script (Linux/macOS) diff --git a/scripts/build-windows.bat b/scripts/build-windows.bat index f37865f6..db9b7bbd 100644 --- a/scripts/build-windows.bat +++ b/scripts/build-windows.bat @@ -1,9 +1,31 @@ @echo off -REM Simple Windows build script for YAZE -REM This script sets up the environment and builds the project using Visual Studio +REM YAZE Windows Build Script (Batch Version) +REM This script builds the YAZE project on Windows using MSBuild setlocal enabledelayedexpansion +REM Parse command line arguments +set BUILD_CONFIG=Release +set BUILD_PLATFORM=x64 +set CLEAN_BUILD=0 +set VERBOSE=0 + +:parse_args +if "%~1"=="" goto :args_done +if /i "%~1"=="Debug" set BUILD_CONFIG=Debug +if /i "%~1"=="Release" set BUILD_CONFIG=Release +if /i "%~1"=="RelWithDebInfo" set BUILD_CONFIG=RelWithDebInfo +if /i "%~1"=="MinSizeRel" set BUILD_CONFIG=MinSizeRel +if /i "%~1"=="x64" set BUILD_PLATFORM=x64 +if /i "%~1"=="x86" set BUILD_PLATFORM=x86 +if /i "%~1"=="ARM64" set BUILD_PLATFORM=ARM64 +if /i "%~1"=="clean" set CLEAN_BUILD=1 +if /i "%~1"=="verbose" set VERBOSE=1 +shift +goto :parse_args + +:args_done + echo ======================================== echo YAZE Windows Build Script echo ======================================== @@ -17,8 +39,7 @@ if not exist "YAZE.sln" ( echo ✓ YAZE.sln found -REM Check for Visual Studio -echo Checking for Visual Studio... +REM Check for MSBuild where msbuild >nul 2>&1 if %errorlevel% neq 0 ( echo ERROR: MSBuild not found. Please install Visual Studio 2022 or later. @@ -30,24 +51,10 @@ if %errorlevel% neq 0 ( echo ✓ MSBuild found REM Check for vcpkg -echo Checking for vcpkg... if not exist "vcpkg.json" ( - echo ERROR: vcpkg.json not found. Please ensure vcpkg is properly configured. - pause - exit /b 1 + echo WARNING: vcpkg.json not found. vcpkg integration may not work properly. ) -echo ✓ vcpkg.json found - -REM Set up environment variables -echo Setting up build environment... -set BUILD_CONFIG=Release -set BUILD_PLATFORM=x64 - -REM Allow user to override configuration -if "%1" neq "" set BUILD_CONFIG=%1 -if "%2" neq "" set BUILD_PLATFORM=%2 - echo Build Configuration: %BUILD_CONFIG% echo Build Platform: %BUILD_PLATFORM% @@ -57,19 +64,46 @@ if not exist "build" mkdir build if not exist "build\bin" mkdir build\bin if not exist "build\obj" mkdir build\obj +REM Clean build if requested +if %CLEAN_BUILD%==1 ( + echo Cleaning build directories... + if exist "build\bin" rmdir /s /q "build\bin" 2>nul + if exist "build\obj" rmdir /s /q "build\obj" 2>nul + if not exist "build\bin" mkdir build\bin + if not exist "build\obj" mkdir build\obj + echo ✓ Build directories cleaned +) + REM Generate yaze_config.h if it doesn't exist if not exist "yaze_config.h" ( echo Generating yaze_config.h... - copy "src\yaze_config.h.in" "yaze_config.h" >nul - powershell -Command "(Get-Content 'yaze_config.h') -replace '@yaze_VERSION_MAJOR@', '0' -replace '@yaze_VERSION_MINOR@', '3' -replace '@yaze_VERSION_PATCH@', '1' | Set-Content 'yaze_config.h'" - echo ✓ Generated yaze_config.h + if exist "src\yaze_config.h.in" ( + copy "src\yaze_config.h.in" "yaze_config.h" >nul + powershell -Command "(Get-Content 'yaze_config.h') -replace '@yaze_VERSION_MAJOR@', '0' -replace '@yaze_VERSION_MINOR@', '3' -replace '@yaze_VERSION_PATCH@', '1' | Set-Content 'yaze_config.h'" + echo ✓ Generated yaze_config.h + ) else ( + echo WARNING: yaze_config.h.in not found, creating basic config + echo // yaze config file > yaze_config.h + echo #define YAZE_VERSION_MAJOR 0 >> yaze_config.h + echo #define YAZE_VERSION_MINOR 3 >> yaze_config.h + echo #define YAZE_VERSION_PATCH 1 >> yaze_config.h + ) ) REM Build using MSBuild echo Building with MSBuild... -echo Command: msbuild YAZE.sln /p:Configuration=%BUILD_CONFIG% /p:Platform=%BUILD_PLATFORM% /p:VcpkgEnabled=true /p:VcpkgManifestInstall=true /m /verbosity:minimal -msbuild YAZE.sln /p:Configuration=%BUILD_CONFIG% /p:Platform=%BUILD_PLATFORM% /p:VcpkgEnabled=true /p:VcpkgManifestInstall=true /m /verbosity:minimal +set MSBUILD_ARGS=YAZE.sln /p:Configuration=%BUILD_CONFIG% /p:Platform=%BUILD_PLATFORM% /p:VcpkgEnabled=true /p:VcpkgManifestInstall=true /m + +if %VERBOSE%==1 ( + set MSBUILD_ARGS=%MSBUILD_ARGS% /verbosity:detailed +) else ( + set MSBUILD_ARGS=%MSBUILD_ARGS% /verbosity:minimal +) + +echo Command: msbuild %MSBUILD_ARGS% + +msbuild %MSBUILD_ARGS% if %errorlevel% neq 0 ( echo ERROR: Build failed with exit code %errorlevel% @@ -124,6 +158,7 @@ echo To build other configurations: echo %~nx0 Debug x64 echo %~nx0 Release x86 echo %~nx0 RelWithDebInfo ARM64 +echo %~nx0 clean echo. -pause +pause \ No newline at end of file diff --git a/scripts/build-windows.ps1 b/scripts/build-windows.ps1 index df8705a9..36822153 100644 --- a/scripts/build-windows.ps1 +++ b/scripts/build-windows.ps1 @@ -1,81 +1,133 @@ -# PowerShell script to build YAZE on Windows -# This script sets up the environment and builds the project using Visual Studio +# YAZE Windows Build Script +# This script builds the YAZE project on Windows using MSBuild param( [string]$Configuration = "Release", [string]$Platform = "x64", - [switch]$Clean = $false, - [switch]$Verbose = $false + [switch]$Clean, + [switch]$Verbose ) -$ErrorActionPreference = "Stop" +# Set error handling +$ErrorActionPreference = "Continue" -Write-Host "========================================" -ForegroundColor Cyan -Write-Host "YAZE Windows Build Script" -ForegroundColor Cyan -Write-Host "========================================" -ForegroundColor Cyan +# Colors for output +$Colors = @{ + Success = "Green" + Warning = "Yellow" + Error = "Red" + Info = "Cyan" + White = "White" +} + +function Write-Status { + param([string]$Message, [string]$Color = "White") + Write-Host $Message -ForegroundColor $Colors[$Color] +} + +function Test-Command { + param([string]$Command) + try { + $null = Get-Command $Command -ErrorAction Stop + return $true + } catch { + return $false + } +} + +function Get-MSBuildPath { + $vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + if (Test-Path $vsWhere) { + $vsInstall = & $vsWhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath + if ($vsInstall) { + $msbuildPath = Join-Path $vsInstall "MSBuild\Current\Bin\MSBuild.exe" + if (Test-Path $msbuildPath) { + return $msbuildPath + } + } + } + return $null +} + +# Main script +Write-Status "========================================" "Info" +Write-Status "YAZE Windows Build Script" "Info" +Write-Status "========================================" "Info" + +# Validate parameters +$ValidConfigs = @("Debug", "Release", "RelWithDebInfo", "MinSizeRel") +$ValidPlatforms = @("x64", "x86", "ARM64") + +if ($ValidConfigs -notcontains $Configuration) { + Write-Status "ERROR: Invalid configuration '$Configuration'. Valid options: $($ValidConfigs -join ', ')" "Error" + exit 1 +} + +if ($ValidPlatforms -notcontains $Platform) { + Write-Status "ERROR: Invalid platform '$Platform'. Valid options: $($ValidPlatforms -join ', ')" "Error" + exit 1 +} + +Write-Status "Build Configuration: $Configuration" "Warning" +Write-Status "Build Platform: $Platform" "Warning" # Check if we're in the right directory if (-not (Test-Path "YAZE.sln")) { - Write-Error "YAZE.sln not found. Please run this script from the project root directory." + Write-Status "ERROR: YAZE.sln not found. Please run this script from the project root directory." "Error" exit 1 } -Write-Host "✓ YAZE.sln found" -ForegroundColor Green +Write-Status "✓ Found YAZE.sln" "Success" -# Check for Visual Studio -Write-Host "Checking for Visual Studio..." -ForegroundColor Yellow -try { - $msbuildPath = Get-Command msbuild -ErrorAction Stop - Write-Host "✓ MSBuild found at: $($msbuildPath.Source)" -ForegroundColor Green -} catch { - Write-Error "MSBuild not found. Please install Visual Studio 2022 or later with the C++ development workload." +# Check for MSBuild +$msbuildPath = Get-MSBuildPath +if (-not $msbuildPath) { + Write-Status "ERROR: MSBuild not found. Please install Visual Studio 2022 with C++ workload." "Error" exit 1 } +Write-Status "✓ MSBuild found at: $msbuildPath" "Success" + # Check for vcpkg -Write-Host "Checking for vcpkg..." -ForegroundColor Yellow if (-not (Test-Path "vcpkg.json")) { - Write-Error "vcpkg.json not found. Please ensure vcpkg is properly configured." - exit 1 + Write-Status "WARNING: vcpkg.json not found. vcpkg integration may not work properly." "Warning" } -Write-Host "✓ vcpkg.json found" -ForegroundColor Green - -# Display build configuration -Write-Host "Build Configuration: $Configuration" -ForegroundColor Yellow -Write-Host "Build Platform: $Platform" -ForegroundColor Yellow - # Create build directories -Write-Host "Creating build directories..." -ForegroundColor Yellow +Write-Status "Creating build directories..." "Warning" $directories = @("build", "build\bin", "build\obj") foreach ($dir in $directories) { if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null - Write-Host "✓ Created directory: $dir" -ForegroundColor Green + Write-Status "✓ Created directory: $dir" "Success" } } # Clean build if requested if ($Clean) { - Write-Host "Cleaning build directories..." -ForegroundColor Yellow + Write-Status "Cleaning build directories..." "Warning" if (Test-Path "build\bin") { Remove-Item -Recurse -Force "build\bin\*" -ErrorAction SilentlyContinue } if (Test-Path "build\obj") { Remove-Item -Recurse -Force "build\obj\*" -ErrorAction SilentlyContinue } - Write-Host "✓ Build directories cleaned" -ForegroundColor Green + Write-Status "✓ Build directories cleaned" "Success" } # Generate yaze_config.h if it doesn't exist if (-not (Test-Path "yaze_config.h")) { - Write-Host "Generating yaze_config.h..." -ForegroundColor Yellow + Write-Status "Generating yaze_config.h..." "Warning" if (Test-Path "src\yaze_config.h.in") { Copy-Item "src\yaze_config.h.in" "yaze_config.h" - (Get-Content 'yaze_config.h') -replace '@yaze_VERSION_MAJOR@', '0' -replace '@yaze_VERSION_MINOR@', '3' -replace '@yaze_VERSION_PATCH@', '1' | Set-Content 'yaze_config.h' - Write-Host "✓ Generated yaze_config.h" -ForegroundColor Green + $content = Get-Content "yaze_config.h" -Raw + $content = $content -replace '@yaze_VERSION_MAJOR@', '0' + $content = $content -replace '@yaze_VERSION_MINOR@', '3' + $content = $content -replace '@yaze_VERSION_PATCH@', '1' + Set-Content "yaze_config.h" $content + Write-Status "✓ Generated yaze_config.h" "Success" } else { - Write-Warning "yaze_config.h.in not found, creating basic config" + Write-Status "WARNING: yaze_config.h.in not found, creating basic config" "Warning" @" // yaze config file #define YAZE_VERSION_MAJOR 0 @@ -86,7 +138,7 @@ if (-not (Test-Path "yaze_config.h")) { } # Build using MSBuild -Write-Host "Building with MSBuild..." -ForegroundColor Yellow +Write-Status "Building with MSBuild..." "Warning" $msbuildArgs = @( "YAZE.sln" @@ -94,7 +146,7 @@ $msbuildArgs = @( "/p:Platform=$Platform" "/p:VcpkgEnabled=true" "/p:VcpkgManifestInstall=true" - "/m" # Multi-processor build + "/m" ) if ($Verbose) { @@ -103,66 +155,66 @@ if ($Verbose) { $msbuildArgs += "/verbosity:minimal" } -$msbuildCommand = "msbuild $($msbuildArgs -join ' ')" -Write-Host "Command: $msbuildCommand" -ForegroundColor Gray +$msbuildCommand = "& `"$msbuildPath`" $($msbuildArgs -join ' ')" +Write-Status "Command: $msbuildCommand" "Info" try { - & msbuild @msbuildArgs + & $msbuildPath @msbuildArgs if ($LASTEXITCODE -ne 0) { throw "MSBuild failed with exit code $LASTEXITCODE" } - Write-Host "✓ Build completed successfully" -ForegroundColor Green + Write-Status "✓ Build completed successfully" "Success" } catch { - Write-Error "Build failed: $_" + Write-Status "✗ Build failed: $_" "Error" exit 1 } # Verify executable was created $exePath = "build\bin\$Configuration\yaze.exe" if (-not (Test-Path $exePath)) { - Write-Error "Executable not found at expected path: $exePath" + Write-Status "ERROR: Executable not found at expected path: $exePath" "Error" exit 1 } -Write-Host "✓ Executable created: $exePath" -ForegroundColor Green +Write-Status "✓ Executable created: $exePath" "Success" -# Test that the executable runs (basic test) -Write-Host "Testing executable startup..." -ForegroundColor Yellow +# Test that the executable runs +Write-Status "Testing executable..." "Warning" try { $testResult = & $exePath --help 2>&1 $exitCode = $LASTEXITCODE # Check if it's the test main or app main if ($testResult -match "Google Test|gtest") { - Write-Error "Executable is running test main instead of app main!" - Write-Host "Output: $testResult" -ForegroundColor Red + Write-Status "ERROR: Executable is running test main instead of app main!" "Error" + Write-Status "Output: $testResult" "Error" exit 1 } - Write-Host "✓ Executable runs correctly (exit code: $exitCode)" -ForegroundColor Green + Write-Status "✓ Executable runs correctly (exit code: $exitCode)" "Success" } catch { - Write-Warning "Could not test executable: $_" + Write-Status "WARNING: Could not test executable: $_" "Warning" } # Display file info $exeInfo = Get-Item $exePath $fileSizeMB = [math]::Round($exeInfo.Length / 1MB, 2) -Write-Host "Executable size: $fileSizeMB MB" -ForegroundColor Cyan +Write-Status "Executable size: $fileSizeMB MB" "Info" -Write-Host "========================================" -ForegroundColor Cyan -Write-Host "✓ YAZE Windows build completed successfully!" -ForegroundColor Green -Write-Host "========================================" -ForegroundColor Cyan -Write-Host "" -Write-Host "Build Configuration: $Configuration" -ForegroundColor White -Write-Host "Build Platform: $Platform" -ForegroundColor White -Write-Host "Executable: $exePath" -ForegroundColor White -Write-Host "" -Write-Host "To run YAZE:" -ForegroundColor Yellow -Write-Host " $exePath" -ForegroundColor White -Write-Host "" -Write-Host "To build other configurations:" -ForegroundColor Yellow -Write-Host " .\scripts\build-windows.ps1 -Configuration Debug -Platform x64" -ForegroundColor White -Write-Host " .\scripts\build-windows.ps1 -Configuration Release -Platform x86" -ForegroundColor White -Write-Host " .\scripts\build-windows.ps1 -Configuration RelWithDebInfo -Platform ARM64" -ForegroundColor White -Write-Host " .\scripts\build-windows.ps1 -Clean" -ForegroundColor White -Write-Host "" +Write-Status "========================================" "Info" +Write-Status "✓ YAZE Windows build completed successfully!" "Success" +Write-Status "========================================" "Info" +Write-Status "" +Write-Status "Build Configuration: $Configuration" "White" +Write-Status "Build Platform: $Platform" "White" +Write-Status "Executable: $exePath" "White" +Write-Status "" +Write-Status "To run YAZE:" "Warning" +Write-Status " $exePath" "White" +Write-Status "" +Write-Status "To build other configurations:" "Warning" +Write-Status " .\scripts\build-windows.ps1 -Configuration Debug -Platform x64" "White" +Write-Status " .\scripts\build-windows.ps1 -Configuration Release -Platform x86" "White" +Write-Status " .\scripts\build-windows.ps1 -Configuration RelWithDebInfo -Platform ARM64" "White" +Write-Status " .\scripts\build-windows.ps1 -Clean" "White" +Write-Status "" \ No newline at end of file diff --git a/scripts/setup-vcpkg-windows.bat b/scripts/setup-vcpkg-windows.bat index 96c2368c..0874c7dc 100644 --- a/scripts/setup-vcpkg-windows.bat +++ b/scripts/setup-vcpkg-windows.bat @@ -1,68 +1,81 @@ @echo off -echo ======================================== -echo yaze Visual Studio Setup Script -echo ======================================== -echo. +REM YAZE vcpkg Setup Script (Batch Version) +REM This script sets up vcpkg for YAZE development on Windows -REM Check if vcpkg is installed -if not exist "%VCPKG_ROOT%" ( - echo ERROR: VCPKG_ROOT environment variable is not set! - echo Please install vcpkg and set the VCPKG_ROOT environment variable. - echo Example: set VCPKG_ROOT=C:\vcpkg - echo. - echo Download vcpkg from: https://github.com/Microsoft/vcpkg - echo After installation, run: .\vcpkg integrate install +setlocal enabledelayedexpansion + +echo ======================================== +echo YAZE vcpkg Setup Script +echo ======================================== + +REM Check if we're in the right directory +if not exist "vcpkg.json" ( + echo ERROR: vcpkg.json not found. Please run this script from the project root directory. pause exit /b 1 ) -echo VCPKG_ROOT is set to: %VCPKG_ROOT% -echo. +echo ✓ vcpkg.json found -REM Check if vcpkg.exe exists -if not exist "%VCPKG_ROOT%\vcpkg.exe" ( - echo ERROR: vcpkg.exe not found at %VCPKG_ROOT%\vcpkg.exe - echo Please verify your vcpkg installation. +REM Check for Git +where git >nul 2>&1 +if %errorlevel% neq 0 ( + echo ERROR: Git not found. Please install Git for Windows. + echo Download from: https://git-scm.com/download/win pause exit /b 1 ) -echo Installing dependencies via vcpkg... -echo This may take several minutes on first run. -echo. +echo ✓ Git found -REM Install dependencies for x64-windows -echo Installing x64-windows dependencies... -"%VCPKG_ROOT%\vcpkg.exe" install zlib:x64-windows -"%VCPKG_ROOT%\vcpkg.exe" install libpng:x64-windows -"%VCPKG_ROOT%\vcpkg.exe" install sdl2[vulkan]:x64-windows -"%VCPKG_ROOT%\vcpkg.exe" install abseil:x64-windows -"%VCPKG_ROOT%\vcpkg.exe" install gtest:x64-windows +REM Clone vcpkg if needed +if not exist "vcpkg" ( + echo Cloning vcpkg... + git clone https://github.com/Microsoft/vcpkg.git vcpkg + if %errorlevel% neq 0 ( + echo ERROR: Failed to clone vcpkg + pause + exit /b 1 + ) + echo ✓ vcpkg cloned successfully +) else ( + echo ✓ vcpkg directory already exists +) -echo. -echo Installing x86-windows dependencies... -"%VCPKG_ROOT%\vcpkg.exe" install zlib:x86-windows -"%VCPKG_ROOT%\vcpkg.exe" install libpng:x86-windows -"%VCPKG_ROOT%\vcpkg.exe" install sdl2[vulkan]:x86-windows -"%VCPKG_ROOT%\vcpkg.exe" install abseil:x86-windows -"%VCPKG_ROOT%\vcpkg.exe" install gtest:x86-windows +REM Bootstrap vcpkg +if not exist "vcpkg\vcpkg.exe" ( + echo Bootstrapping vcpkg... + cd vcpkg + call bootstrap-vcpkg.bat + if %errorlevel% neq 0 ( + echo ERROR: Failed to bootstrap vcpkg + cd .. + pause + exit /b 1 + ) + cd .. + echo ✓ vcpkg bootstrapped successfully +) else ( + echo ✓ vcpkg already bootstrapped +) -echo. -echo Integrating vcpkg with Visual Studio... -"%VCPKG_ROOT%\vcpkg.exe" integrate install +REM Install dependencies +echo Installing dependencies... +vcpkg\vcpkg.exe install --triplet x64-windows +if %errorlevel% neq 0 ( + echo WARNING: Some dependencies may not have installed correctly +) else ( + echo ✓ Dependencies installed successfully +) -echo. echo ======================================== -echo Setup Complete! +echo ✓ vcpkg setup complete! echo ======================================== echo. -echo You can now: -echo 1. Open yaze.sln in Visual Studio 2022 -echo 2. Select Debug or Release configuration -echo 3. Choose x64 or x86 platform -echo 4. Press F5 to build and run +echo You can now build YAZE using: +echo .\scripts\build-windows.ps1 +echo or +echo .\scripts\build-windows.bat echo. -echo If you have a Zelda 3 ROM file, place it in the project root -echo and name it 'zelda3.sfc' for automatic copying. -echo. -pause + +pause \ No newline at end of file diff --git a/scripts/setup-vcpkg-windows.ps1 b/scripts/setup-vcpkg-windows.ps1 index 2e3084b2..bfb3e2eb 100644 --- a/scripts/setup-vcpkg-windows.ps1 +++ b/scripts/setup-vcpkg-windows.ps1 @@ -1,54 +1,106 @@ -# Setup script for vcpkg on Windows (PowerShell) -# This script helps set up vcpkg for YAZE Windows builds +# YAZE vcpkg Setup Script +# This script sets up vcpkg for YAZE development on Windows -Write-Host "Setting up vcpkg for YAZE Windows builds..." -ForegroundColor Green +param( + [string]$Triplet = "x64-windows" +) -# Check if vcpkg directory exists +# Set error handling +$ErrorActionPreference = "Continue" + +# Colors for output +$Colors = @{ + Success = "Green" + Warning = "Yellow" + Error = "Red" + Info = "Cyan" + White = "White" +} + +function Write-Status { + param([string]$Message, [string]$Color = "White") + Write-Host $Message -ForegroundColor $Colors[$Color] +} + +function Test-Command { + param([string]$Command) + try { + $null = Get-Command $Command -ErrorAction Stop + return $true + } catch { + return $false + } +} + +# Main script +Write-Status "========================================" "Info" +Write-Status "YAZE vcpkg Setup Script" "Info" +Write-Status "========================================" "Info" + +Write-Status "Target triplet: $Triplet" "Warning" + +# Check if we're in the right directory +if (-not (Test-Path "vcpkg.json")) { + Write-Status "ERROR: vcpkg.json not found. Please run this script from the project root directory." "Error" + exit 1 +} + +Write-Status "✓ Found vcpkg.json" "Success" + +# Check for Git +if (-not (Test-Command "git")) { + Write-Status "ERROR: Git not found. Please install Git for Windows." "Error" + Write-Status "Download from: https://git-scm.com/download/win" "Info" + exit 1 +} + +Write-Status "✓ Git found" "Success" + +# Clone vcpkg if needed if (-not (Test-Path "vcpkg")) { - Write-Host "Cloning vcpkg..." -ForegroundColor Yellow - git clone https://github.com/Microsoft/vcpkg.git - if ($LASTEXITCODE -ne 0) { - Write-Host "Error: Failed to clone vcpkg repository" -ForegroundColor Red - Read-Host "Press Enter to continue" + Write-Status "Cloning vcpkg..." "Warning" + & git clone https://github.com/Microsoft/vcpkg.git vcpkg + if ($LASTEXITCODE -eq 0) { + Write-Status "✓ vcpkg cloned successfully" "Success" + } else { + Write-Status "✗ Failed to clone vcpkg" "Error" exit 1 } +} else { + Write-Status "✓ vcpkg directory already exists" "Success" } # Bootstrap vcpkg -Set-Location vcpkg -if (-not (Test-Path "vcpkg.exe")) { - Write-Host "Bootstrapping vcpkg..." -ForegroundColor Yellow +$vcpkgExe = "vcpkg\vcpkg.exe" +if (-not (Test-Path $vcpkgExe)) { + Write-Status "Bootstrapping vcpkg..." "Warning" + Push-Location vcpkg & .\bootstrap-vcpkg.bat - if ($LASTEXITCODE -ne 0) { - Write-Host "Error: Failed to bootstrap vcpkg" -ForegroundColor Red - Read-Host "Press Enter to continue" + if ($LASTEXITCODE -eq 0) { + Write-Status "✓ vcpkg bootstrapped successfully" "Success" + } else { + Write-Status "✗ Failed to bootstrap vcpkg" "Error" + Pop-Location exit 1 } + Pop-Location +} else { + Write-Status "✓ vcpkg already bootstrapped" "Success" } -# Integrate vcpkg with Visual Studio (optional) -Write-Host "Integrating vcpkg with Visual Studio..." -ForegroundColor Yellow -& .\vcpkg.exe integrate install +# Install dependencies +Write-Status "Installing dependencies for triplet: $Triplet" "Warning" +& $vcpkgExe install --triplet $Triplet +if ($LASTEXITCODE -eq 0) { + Write-Status "✓ Dependencies installed successfully" "Success" +} else { + Write-Status "⚠ Some dependencies may not have installed correctly" "Warning" +} -# Set environment variable for this session -$vcpkgRoot = Get-Location -$env:VCPKG_ROOT = $vcpkgRoot.Path -Write-Host "VCPKG_ROOT set to: $($env:VCPKG_ROOT)" -ForegroundColor Green - -Set-Location .. - -Write-Host "" -Write-Host "vcpkg setup complete!" -ForegroundColor Green -Write-Host "" -Write-Host "To use vcpkg with YAZE:" -ForegroundColor Cyan -Write-Host "1. Use the Windows presets in CMakePresets.json:" -ForegroundColor White -Write-Host " - windows-debug (Debug build)" -ForegroundColor Gray -Write-Host " - windows-release (Release build)" -ForegroundColor Gray -Write-Host "" -Write-Host "2. Or set VCPKG_ROOT environment variable:" -ForegroundColor White -Write-Host " `$env:VCPKG_ROOT = `"$vcpkgRoot`"" -ForegroundColor Gray -Write-Host "" -Write-Host "3. Dependencies will be automatically installed via vcpkg manifest mode" -ForegroundColor White -Write-Host "" - -Read-Host "Press Enter to continue" +Write-Status "========================================" "Info" +Write-Status "✓ vcpkg setup complete!" "Success" +Write-Status "========================================" "Info" +Write-Status "" +Write-Status "You can now build YAZE using:" "Warning" +Write-Status " .\scripts\build-windows.ps1" "White" +Write-Status "" \ No newline at end of file diff --git a/scripts/setup-windows-dev.bat b/scripts/setup-windows-dev.bat deleted file mode 100644 index b7cb9dc6..00000000 --- a/scripts/setup-windows-dev.bat +++ /dev/null @@ -1,177 +0,0 @@ -@echo off -REM Setup script for Windows development environment -REM This script installs the necessary tools for YAZE development on Windows - -setlocal enabledelayedexpansion - -set FORCE=false - -REM Parse command line arguments -:parse_args -if "%~1"=="" goto :args_done -if "%~1"=="--force" set FORCE=true -shift -goto :parse_args - -:args_done - -echo Setting up Windows development environment for YAZE... - -REM Check if we're on Windows -if not "%OS%"=="Windows_NT" ( - echo This script is designed for Windows only. - exit /b 1 -) - -REM Check if running as administrator -net session >nul 2>&1 -if errorlevel 1 ( - echo This script requires administrator privileges to install software. - echo Please run Command Prompt as Administrator and try again. - exit /b 1 -) - -REM Install Chocolatey if not present -where choco >nul 2>&1 -if errorlevel 1 ( - echo Installing Chocolatey package manager... - powershell -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" - - REM Refresh environment variables - call refreshenv - - echo Chocolatey installed successfully -) else ( - echo Chocolatey already installed -) - -REM Install required tools -echo. -echo Installing required development tools... - -REM CMake -where cmake >nul 2>&1 -if errorlevel 1 ( - echo Installing CMake... - choco install -y cmake - if errorlevel 1 ( - echo Failed to install CMake - ) else ( - echo CMake installed successfully - ) -) else ( - echo CMake already installed -) - -REM Git -where git >nul 2>&1 -if errorlevel 1 ( - echo Installing Git... - choco install -y git - if errorlevel 1 ( - echo Failed to install Git - ) else ( - echo Git installed successfully - ) -) else ( - echo Git already installed -) - -REM Ninja -where ninja >nul 2>&1 -if errorlevel 1 ( - echo Installing Ninja... - choco install -y ninja - if errorlevel 1 ( - echo Failed to install Ninja - ) else ( - echo Ninja installed successfully - ) -) else ( - echo Ninja already installed -) - -REM Python 3 -where python3 >nul 2>&1 -if errorlevel 1 ( - echo Installing Python 3... - choco install -y python3 - if errorlevel 1 ( - echo Failed to install Python 3 - ) else ( - echo Python 3 installed successfully - ) -) else ( - echo Python 3 already installed -) - -REM Refresh environment variables -call refreshenv - -REM Verify installations -echo. -echo Verifying installations... - -where cmake >nul 2>&1 -if errorlevel 1 ( - echo ✗ CMake not found -) else ( - echo ✓ CMake found -) - -where git >nul 2>&1 -if errorlevel 1 ( - echo ✗ Git not found -) else ( - echo ✓ Git found -) - -where ninja >nul 2>&1 -if errorlevel 1 ( - echo ✗ Ninja not found -) else ( - echo ✓ Ninja found -) - -where python3 >nul 2>&1 -if errorlevel 1 ( - echo ✗ Python 3 not found -) else ( - echo ✓ Python 3 found -) - -REM Check for Visual Studio -echo. -echo Checking for Visual Studio... -where vswhere >nul 2>&1 -if errorlevel 1 ( - if exist "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" ( - set VSWHERE="C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" - ) else ( - echo ✗ vswhere not found - cannot detect Visual Studio - goto :setup_complete - ) -) else ( - set VSWHERE=vswhere -) - -%VSWHERE% -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath >nul 2>&1 -if errorlevel 1 ( - echo ✗ Visual Studio 2022 with C++ workload not found - echo Please install Visual Studio 2022 with the 'Desktop development with C++' workload -) else ( - echo ✓ Visual Studio found -) - -:setup_complete -echo. -echo 🎉 Windows development environment setup complete! -echo. -echo Next steps: -echo 1. Run the Visual Studio project generation script: -echo .\scripts\generate-vs-projects.bat -echo 2. Or use CMake presets: -echo cmake --preset windows-debug -echo 3. Open YAZE.sln in Visual Studio and build - -pause diff --git a/scripts/setup-windows-dev.ps1 b/scripts/setup-windows-dev.ps1 index 8af73200..7044d6ba 100644 --- a/scripts/setup-windows-dev.ps1 +++ b/scripts/setup-windows-dev.ps1 @@ -1,195 +1,193 @@ -# PowerShell script to set up Windows development environment for YAZE -# This script helps developers get started with building YAZE on Windows +# YAZE Windows Development Setup Script +# This script sets up a complete Windows development environment for YAZE param( - [switch]$SkipVcpkg = $false, - [switch]$SkipVS = $false + [switch]$SkipVcpkg, + [switch]$SkipVS, + [switch]$SkipBuild ) -$ErrorActionPreference = "Stop" +# Set error handling +$ErrorActionPreference = "Continue" -Write-Host "========================================" -ForegroundColor Cyan -Write-Host "YAZE Windows Development Setup" -ForegroundColor Cyan -Write-Host "========================================" -ForegroundColor Cyan - -# Check if we're in the right directory -if (-not (Test-Path "YAZE.sln")) { - Write-Error "YAZE.sln not found. Please run this script from the project root directory." - exit 1 +# Colors for output +$Colors = @{ + Success = "Green" + Warning = "Yellow" + Error = "Red" + Info = "Cyan" + White = "White" } -Write-Host "✓ Found YAZE project files" -ForegroundColor Green +function Write-Status { + param([string]$Message, [string]$Color = "White") + Write-Host $Message -ForegroundColor $Colors[$Color] +} -# Check for Visual Studio -if (-not $SkipVS) { - Write-Host "Checking for Visual Studio..." -ForegroundColor Yellow - +function Test-Command { + param([string]$Command) + try { + $null = Get-Command $Command -ErrorAction Stop + return $true + } catch { + return $false + } +} + +function Test-VisualStudio { $vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" if (Test-Path $vsWhere) { $vsInstall = & $vsWhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath if ($vsInstall) { - Write-Host "✓ Visual Studio found at: $vsInstall" -ForegroundColor Green - - # Check for MSBuild $msbuildPath = Join-Path $vsInstall "MSBuild\Current\Bin\MSBuild.exe" if (Test-Path $msbuildPath) { - Write-Host "✓ MSBuild found" -ForegroundColor Green - } else { - Write-Warning "MSBuild not found. Please ensure C++ development workload is installed." + return $true } - } else { - Write-Warning "Visual Studio 2022 with C++ workload not found." - Write-Host "Please install Visual Studio 2022 with the following workloads:" -ForegroundColor Yellow - Write-Host " - Desktop development with C++" -ForegroundColor White - Write-Host " - Game development with C++" -ForegroundColor White } + } + return $false +} + +# Main script +Write-Status "========================================" "Info" +Write-Status "YAZE Windows Development Setup" "Info" +Write-Status "========================================" "Info" + +# Check if we're in the right directory +if (-not (Test-Path "YAZE.sln")) { + Write-Status "ERROR: YAZE.sln not found. Please run this script from the project root directory." "Error" + exit 1 +} + +Write-Status "✓ Found YAZE project files" "Success" + +# Check Visual Studio +if (-not $SkipVS) { + Write-Status "Checking Visual Studio..." "Warning" + if (Test-VisualStudio) { + Write-Status "✓ Visual Studio 2022 with C++ workload found" "Success" } else { - Write-Warning "Visual Studio Installer not found. Please install Visual Studio 2022." + Write-Status "⚠ Visual Studio 2022 with C++ workload not found" "Warning" + Write-Status "Please install Visual Studio 2022 with 'Desktop development with C++' workload" "Info" } } else { - Write-Host "Skipping Visual Studio check" -ForegroundColor Yellow + Write-Status "Skipping Visual Studio check" "Warning" } -# Check for Git -Write-Host "Checking for Git..." -ForegroundColor Yellow -$gitFound = $false -try { - $null = Get-Command git -ErrorAction Stop +# Check Git +Write-Status "Checking Git..." "Warning" +if (Test-Command "git") { $gitVersion = & git --version - Write-Host "✓ Git found: $gitVersion" -ForegroundColor Green - $gitFound = $true -} catch { - Write-Warning "Git not found. Please install Git for Windows." - Write-Host "Download from: https://git-scm.com/download/win" -ForegroundColor Yellow + Write-Status "✓ Git found: $gitVersion" "Success" +} else { + Write-Status "⚠ Git not found" "Warning" + Write-Status "Please install Git for Windows from: https://git-scm.com/download/win" "Info" } -# Check for Python -Write-Host "Checking for Python..." -ForegroundColor Yellow -$pythonFound = $false -try { - $null = Get-Command python -ErrorAction Stop +# Check Python +Write-Status "Checking Python..." "Warning" +if (Test-Command "python") { $pythonVersion = & python --version - Write-Host "✓ Python found: $pythonVersion" -ForegroundColor Green - $pythonFound = $true -} catch { - Write-Warning "Python not found. Please install Python 3.8 or later." - Write-Host "Download from: https://www.python.org/downloads/" -ForegroundColor Yellow + Write-Status "✓ Python found: $pythonVersion" "Success" +} else { + Write-Status "⚠ Python not found" "Warning" + Write-Status "Please install Python 3.8+ from: https://www.python.org/downloads/" "Info" } -# Set up vcpkg +# Setup vcpkg if (-not $SkipVcpkg) { - Write-Host "Setting up vcpkg..." -ForegroundColor Yellow + Write-Status "Setting up vcpkg..." "Warning" + # Clone vcpkg if needed if (-not (Test-Path "vcpkg")) { - Write-Host "Cloning vcpkg..." -ForegroundColor Yellow - if ($gitFound) { - try { - & git clone https://github.com/Microsoft/vcpkg.git vcpkg - if ($LASTEXITCODE -eq 0) { - Write-Host "✓ vcpkg cloned successfully" -ForegroundColor Green - } else { - Write-Error "Failed to clone vcpkg" - exit 1 - } - } catch { - Write-Error "Failed to clone vcpkg: $_" + if (Test-Command "git") { + Write-Status "Cloning vcpkg..." "Warning" + & git clone https://github.com/Microsoft/vcpkg.git vcpkg + if ($LASTEXITCODE -eq 0) { + Write-Status "✓ vcpkg cloned successfully" "Success" + } else { + Write-Status "✗ Failed to clone vcpkg" "Error" exit 1 } } else { - Write-Error "Git is required to clone vcpkg. Please install Git first." + Write-Status "✗ Git is required to clone vcpkg" "Error" exit 1 } } else { - Write-Host "✓ vcpkg directory already exists" -ForegroundColor Green + Write-Status "✓ vcpkg directory already exists" "Success" } # Bootstrap vcpkg $vcpkgExe = "vcpkg\vcpkg.exe" if (-not (Test-Path $vcpkgExe)) { - Write-Host "Bootstrapping vcpkg..." -ForegroundColor Yellow - try { - Push-Location vcpkg - & .\bootstrap-vcpkg.bat - if ($LASTEXITCODE -eq 0) { - Write-Host "✓ vcpkg bootstrapped successfully" -ForegroundColor Green - } else { - Write-Error "Failed to bootstrap vcpkg" - Pop-Location - exit 1 - } + Write-Status "Bootstrapping vcpkg..." "Warning" + Push-Location vcpkg + & .\bootstrap-vcpkg.bat + if ($LASTEXITCODE -eq 0) { + Write-Status "✓ vcpkg bootstrapped successfully" "Success" + } else { + Write-Status "✗ Failed to bootstrap vcpkg" "Error" Pop-Location - } catch { - Pop-Location - Write-Error "Failed to bootstrap vcpkg: $_" exit 1 } + Pop-Location } else { - Write-Host "✓ vcpkg already bootstrapped" -ForegroundColor Green + Write-Status "✓ vcpkg already bootstrapped" "Success" } # Install dependencies - Write-Host "Installing dependencies with vcpkg..." -ForegroundColor Yellow - try { - & $vcpkgExe install --triplet x64-windows - if ($LASTEXITCODE -eq 0) { - Write-Host "✓ Dependencies installed successfully" -ForegroundColor Green - } else { - Write-Warning "Some dependencies may not have installed correctly" - } - } catch { - Write-Warning "Failed to install dependencies: $_" + Write-Status "Installing dependencies..." "Warning" + & $vcpkgExe install --triplet x64-windows + if ($LASTEXITCODE -eq 0) { + Write-Status "✓ Dependencies installed successfully" "Success" + } else { + Write-Status "⚠ Some dependencies may not have installed correctly" "Warning" } } else { - Write-Host "Skipping vcpkg setup" -ForegroundColor Yellow + Write-Status "Skipping vcpkg setup" "Warning" } -# Generate Visual Studio project files -Write-Host "Generating Visual Studio project files..." -ForegroundColor Yellow -if ($pythonFound) { - try { - & python scripts/generate-vs-projects.py - if ($LASTEXITCODE -eq 0) { - Write-Host "✓ Visual Studio project files generated" -ForegroundColor Green - } else { - Write-Warning "Failed to generate project files" - } - } catch { - Write-Warning "Failed to generate project files: $_" - Write-Host "You can manually run: python scripts/generate-vs-projects.py" -ForegroundColor Yellow +# Generate project files +Write-Status "Generating Visual Studio project files..." "Warning" +if (Test-Command "python") { + & python scripts/generate-vs-projects.py + if ($LASTEXITCODE -eq 0) { + Write-Status "✓ Project files generated successfully" "Success" + } else { + Write-Status "⚠ Failed to generate project files" "Warning" } } else { - Write-Warning "Python is required to generate project files. Please install Python first." - Write-Host "You can manually run: python scripts/generate-vs-projects.py" -ForegroundColor Yellow + Write-Status "⚠ Python required to generate project files" "Warning" } # Test build -Write-Host "Testing build..." -ForegroundColor Yellow -if (Test-Path "scripts\build-windows.ps1") { - try { +if (-not $SkipBuild) { + Write-Status "Testing build..." "Warning" + if (Test-Path "scripts\build-windows.ps1") { & .\scripts\build-windows.ps1 -Configuration Release -Platform x64 if ($LASTEXITCODE -eq 0) { - Write-Host "✓ Test build successful" -ForegroundColor Green + Write-Status "✓ Test build successful" "Success" } else { - Write-Warning "Test build failed, but setup is complete" + Write-Status "⚠ Test build failed, but setup is complete" "Warning" } - } catch { - Write-Warning "Test build failed: $_" - Write-Host "You can manually run: .\scripts\build-windows.ps1" -ForegroundColor Yellow + } else { + Write-Status "⚠ Build script not found" "Warning" } } else { - Write-Warning "Build script not found. You can manually build using Visual Studio." + Write-Status "Skipping test build" "Warning" } -Write-Host "========================================" -ForegroundColor Cyan -Write-Host "✓ YAZE Windows development setup complete!" -ForegroundColor Green -Write-Host "========================================" -ForegroundColor Cyan -Write-Host "" -Write-Host "Next steps:" -ForegroundColor Yellow -Write-Host "1. Open YAZE.sln in Visual Studio 2022" -ForegroundColor White -Write-Host "2. Select your desired configuration (Debug/Release) and platform (x64/x86/ARM64)" -ForegroundColor White -Write-Host "3. Build the solution (Ctrl+Shift+B)" -ForegroundColor White -Write-Host "" -Write-Host "Or use the command line:" -ForegroundColor Yellow -Write-Host " .\scripts\build-windows.ps1 -Configuration Release -Platform x64" -ForegroundColor White -Write-Host "" -Write-Host "For more information, see docs/02-build-instructions.md" -ForegroundColor Yellow \ No newline at end of file +# Final instructions +Write-Status "========================================" "Info" +Write-Status "✓ YAZE Windows development setup complete!" "Success" +Write-Status "========================================" "Info" +Write-Status "" +Write-Status "Next steps:" "Warning" +Write-Status "1. Open YAZE.sln in Visual Studio 2022" "White" +Write-Status "2. Select configuration (Debug/Release) and platform (x64/x86/ARM64)" "White" +Write-Status "3. Build the solution (Ctrl+Shift+B)" "White" +Write-Status "" +Write-Status "Or use command line:" "Warning" +Write-Status " .\scripts\build-windows.ps1 -Configuration Release -Platform x64" "White" +Write-Status "" +Write-Status "For more information, see docs/windows-development-guide.md" "Info" \ No newline at end of file diff --git a/scripts/test-cmake-config.ps1 b/scripts/test-cmake-config.ps1 deleted file mode 100644 index 9cd56072..00000000 --- a/scripts/test-cmake-config.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -# Test CMake configuration for YAZE -# This script tests if CMake can configure the project without errors - -param( - [string]$Architecture = "x64", - [switch]$Clean = $false -) - -Write-Host "Testing CMake configuration for YAZE..." -ForegroundColor Green - -# Check if we're on Windows -if ($env:OS -ne "Windows_NT") { - Write-Host "This script is designed for Windows only." -ForegroundColor Red - exit 1 -} - -# Check if CMake is available -$cmakePath = Get-Command cmake -ErrorAction SilentlyContinue -if (-not $cmakePath) { - Write-Host "CMake not found. Please run setup-windows-dev.ps1 first." -ForegroundColor Red - exit 1 -} - -Write-Host "CMake found: $($cmakePath.Source)" -ForegroundColor Green - -# Set up paths -$SourceDir = Split-Path -Parent $PSScriptRoot -$TestBuildDir = Join-Path $SourceDir "build-test" - -Write-Host "Source directory: $SourceDir" -ForegroundColor Cyan -Write-Host "Test build directory: $TestBuildDir" -ForegroundColor Cyan - -# Clean test build directory if requested -if ($Clean -and (Test-Path $TestBuildDir)) { - Write-Host "Cleaning test build directory..." -ForegroundColor Yellow - Remove-Item -Recurse -Force $TestBuildDir -} - -# Create test build directory -if (-not (Test-Path $TestBuildDir)) { - New-Item -ItemType Directory -Path $TestBuildDir | Out-Null -} - -# Test CMake configuration with minimal settings -Write-Host "Testing CMake configuration..." -ForegroundColor Yellow - -$TestArgs = @( - "-B", $TestBuildDir, - "-G", "Visual Studio 17 2022", - "-A", $Architecture, - "-DCMAKE_BUILD_TYPE=Debug", - "-DCMAKE_POLICY_VERSION_MINIMUM=3.5", - "-DCMAKE_POLICY_VERSION_MAXIMUM=3.28", - "-DCMAKE_WARN_DEPRECATED=OFF", - "-DABSL_PROPAGATE_CXX_STD=ON", - "-DTHREADS_PREFER_PTHREAD_FLAG=OFF", - "-DYAZE_BUILD_TESTS=OFF", - "-DYAZE_BUILD_APP=ON", - "-DYAZE_BUILD_LIB=OFF", - "-DYAZE_BUILD_EMU=OFF", - "-DYAZE_BUILD_Z3ED=OFF", - "-DYAZE_ENABLE_ROM_TESTS=OFF", - "-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF", - "-DYAZE_ENABLE_UI_TESTS=OFF", - "-DYAZE_INSTALL_LIB=OFF", - "-DYAZE_MINIMAL_BUILD=ON" -) - -Write-Host "CMake command: cmake $($TestArgs -join ' ') $SourceDir" -ForegroundColor Gray - -& cmake @TestArgs $SourceDir - -if ($LASTEXITCODE -eq 0) { - Write-Host "✅ CMake configuration test PASSED!" -ForegroundColor Green - Write-Host "The project can be configured successfully." -ForegroundColor Green - - # Clean up test build directory - if (Test-Path $TestBuildDir) { - Remove-Item -Recurse -Force $TestBuildDir - Write-Host "Test build directory cleaned up." -ForegroundColor Gray - } - - Write-Host "`nYou can now run the full project generation script:" -ForegroundColor Cyan - Write-Host ".\scripts\generate-vs-projects.ps1" -ForegroundColor White -} else { - Write-Host "❌ CMake configuration test FAILED!" -ForegroundColor Red - Write-Host "Please check the error messages above." -ForegroundColor Red - exit 1 -} diff --git a/scripts/validate-vs-build.ps1 b/scripts/validate-vs-build.ps1 deleted file mode 100644 index 8a97ba87..00000000 --- a/scripts/validate-vs-build.ps1 +++ /dev/null @@ -1,146 +0,0 @@ -# PowerShell script to validate Visual Studio project builds -# This script ensures that the .vcxproj files work correctly with vcpkg - -param( - [Parameter(Mandatory=$false)] - [string]$Configuration = "Debug", - - [Parameter(Mandatory=$false)] - [string]$Platform = "x64", - - [Parameter(Mandatory=$false)] - [switch]$Clean = $false, - - [Parameter(Mandatory=$false)] - [switch]$Verbose = $false -) - -$ErrorActionPreference = "Stop" - -Write-Host "========================================" -ForegroundColor Cyan -Write-Host "YAZE Visual Studio Build Validation" -ForegroundColor Cyan -Write-Host "========================================" -ForegroundColor Cyan -Write-Host "Configuration: $Configuration" -ForegroundColor Yellow -Write-Host "Platform: $Platform" -ForegroundColor Yellow -Write-Host "Clean Build: $Clean" -ForegroundColor Yellow -Write-Host "" - -# Check if we're in the right directory -if (-not (Test-Path "yaze.sln")) { - Write-Error "yaze.sln not found. Please run this script from the project root directory." - exit 1 -} - -# Check if vcpkg is available -if (-not $env:VCPKG_ROOT) { - Write-Error "VCPKG_ROOT environment variable is not set. Please install vcpkg and set the environment variable." - exit 1 -} - -if (-not (Test-Path "$env:VCPKG_ROOT\vcpkg.exe")) { - Write-Error "vcpkg.exe not found at $env:VCPKG_ROOT\vcpkg.exe" - exit 1 -} - -Write-Host "✓ vcpkg found at: $env:VCPKG_ROOT" -ForegroundColor Green - -# Check if required dependencies are installed -Write-Host "Checking vcpkg dependencies..." -ForegroundColor Yellow -$dependencies = @("zlib:$Platform-windows", "libpng:$Platform-windows", "sdl2[vulkan]:$Platform-windows", "abseil:$Platform-windows") - -foreach ($dep in $dependencies) { - $result = & "$env:VCPKG_ROOT\vcpkg.exe" list $dep 2>$null - if ($LASTEXITCODE -ne 0 -or -not $result) { - Write-Host "Installing missing dependency: $dep" -ForegroundColor Yellow - & "$env:VCPKG_ROOT\vcpkg.exe" install $dep - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed to install dependency: $dep" - exit 1 - } - } else { - Write-Host "✓ $dep is installed" -ForegroundColor Green - } -} - -# Clean build if requested -if ($Clean) { - Write-Host "Cleaning previous build..." -ForegroundColor Yellow - if (Test-Path "build") { - Remove-Item -Recurse -Force "build" - } -} - -# Ensure build directory exists -if (-not (Test-Path "build")) { - New-Item -ItemType Directory -Path "build" | Out-Null -} - -# Build using MSBuild -Write-Host "Building with MSBuild..." -ForegroundColor Yellow -$msbuildArgs = @( - "yaze.sln" - "/p:Configuration=$Configuration" - "/p:Platform=$Platform" - "/p:VcpkgEnabled=true" - "/p:VcpkgManifestInstall=true" - "/m" # Multi-processor build -) - -if ($Verbose) { - $msbuildArgs += "/verbosity:detailed" -} - -Write-Host "MSBuild command: msbuild $($msbuildArgs -join ' ')" -ForegroundColor Gray -& msbuild @msbuildArgs - -if ($LASTEXITCODE -ne 0) { - Write-Error "MSBuild failed with exit code $LASTEXITCODE" - exit 1 -} - -Write-Host "✓ Build completed successfully" -ForegroundColor Green - -# Verify executable was created -$exePath = "build\bin\$Configuration\yaze.exe" -if (-not (Test-Path $exePath)) { - Write-Error "Executable not found at expected path: $exePath" - exit 1 -} - -Write-Host "✓ Executable created: $exePath" -ForegroundColor Green - -# Verify assets were copied -$assetsPath = "build\bin\$Configuration\assets" -if (-not (Test-Path $assetsPath)) { - Write-Error "Assets directory not found at expected path: $assetsPath" - exit 1 -} - -Write-Host "✓ Assets copied to: $assetsPath" -ForegroundColor Green - -# Test that the executable runs (basic test) -Write-Host "Testing executable startup..." -ForegroundColor Yellow -$testResult = & $exePath --help 2>&1 -$exitCode = $LASTEXITCODE - -# Check if it's the test main or app main -if ($testResult -match "Google Test" -or $testResult -match "gtest") { - Write-Error "Executable is running test main instead of app main!" - Write-Host "Output: $testResult" -ForegroundColor Red - exit 1 -} - -Write-Host "✓ Executable runs correctly (exit code: $exitCode)" -ForegroundColor Green - -# Display file info -$exeInfo = Get-Item $exePath -Write-Host "" -Write-Host "Build Summary:" -ForegroundColor Cyan -Write-Host " Executable: $($exeInfo.FullName)" -ForegroundColor White -Write-Host " Size: $([math]::Round($exeInfo.Length / 1MB, 2)) MB" -ForegroundColor White -Write-Host " Created: $($exeInfo.CreationTime)" -ForegroundColor White - -Write-Host "" -Write-Host "========================================" -ForegroundColor Cyan -Write-Host "✓ Visual Studio build validation PASSED" -ForegroundColor Green -Write-Host "========================================" -ForegroundColor Cyan diff --git a/scripts/validate-windows-build.ps1 b/scripts/validate-windows-build.ps1 new file mode 100644 index 00000000..69bbc869 --- /dev/null +++ b/scripts/validate-windows-build.ps1 @@ -0,0 +1,132 @@ +# YAZE Windows Build Validation Script +# This script validates that the Windows build environment is properly set up + +# Set error handling +$ErrorActionPreference = "Continue" + +# Colors for output +$Colors = @{ + Success = "Green" + Warning = "Yellow" + Error = "Red" + Info = "Cyan" + White = "White" +} + +function Write-Status { + param([string]$Message, [string]$Color = "White") + Write-Host $Message -ForegroundColor $Colors[$Color] +} + +function Test-Command { + param([string]$Command) + try { + $null = Get-Command $Command -ErrorAction Stop + return $true + } catch { + return $false + } +} + +function Test-VisualStudio { + $vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + if (Test-Path $vsWhere) { + $vsInstall = & $vsWhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath + if ($vsInstall) { + $msbuildPath = Join-Path $vsInstall "MSBuild\Current\Bin\MSBuild.exe" + if (Test-Path $msbuildPath) { + return $true + } + } + } + return $false +} + +# Main script +Write-Status "========================================" "Info" +Write-Status "YAZE Windows Build Validation" "Info" +Write-Status "========================================" "Info" + +$allGood = $true + +# Check if we're in the right directory +if (-not (Test-Path "YAZE.sln")) { + Write-Status "✗ YAZE.sln not found" "Error" + $allGood = $false +} else { + Write-Status "✓ YAZE.sln found" "Success" +} + +# Check for vcpkg.json +if (-not (Test-Path "vcpkg.json")) { + Write-Status "✗ vcpkg.json not found" "Error" + $allGood = $false +} else { + Write-Status "✓ vcpkg.json found" "Success" +} + +# Check for Visual Studio +if (Test-VisualStudio) { + Write-Status "✓ Visual Studio 2022 with C++ workload found" "Success" +} else { + Write-Status "✗ Visual Studio 2022 with C++ workload not found" "Error" + $allGood = $false +} + +# Check for Git +if (Test-Command "git") { + $gitVersion = & git --version + Write-Status "✓ Git found: $gitVersion" "Success" +} else { + Write-Status "✗ Git not found" "Error" + $allGood = $false +} + +# Check for Python +if (Test-Command "python") { + $pythonVersion = & python --version + Write-Status "✓ Python found: $pythonVersion" "Success" +} else { + Write-Status "✗ Python not found" "Error" + $allGood = $false +} + +# Check for vcpkg +if (Test-Path "vcpkg\vcpkg.exe") { + Write-Status "✓ vcpkg found and bootstrapped" "Success" +} else { + Write-Status "✗ vcpkg not found or not bootstrapped" "Error" + $allGood = $false +} + +# Check for generated project files +if (Test-Path "YAZE.vcxproj") { + Write-Status "✓ Visual Studio project file found" "Success" +} else { + Write-Status "✗ Visual Studio project file not found" "Error" + Write-Status " Run: python scripts/generate-vs-projects.py" "Info" + $allGood = $false +} + +# Check for config file +if (Test-Path "yaze_config.h") { + Write-Status "✓ yaze_config.h found" "Success" +} else { + Write-Status "⚠ yaze_config.h not found (will be generated during build)" "Warning" +} + +Write-Status "========================================" "Info" +if ($allGood) { + Write-Status "✓ All checks passed! Build environment is ready." "Success" + Write-Status "" + Write-Status "You can now build YAZE using:" "Warning" + Write-Status " .\scripts\build-windows.ps1" "White" + Write-Status " or" "White" + Write-Status " .\scripts\build-windows.bat" "White" +} else { + Write-Status "✗ Some checks failed. Please fix the issues above." "Error" + Write-Status "" + Write-Status "Run the setup script to fix issues:" "Warning" + Write-Status " .\scripts\setup-windows-dev.ps1" "White" +} +Write-Status "========================================" "Info"