From 4df97fb8125649df49e9110111d02362352ae35f Mon Sep 17 00:00:00 2001 From: scawful Date: Wed, 1 Oct 2025 09:48:05 -0400 Subject: [PATCH] Refactor Windows build instructions and remove legacy scripts - Updated `02-build-instructions.md` to enhance clarity and organization, including renaming sections for better understanding. - Removed outdated automated setup scripts (`build-windows.bat`, `build-windows.ps1`, `setup-windows-dev.ps1`, and `validate-windows-build.ps1`) to streamline the build process. - Introduced optional vcpkg setup for SDL2 dependency management, emphasizing the use of bundled dependencies by default. - Improved documentation for Visual Studio CMake workflow, highlighting the recommended approach for building the project. - Consolidated and clarified command line build instructions, ensuring a more straightforward setup experience for developers. --- docs/02-build-instructions.md | 204 +++++++------------------- scripts/README.md | 203 ++++++++------------------ scripts/build-windows.bat | 164 --------------------- scripts/build-windows.ps1 | 220 ----------------------------- scripts/setup-windows-dev.ps1 | 219 ---------------------------- scripts/validate-windows-build.ps1 | 132 ----------------- 6 files changed, 105 insertions(+), 1037 deletions(-) delete mode 100644 scripts/build-windows.bat delete mode 100644 scripts/build-windows.ps1 delete mode 100644 scripts/setup-windows-dev.ps1 delete mode 100644 scripts/validate-windows-build.ps1 diff --git a/docs/02-build-instructions.md b/docs/02-build-instructions.md index f10be410..7ba1e0d4 100644 --- a/docs/02-build-instructions.md +++ b/docs/02-build-instructions.md @@ -16,11 +16,8 @@ cmake -B build -DCMAKE_BUILD_TYPE=Debug cmake --build build ``` -### Windows (Recommended - CMake Mode) +### Windows (Visual Studio CMake Workflow) ```powershell -# Automated setup (first time only) -.\scripts\setup-windows-dev.ps1 - # Recommended: Use Visual Studio's built-in CMake support # 1. Open Visual Studio 2022 # 2. Select "Open a local folder" @@ -32,9 +29,6 @@ cmake --build build # Alternative: Command line build cmake -B build -DCMAKE_BUILD_TYPE=Debug cmake --build build --config Debug - -# Legacy: Generate Visual Studio solution (not recommended) -# python scripts/generate-vs-projects.py # Less maintainable, use CMake mode instead ``` ### Minimal Build (CI/Fast) @@ -75,92 +69,34 @@ sudo apt-get install -y build-essential cmake ninja-build pkg-config \ ### Windows -#### Automated Setup (Recommended) -The project includes comprehensive setup scripts for Windows development: +#### Requirements +- Visual Studio 2022 with "Desktop development with C++" workload +- CMake 3.16+ (included with Visual Studio) +- Git (for cloning and submodules) + +#### Optional: vcpkg for SDL2 +The project uses bundled dependencies by default. Optionally, you can use vcpkg for SDL2: ```powershell -# Complete development environment setup -.\scripts\setup-windows-dev.ps1 - -# Generate Visual Studio project files (with proper vcpkg integration) -python scripts/generate-vs-projects.py - -# Test CMake configuration -.\scripts\test-cmake-config.ps1 +# Setup vcpkg (optional) +.\scripts\setup-vcpkg-windows.ps1 ``` -**What the setup script installs:** -- Chocolatey package manager -- CMake 3.16+ -- Git, Ninja, Python 3 -- Visual Studio 2022 detection and verification +#### vcpkg Integration (Optional) -#### Manual Setup Options - -**Option 1 - Minimal (CI/Fast Builds):** -- Visual Studio 2019+ with C++ CMake tools -- No additional dependencies needed (all bundled) - -**Option 2 - Full Development with vcpkg:** -- Visual Studio 2019+ with C++ CMake tools -- vcpkg package manager for dependency management - -#### vcpkg Integration - -**Automatic Setup:** +**Setup vcpkg for SDL2:** ```powershell # PowerShell -.\scripts\setup-windows-dev.ps1 +.\scripts\setup-vcpkg-windows.ps1 # Command Prompt -scripts\setup-windows-dev.bat -``` - -**Manual vcpkg Setup:** -```cmd -git clone https://github.com/Microsoft/vcpkg.git -cd vcpkg -.\bootstrap-vcpkg.bat -.\vcpkg.exe integrate install -set VCPKG_ROOT=%CD% +.\scripts\setup-vcpkg-windows.bat ``` **Dependencies (vcpkg.json):** -- sdl2 (graphics/input with Vulkan support) +- sdl2 (graphics/input) - optional, bundled version available -**Note**: Abseil and gtest are built from source via CMake rather than through vcpkg to avoid compatibility issues. - -#### Windows Build Commands - -**Using CMake Presets:** -```cmd -# Debug build (minimal, no tests) -cmake --preset windows-debug -cmake --build build --preset windows-debug - -# Development build (includes Google Test) -cmake --preset windows-dev -cmake --build build --preset windows-dev - -# Release build (optimized, no tests) -cmake --preset windows-release -cmake --build build --preset windows-release -``` - -**Using Visual Studio Projects:** -```powershell -# Generate project files (with proper vcpkg integration) -python scripts/generate-vs-projects.py - -# Open YAZE.sln in Visual Studio -# Select configuration (Debug/Release) and platform (x64/x86/ARM64) -# Press F5 to build and run -``` - -**Build Types:** -- **windows-debug**: Minimal debug build, no Google Test -- **windows-dev**: Development build with Google Test and ROM testing -- **windows-release**: Optimized release build, no Google Test +**Note**: All other dependencies (Abseil, GoogleTest, ImGui, Asar) are built from source via CMake for better compatibility. ## Build Targets @@ -321,43 +257,27 @@ The test system supports Google Test filters for selective execution: ## IDE Integration ### Visual Studio (Windows) -**Recommended approach - CMake Mode:** -```powershell -# Setup development environment -.\scripts\setup-windows-dev.ps1 - -# Open in Visual Studio 2022 -# 1. File → Open → Folder -# 2. Navigate to yaze directory -# 3. Visual Studio detects CMakeLists.txt automatically -# 4. Select configuration from toolbar (Debug/Release) -# 5. Press F5 to build and run -``` +**CMake Workflow (Recommended):** +1. **File → Open → Folder** +2. Navigate to yaze directory +3. Visual Studio detects `CMakeLists.txt` automatically +4. Select configuration from toolbar (Debug/Release) +5. Press F5 to build and run **Why CMake Mode?** -- ✅ **No project generation step** - CMake files are the source of truth +- ✅ **No project generation** - CMake files are the source of truth - ✅ **Always in sync** - Changes to CMakeLists.txt reflect immediately - ✅ **Better IntelliSense** - Direct CMake target understanding - ✅ **Native CMake support** - Modern Visual Studio feature -- ✅ **Simpler workflow** - One less build step to maintain -- ✅ **Cross-platform consistency** - Same CMake workflow on all platforms +- ✅ **Cross-platform consistency** - Same workflow on all platforms **Features:** -- Full IntelliSense support (better than generated projects) -- Integrated debugging with breakpoint support -- Automatic vcpkg dependency management (SDL2) -- Multi-platform support (x64, ARM64) -- Automatic asset copying via CMake post-build commands +- Full IntelliSense support +- Integrated debugging with breakpoints +- Automatic vcpkg dependency management (if configured) +- Multi-architecture support (x64, x86, ARM64) - CMakeSettings.json for custom configurations -**Legacy Solution Generation (Not Recommended):** -If you must use a .sln file (e.g., for CI integration): -```powershell -python scripts/generate-vs-projects.py -# Open generated YAZE.sln -``` -Note: This approach requires regeneration when CMakeLists.txt changes and is less maintainable. - ### VS Code 1. Install CMake Tools extension 2. Open project, select "Debug" preset @@ -375,42 +295,17 @@ open build/yaze.xcodeproj ## Windows Development Scripts -The project includes several PowerShell and Batch scripts to streamline Windows development: - -### Setup Scripts -- **`setup-windows-dev.ps1`**: Complete development environment setup -- **`setup-windows-dev.bat`**: Batch version of setup script - -**What they install:** -- Chocolatey package manager -- CMake 3.16+ -- Git, Ninja, Python 3 -- Visual Studio 2022 detection - -### Project Generation Scripts -- **`generate-vs-projects.py`**: Generate Visual Studio project files with proper vcpkg integration -- **`generate-vs-projects.bat`**: Batch version of project generation - -**Features:** -- Automatic CMake detection and installation -- Visual Studio 2022 detection -- Multi-architecture support (x64, ARM64) -- vcpkg integration -- CMake compatibility fixes - -### Testing Scripts -- **`test-cmake-config.ps1`**: Test CMake configuration without full build +### vcpkg Setup (Optional) +- **`setup-vcpkg-windows.ps1`**: Setup vcpkg for SDL2 dependency +- **`setup-vcpkg-windows.bat`**: Batch version of vcpkg setup **Usage:** ```powershell -# Test configuration -.\scripts\test-cmake-config.ps1 +# Setup vcpkg (optional - for SDL2 via vcpkg instead of bundled) +.\scripts\setup-vcpkg-windows.ps1 -# Test with specific architecture -.\scripts\test-cmake-config.ps1 -Architecture x86 - -# Clean test build -.\scripts\test-cmake-config.ps1 -Clean +# Or using batch +.\scripts\setup-vcpkg-windows.bat ``` ## Features by Build Type @@ -523,14 +418,14 @@ Remove-Item -Recurse -Force build cmake -B build -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_WARN_DEPRECATED=OFF ``` -**Visual Studio Project Issues:** +**Visual Studio CMake Issues:** ```powershell -# Regenerate project files -.\scripts\generate-vs-projects.ps1 - -# Clean and rebuild +# Clean CMake cache Remove-Item -Recurse -Force build -cmake --preset windows-debug + +# Rebuild CMake configuration +cmake -B build -DCMAKE_BUILD_TYPE=Debug +cmake --build build --config Debug ``` ### vcpkg Issues @@ -562,13 +457,13 @@ cd C:\vcpkg .\vcpkg.exe integrate install ``` -**ZLIB or Other Dependencies Not Found:** -```bash -# Regenerate project files with proper vcpkg integration -python scripts/generate-vs-projects.py +**Dependencies Not Found:** +```powershell +# Ensure vcpkg is properly set up (if using vcpkg) +.\scripts\setup-vcpkg-windows.ps1 -# Ensure vcpkg is properly set up -.\scripts\setup-windows-dev.ps1 +# Or use bundled dependencies (default) +cmake -B build -DCMAKE_BUILD_TYPE=Debug ``` ### Test Issues @@ -634,8 +529,9 @@ cmake --build build - Ensures proper C++ standard handling **Visual Studio "file not found" errors:** -- Run `python scripts/generate-vs-projects.py` to regenerate project files -- Ensure CMake configuration completed successfully first +- Close and reopen the folder in Visual Studio +- Delete the `build/` directory and let Visual Studio regenerate CMake cache +- Ensure all git submodules are initialized: `git submodule update --init --recursive` **CI/CD Build Failures:** - Check if vcpkg download failed (network issues) diff --git a/scripts/README.md b/scripts/README.md index 258c5cc1..ebb02cbc 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -4,151 +4,65 @@ This directory contains build and setup scripts for YAZE development on differen ## 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) +### vcpkg Setup (Optional) +- **`setup-vcpkg-windows.ps1`** - Setup vcpkg for SDL2 dependency (PowerShell) +- **`setup-vcpkg-windows.bat`** - Setup vcpkg for SDL2 dependency (Batch) -### Build Scripts -- **`build-windows.ps1`** - Build YAZE on Windows (PowerShell) -- **`build-windows.bat`** - Build YAZE on Windows (Batch) +**Note**: vcpkg is optional. YAZE uses bundled dependencies by default. -### Validation Scripts -- **`validate-windows-build.ps1`** - Validate Windows build environment +## Windows Build Workflow -### Project Generation -- **`generate-vs-projects.py`** - Generate Visual Studio project files (Cross-platform Python) +### Recommended: Visual Studio CMake Mode -## Windows Compiler Recommendations +**YAZE uses Visual Studio's native CMake support - no project generation needed.** -### ⚠️ Important: MSVC vs Clang on Windows +1. **Install Visual Studio 2022** with "Desktop development with C++" workload +2. **Open Visual Studio 2022** +3. **File → Open → Folder** +4. **Navigate to yaze directory** +5. **Select configuration** (Debug/Release) from toolbar +6. **Press F5** to build and run -**We strongly recommend using Clang on Windows** due to compatibility issues with MSVC and Abseil's int128 and type_traits features: +### Command Line Build -#### Why Clang is Recommended: -- ✅ **Better C++23 Support**: Full support for modern C++23 features -- ✅ **Abseil Compatibility**: No issues with `absl::int128` and type traits -- ✅ **Cross-Platform Consistency**: Same compiler across all platforms -- ✅ **Better Error Messages**: More helpful diagnostic messages -- ✅ **Faster Compilation**: Generally faster than MSVC - -#### MSVC Issues: -- ❌ **C++23 Deprecation Warnings**: Abseil int128 triggers numerous deprecation warnings -- ❌ **Type Traits Problems**: Some Abseil type traits don't work correctly with MSVC -- ❌ **Int128 Limitations**: MSVC's int128 support is incomplete -- ❌ **Build Complexity**: Requires additional workarounds and flags - -### Compiler Setup Options - -#### Option 1: Clang (Recommended) ```powershell -# Install LLVM/Clang via winget -winget install LLVM.LLVM +# Standard CMake workflow +cmake -B build -DCMAKE_BUILD_TYPE=Debug +cmake --build build --config Debug -# Or download from: https://releases.llvm.org/ -# Make sure to add Clang to PATH during installation - -# Verify installation -clang --version +# Run the application +.\build\bin\Debug\yaze.exe ``` -#### Option 2: MSVC with Workarounds -If you must use MSVC, the build system includes workarounds: -- Abseil int128 is automatically disabled on Windows -- C++23 deprecation warnings are silenced -- Additional compatibility flags are applied +### Compiler Notes -However, you may still encounter issues with some Abseil features. +The CMake configuration is designed to work with **MSVC** (Visual Studio's compiler). The build system includes automatic workarounds for C++23 compatibility: +- Abseil int128 is automatically excluded on Windows +- C++23 deprecation warnings are properly silenced +- Platform-specific definitions are handled automatically ## Quick Start (Windows) -### Option 1: Automated Setup (Recommended) +### Option 1: Visual Studio (Recommended) +1. Open Visual Studio 2022 +2. File → Open → Folder +3. Navigate to yaze directory +4. Select configuration (Debug/Release) +5. Press F5 to build and run + +### Option 2: Command Line ```powershell -.\scripts\setup-windows-dev.ps1 +# Standard CMake build +cmake -B build -DCMAKE_BUILD_TYPE=Debug +cmake --build build --config Debug ``` -### Option 2: Manual Setup +### Option 3: With vcpkg (Optional) ```powershell -# 1. Setup vcpkg +# Setup vcpkg for SDL2 .\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) -- `-Compiler` - Compiler to use (clang, msvc, auto) -- `-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) -- Third argument: Compiler (clang, msvc, auto) -- `clean` - Clean build directories -- `verbose` - Verbose build output - -## Examples - -```powershell -# Build Release x64 with Clang (recommended) -.\scripts\build-windows.ps1 -Compiler clang - -# Build Release x64 with MSVC (with workarounds) -.\scripts\build-windows.ps1 -Compiler msvc - -# Build Debug x64 with Clang -.\scripts\build-windows.ps1 -Configuration Debug -Platform x64 -Compiler clang - -# Build Release x86 with auto-detection -.\scripts\build-windows.ps1 -Configuration Release -Platform x86 -Compiler auto - -# Clean build with Clang -.\scripts\build-windows.ps1 -Clean -Compiler clang - -# Verbose build with MSVC -.\scripts\build-windows.ps1 -Verbose -Compiler msvc - -# Validate environment -.\scripts\validate-windows-build.ps1 -``` - -```batch -REM Build Release x64 with Clang (recommended) -.\scripts\build-windows.bat Release x64 clang - -REM Build Debug x64 with MSVC -.\scripts\build-windows.bat Debug x64 msvc - -REM Build Release x86 with auto-detection -.\scripts\build-windows.bat Release x86 auto - -REM Clean build with Clang -.\scripts\build-windows.bat clean clang +# Then build normally in Visual Studio or command line ``` ## Troubleshooting @@ -160,38 +74,31 @@ REM Clean build with Clang Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser ``` -2. **MSBuild Not Found** - - Install Visual Studio 2022 with C++ workload - - Or add MSBuild to PATH +2. **Visual Studio Not Detecting CMakeLists.txt** + - Ensure you opened the folder (not a solution file) + - Check that CMakeLists.txt exists in the root directory + - Try: File → Close Folder, then File → Open → Folder -3. **vcpkg Issues** +3. **vcpkg Issues (if using vcpkg)** - Run `.\scripts\setup-vcpkg-windows.ps1` to reinstall - Check internet connection for dependency downloads + - Note: vcpkg is optional; bundled dependencies work by default -4. **Python Not Found** - - Install Python 3.8+ from python.org - - Make sure Python is in PATH +4. **CMake Configuration Errors** + - Delete the `build/` directory + - Close and reopen the folder in Visual Studio + - Or run: `cmake -B build -DCMAKE_BUILD_TYPE=Debug` -5. **MSVC Compilation Errors** - - **Abseil int128 errors**: Use Clang instead (`-Compiler clang`) - - **C++23 deprecation warnings**: These are silenced automatically, but Clang is cleaner - - **Type traits issues**: Switch to Clang for better compatibility - - **Solution**: Install Clang and use `.\scripts\build-windows.ps1 -Compiler clang` - -6. **Clang Not Found** - - Install LLVM/Clang: `winget install LLVM.LLVM` - - Or download from: https://releases.llvm.org/ - - Make sure Clang is in PATH: `clang --version` - -7. **Compiler Detection Issues** - - Use explicit compiler selection: `-Compiler clang` or `-Compiler msvc` - - Check available compilers: `where clang` and `where cl` +5. **Missing Git Submodules** + ```powershell + git submodule update --init --recursive + ``` ### 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 +1. Check the [Build Instructions](../docs/02-build-instructions.md) +2. Review CMake output for specific error messages +3. Ensure all prerequisites are installed (Visual Studio 2022 with C++ workload) ## Other Scripts diff --git a/scripts/build-windows.bat b/scripts/build-windows.bat deleted file mode 100644 index db9b7bbd..00000000 --- a/scripts/build-windows.bat +++ /dev/null @@ -1,164 +0,0 @@ -@echo off -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 ======================================== - -REM Check if we're in the right directory -if not exist "YAZE.sln" ( - echo ERROR: YAZE.sln not found. Please run this script from the project root directory. - pause - exit /b 1 -) - -echo ✓ YAZE.sln found - -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. - echo Make sure to install the C++ development workload. - pause - exit /b 1 -) - -echo ✓ MSBuild found - -REM Check for vcpkg -if not exist "vcpkg.json" ( - echo WARNING: vcpkg.json not found. vcpkg integration may not work properly. -) - -echo Build Configuration: %BUILD_CONFIG% -echo Build Platform: %BUILD_PLATFORM% - -REM Create build directories -echo Creating build directories... -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... - 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... - -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% - pause - exit /b 1 -) - -echo ✓ Build completed successfully - -REM Verify executable was created -set EXE_PATH=build\bin\%BUILD_CONFIG%\yaze.exe -if not exist "%EXE_PATH%" ( - echo ERROR: Executable not found at expected path: %EXE_PATH% - pause - exit /b 1 -) - -echo ✓ Executable created: %EXE_PATH% - -REM Test that the executable runs (basic test) -echo Testing executable startup... -"%EXE_PATH%" --help >nul 2>&1 -set EXIT_CODE=%errorlevel% - -REM Check if it's the test main or app main -"%EXE_PATH%" --help 2>&1 | findstr /i "Google Test" >nul -if %errorlevel% equ 0 ( - echo ERROR: Executable is running test main instead of app main! - pause - exit /b 1 -) - -echo ✓ Executable runs correctly (exit code: %EXIT_CODE%) - -REM Display file info -for %%A in ("%EXE_PATH%") do set FILE_SIZE=%%~zA -set /a FILE_SIZE_MB=%FILE_SIZE% / 1024 / 1024 -echo Executable size: %FILE_SIZE_MB% MB - -echo ======================================== -echo ✓ YAZE Windows build completed successfully! -echo ======================================== -echo. -echo Build Configuration: %BUILD_CONFIG% -echo Build Platform: %BUILD_PLATFORM% -echo Executable: %EXE_PATH% -echo. -echo To run YAZE: -echo %EXE_PATH% -echo. -echo To build other configurations: -echo %~nx0 Debug x64 -echo %~nx0 Release x86 -echo %~nx0 RelWithDebInfo ARM64 -echo %~nx0 clean -echo. - -pause \ No newline at end of file diff --git a/scripts/build-windows.ps1 b/scripts/build-windows.ps1 deleted file mode 100644 index 36822153..00000000 --- a/scripts/build-windows.ps1 +++ /dev/null @@ -1,220 +0,0 @@ -# YAZE Windows Build Script -# This script builds the YAZE project on Windows using MSBuild - -param( - [string]$Configuration = "Release", - [string]$Platform = "x64", - [switch]$Clean, - [switch]$Verbose -) - -# 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 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-Status "ERROR: YAZE.sln not found. Please run this script from the project root directory." "Error" - exit 1 -} - -Write-Status "✓ Found YAZE.sln" "Success" - -# 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 -if (-not (Test-Path "vcpkg.json")) { - Write-Status "WARNING: vcpkg.json not found. vcpkg integration may not work properly." "Warning" -} - -# Create build directories -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-Status "✓ Created directory: $dir" "Success" - } -} - -# Clean build if requested -if ($Clean) { - 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-Status "✓ Build directories cleaned" "Success" -} - -# Generate yaze_config.h if it doesn't exist -if (-not (Test-Path "yaze_config.h")) { - 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" - $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-Status "WARNING: yaze_config.h.in not found, creating basic config" "Warning" - @" -// yaze config file -#define YAZE_VERSION_MAJOR 0 -#define YAZE_VERSION_MINOR 3 -#define YAZE_VERSION_PATCH 1 -"@ | Out-File -FilePath "yaze_config.h" -Encoding UTF8 - } -} - -# Build using MSBuild -Write-Status "Building with MSBuild..." "Warning" - -$msbuildArgs = @( - "YAZE.sln" - "/p:Configuration=$Configuration" - "/p:Platform=$Platform" - "/p:VcpkgEnabled=true" - "/p:VcpkgManifestInstall=true" - "/m" -) - -if ($Verbose) { - $msbuildArgs += "/verbosity:detailed" -} else { - $msbuildArgs += "/verbosity:minimal" -} - -$msbuildCommand = "& `"$msbuildPath`" $($msbuildArgs -join ' ')" -Write-Status "Command: $msbuildCommand" "Info" - -try { - & $msbuildPath @msbuildArgs - if ($LASTEXITCODE -ne 0) { - throw "MSBuild failed with exit code $LASTEXITCODE" - } - Write-Status "✓ Build completed successfully" "Success" -} catch { - Write-Status "✗ Build failed: $_" "Error" - exit 1 -} - -# Verify executable was created -$exePath = "build\bin\$Configuration\yaze.exe" -if (-not (Test-Path $exePath)) { - Write-Status "ERROR: Executable not found at expected path: $exePath" "Error" - exit 1 -} - -Write-Status "✓ Executable created: $exePath" "Success" - -# 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-Status "ERROR: Executable is running test main instead of app main!" "Error" - Write-Status "Output: $testResult" "Error" - exit 1 - } - - Write-Status "✓ Executable runs correctly (exit code: $exitCode)" "Success" -} catch { - Write-Status "WARNING: Could not test executable: $_" "Warning" -} - -# Display file info -$exeInfo = Get-Item $exePath -$fileSizeMB = [math]::Round($exeInfo.Length / 1MB, 2) -Write-Status "Executable size: $fileSizeMB MB" "Info" - -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-windows-dev.ps1 b/scripts/setup-windows-dev.ps1 deleted file mode 100644 index 1495c7cf..00000000 --- a/scripts/setup-windows-dev.ps1 +++ /dev/null @@ -1,219 +0,0 @@ -# yaze Windows Development Setup Script -# Sequential approach with no functions and minimal conditionals - -param( - [switch]$SkipVcpkg, - [switch]$SkipVS, - [switch]$SkipBuild -) - -$ErrorActionPreference = "Continue" - -Write-Host "========================================" -ForegroundColor Cyan -Write-Host "YAZE Windows Development Setup" -ForegroundColor Cyan -Write-Host "========================================" -ForegroundColor Cyan - -# Step 1: Check project directory -Write-Host "Step 1: Checking project directory..." -ForegroundColor Yellow -$projectValid = Test-Path "CMakeLists.txt" -switch ($projectValid) { - $true { Write-Host "✓ CMakeLists.txt found" -ForegroundColor Green } - $false { - Write-Host "✗ CMakeLists.txt not found" -ForegroundColor Red - Write-Host "Please run this script from the YAZE project root directory" -ForegroundColor Yellow - exit 1 - } -} - -# Step 2: Check Visual Studio -Write-Host "Step 2: Checking Visual Studio..." -ForegroundColor Yellow -switch ($SkipVS) { - $true { Write-Host "Skipping Visual Studio check" -ForegroundColor Yellow } - $false { - $vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" - $vsFound = $false - $vsExists = Test-Path $vsWhere - switch ($vsExists) { - $true { - $vsInstall = & $vsWhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath - switch ($null -ne $vsInstall) { - $true { - $msbuildPath = Join-Path $vsInstall "MSBuild\Current\Bin\MSBuild.exe" - $vsFound = Test-Path $msbuildPath - } - } - } - } - - switch ($vsFound) { - $true { Write-Host "✓ Visual Studio 2022 with C++ workload found" -ForegroundColor Green } - $false { - Write-Host "⚠ Visual Studio 2022 with C++ workload not found" -ForegroundColor Yellow - Write-Host "Please install Visual Studio 2022 with 'Desktop development with C++' workload" -ForegroundColor White - } - } - } -} - -# Step 3: Check Git -Write-Host "Step 3: Checking Git..." -ForegroundColor Yellow -$gitFound = $false -try { - $null = Get-Command git -ErrorAction Stop - $gitFound = $true -} catch { - $gitFound = $false -} - -switch ($gitFound) { - $true { - $gitVersion = & git --version - Write-Host "✓ Git found: $gitVersion" -ForegroundColor Green - } - $false { - Write-Host "⚠ Git not found" -ForegroundColor Yellow - Write-Host "Please install Git for Windows from: https://git-scm.com/download/win" -ForegroundColor White - } -} - -# Step 4: Check Python -Write-Host "Step 4: Checking Python..." -ForegroundColor Yellow -$pythonFound = $false -try { - $null = Get-Command python -ErrorAction Stop - $pythonFound = $true -} catch { - $pythonFound = $false -} - -switch ($pythonFound) { - $true { - $pythonVersion = & python --version - Write-Host "✓ Python found: $pythonVersion" -ForegroundColor Green - } - $false { - Write-Host "⚠ Python not found" -ForegroundColor Yellow - Write-Host "Please install Python 3.8+ from: https://www.python.org/downloads/" -ForegroundColor White - } -} - -# Step 5: Setup vcpkg -Write-Host "Step 5: Setting up vcpkg..." -ForegroundColor Yellow -switch ($SkipVcpkg) { - $true { Write-Host "Skipping vcpkg setup" -ForegroundColor Yellow } - $false { - # Clone vcpkg - $vcpkgExists = Test-Path "vcpkg" - switch ($vcpkgExists) { - $false { - Write-Host "Cloning vcpkg..." -ForegroundColor Yellow - switch ($gitFound) { - $true { - & git clone https://github.com/Microsoft/vcpkg.git vcpkg - $cloneSuccess = ($LASTEXITCODE -eq 0) - switch ($cloneSuccess) { - $true { Write-Host "✓ vcpkg cloned successfully" -ForegroundColor Green } - $false { - Write-Host "✗ Failed to clone vcpkg" -ForegroundColor Red - exit 1 - } - } - } - $false { - Write-Host "✗ Git is required to clone vcpkg" -ForegroundColor Red - exit 1 - } - } - } - $true { Write-Host "✓ vcpkg directory already exists" -ForegroundColor Green } - } - - # Bootstrap vcpkg - $vcpkgExe = "vcpkg\vcpkg.exe" - $vcpkgBootstrapped = Test-Path $vcpkgExe - switch ($vcpkgBootstrapped) { - $false { - Write-Host "Bootstrapping vcpkg..." -ForegroundColor Yellow - Push-Location vcpkg - & .\bootstrap-vcpkg.bat - $bootstrapSuccess = ($LASTEXITCODE -eq 0) - Pop-Location - switch ($bootstrapSuccess) { - $true { Write-Host "✓ vcpkg bootstrapped successfully" -ForegroundColor Green } - $false { - Write-Host "✗ Failed to bootstrap vcpkg" -ForegroundColor Red - exit 1 - } - } - } - $true { Write-Host "✓ vcpkg already bootstrapped" -ForegroundColor Green } - } - - # Install dependencies - Write-Host "Installing dependencies..." -ForegroundColor Yellow - & $vcpkgExe install --triplet x64-windows - $installSuccess = ($LASTEXITCODE -eq 0) - switch ($installSuccess) { - $true { Write-Host "✓ Dependencies installed successfully" -ForegroundColor Green } - $false { Write-Host "⚠ Some dependencies may not have installed correctly" -ForegroundColor Yellow } - } - } -} - -# Step 6: Generate project files -Write-Host "Step 6: Generating Visual Studio project files..." -ForegroundColor Yellow -switch ($pythonFound) { - $true { - & python scripts/generate-vs-projects-simple.py - $generateSuccess = ($LASTEXITCODE -eq 0) - switch ($generateSuccess) { - $true { Write-Host "✓ Project files generated successfully" -ForegroundColor Green } - $false { - Write-Host "⚠ Failed to generate project files with simple generator, trying original..." -ForegroundColor Yellow - & python scripts/generate-vs-projects.py - $generateSuccess2 = ($LASTEXITCODE -eq 0) - switch ($generateSuccess2) { - $true { Write-Host "✓ Project files generated successfully" -ForegroundColor Green } - $false { Write-Host "⚠ Failed to generate project files" -ForegroundColor Yellow } - } - } - } - } - $false { Write-Host "⚠ Python required to generate project files" -ForegroundColor Yellow } -} - -# Step 7: Test build -Write-Host "Step 7: Testing build..." -ForegroundColor Yellow -switch ($SkipBuild) { - $true { Write-Host "Skipping test build" -ForegroundColor Yellow } - $false { - $buildScriptExists = Test-Path "scripts\build-windows.ps1" - switch ($buildScriptExists) { - $true { - & .\scripts\build-windows.ps1 -Configuration Release -Platform x64 - $buildSuccess = ($LASTEXITCODE -eq 0) - switch ($buildSuccess) { - $true { Write-Host "✓ Test build successful" -ForegroundColor Green } - $false { Write-Host "⚠ Test build failed, but setup is complete" -ForegroundColor Yellow } - } - } - $false { Write-Host "⚠ Build script not found" -ForegroundColor Yellow } - } - } -} - -# Final instructions -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. Visual Studio project files have been generated" -ForegroundColor White -Write-Host "2. Open YAZE.sln in Visual Studio 2022" -ForegroundColor White -Write-Host "3. Select configuration (Debug/Release) and platform (x64/x86/ARM64)" -ForegroundColor White -Write-Host "4. Build the solution (Ctrl+Shift+B)" -ForegroundColor White -Write-Host "" -Write-Host "Or use 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/windows-development-guide.md" -ForegroundColor Cyan \ No newline at end of file diff --git a/scripts/validate-windows-build.ps1 b/scripts/validate-windows-build.ps1 deleted file mode 100644 index 69bbc869..00000000 --- a/scripts/validate-windows-build.ps1 +++ /dev/null @@ -1,132 +0,0 @@ -# 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"