diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64651747..c918a2da 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -231,7 +231,7 @@ jobs: run: | echo "Using streamlined release build configuration for all platforms" echo "Linux/macOS: UI tests enabled with full dependency support" - echo "Windows: Minimal build to avoid vcpkg issues, UI tests disabled" + echo "Windows: Full build with vcpkg integration for proper releases" echo "All platforms: Emulator and developer tools disabled for clean releases" # Configure CMake @@ -250,6 +250,17 @@ jobs: -DYAZE_INSTALL_LIB=OFF \ -GNinja + # Set up vcpkg for Windows builds + - name: Set up vcpkg (Windows) + if: runner.os == 'Windows' + uses: lukka/run-vcpkg@v11 + with: + vcpkgGitCommitId: 'c8696863d371ab7f46e213d8f5ca923c4aef2a00' + runVcpkgInstall: true + vcpkgJsonGlob: '**/vcpkg.json' + vcpkgDirectory: '${{ github.workspace }}/vcpkg' + vcpkgTriplet: '${{ matrix.vcpkg_triplet }}' + - name: Configure CMake (Windows) if: runner.os == 'Windows' shell: cmd @@ -257,13 +268,14 @@ jobs: cmake -B build ^ -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ^ -DCMAKE_POLICY_VERSION_MINIMUM=3.16 ^ + -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" ^ -DYAZE_BUILD_TESTS=OFF ^ -DYAZE_BUILD_EMU=OFF ^ -DYAZE_BUILD_Z3ED=OFF ^ -DYAZE_ENABLE_ROM_TESTS=OFF ^ -DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF ^ -DYAZE_INSTALL_LIB=OFF ^ - -DYAZE_MINIMAL_BUILD=ON ^ + -DYAZE_MINIMAL_BUILD=OFF ^ -G "${{ matrix.cmake_generator }}" ^ -A ${{ matrix.cmake_generator_platform }} @@ -271,6 +283,76 @@ jobs: - name: Build run: cmake --build build --config ${{ env.BUILD_TYPE }} --parallel + # Validate Visual Studio project builds (Windows only) + - name: Validate Visual Studio Project Build + if: runner.os == 'Windows' + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + + Write-Host "========================================" -ForegroundColor Cyan + Write-Host "Validating Visual Studio Project Build" -ForegroundColor Cyan + Write-Host "Platform: ${{ matrix.cmake_generator_platform }}" -ForegroundColor Yellow + Write-Host "Configuration: ${{ env.BUILD_TYPE }}" -ForegroundColor Yellow + 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 + } + + Write-Host "✓ yaze.sln found" -ForegroundColor Green + + # Build using MSBuild + Write-Host "Building with MSBuild..." -ForegroundColor Yellow + $msbuildArgs = @( + "yaze.sln" + "/p:Configuration=${{ env.BUILD_TYPE }}" + "/p:Platform=${{ matrix.cmake_generator_platform }}" + "/p:VcpkgEnabled=true" + "/p:VcpkgManifestInstall=true" + "/m" # Multi-processor build + "/verbosity:minimal" + ) + + 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 "✓ Visual Studio build completed successfully" -ForegroundColor Green + + # Verify executable was created + $exePath = "build\bin\${{ env.BUILD_TYPE }}\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 + + # 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 + + Write-Host "========================================" -ForegroundColor Cyan + Write-Host "✓ Visual Studio build validation PASSED" -ForegroundColor Green + Write-Host "========================================" -ForegroundColor Cyan + # Package - name: Package shell: bash diff --git a/.github/workflows/validate-vs-build.yml b/.github/workflows/validate-vs-build.yml new file mode 100644 index 00000000..da501c25 --- /dev/null +++ b/.github/workflows/validate-vs-build.yml @@ -0,0 +1,164 @@ +name: Validate Visual Studio Builds + +on: + push: + branches: [ "master", "develop" ] + paths: + - 'yaze.vcxproj' + - 'yaze.sln' + - 'vcpkg.json' + - 'src/**' + - 'scripts/validate-vs-build.ps1' + - '.github/workflows/validate-vs-build.yml' + pull_request: + branches: [ "master", "develop" ] + paths: + - 'yaze.vcxproj' + - 'yaze.sln' + - 'vcpkg.json' + - 'src/**' + - 'scripts/validate-vs-build.ps1' + - '.github/workflows/validate-vs-build.yml' + +env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + +jobs: + validate-vs-builds: + strategy: + fail-fast: false + matrix: + include: + - name: "Windows x64 Debug" + platform: x64 + configuration: Debug + + - name: "Windows x64 Release" + platform: x64 + configuration: Release + + - name: "Windows x86 Debug" + platform: x86 + configuration: Debug + + - name: "Windows x86 Release" + platform: x86 + configuration: Release + + name: ${{ matrix.name }} + runs-on: windows-2022 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up vcpkg + uses: lukka/run-vcpkg@v11 + with: + vcpkgGitCommitId: 'c8696863d371ab7f46e213d8f5ca923c4aef2a00' + runVcpkgInstall: true + vcpkgJsonGlob: '**/vcpkg.json' + vcpkgDirectory: '${{ github.workspace }}/vcpkg' + vcpkgTriplet: '${{ matrix.platform }}-windows' + + - name: Validate Visual Studio Build + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + + Write-Host "========================================" -ForegroundColor Cyan + Write-Host "YAZE Visual Studio Build Validation" -ForegroundColor Cyan + Write-Host "Platform: ${{ matrix.platform }}" -ForegroundColor Yellow + Write-Host "Configuration: ${{ matrix.configuration }}" -ForegroundColor Yellow + 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 + } + + Write-Host "✓ yaze.sln found" -ForegroundColor Green + + # 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=${{ matrix.configuration }}" + "/p:Platform=${{ matrix.platform }}" + "/p:VcpkgEnabled=true" + "/p:VcpkgManifestInstall=true" + "/m" # Multi-processor build + "/verbosity:minimal" + ) + + 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\${{ matrix.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\${{ matrix.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 + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: yaze-${{ matrix.platform }}-${{ matrix.configuration }} + path: | + build/bin/${{ matrix.configuration }}/ + retention-days: 7 diff --git a/docs/visual-studio-setup.md b/docs/visual-studio-setup.md index 3813e8d0..0c52a946 100644 --- a/docs/visual-studio-setup.md +++ b/docs/visual-studio-setup.md @@ -241,13 +241,37 @@ The included `yaze.vcxproj` and `yaze.sln` files provide: - **Debugging Integration:** Native Visual Studio debugging support - **Project Properties:** Easy access to compiler and linker settings +## CI/CD Integration + +The Visual Studio project files are fully integrated into the CI/CD pipeline: + +### **Automated Validation** +- **Pre-commit checks:** Visual Studio builds are validated on every pull request +- **Release validation:** Both CMake and Visual Studio builds are tested before release +- **Multi-platform testing:** x64 and x86 builds are validated on Windows +- **Dependency verification:** vcpkg integration is tested automatically + +### **Build Matrix** +The CI/CD pipeline tests: +- **Windows x64 Debug/Release** using Visual Studio 2022 +- **Windows x86 Debug/Release** using Visual Studio 2022 +- **CMake builds** alongside Visual Studio builds for compatibility +- **Asset copying** and executable functionality + +### **Quality Assurance** +- **Test main detection:** Prevents the test framework from hijacking the main application +- **Asset validation:** Ensures themes and resources are properly copied +- **Executable testing:** Verifies the application starts correctly +- **Dependency checking:** Validates all required libraries are properly linked + ## Additional Notes - The project supports both x64 and x86 builds (use appropriate vcpkg triplets) - For ARM64 Windows builds, use `arm64-windows` triplet -- The CI/CD pipeline uses minimal builds to avoid dependency issues +- The CI/CD pipeline validates both CMake and Visual Studio builds - Development builds include additional debugging features and ROM testing capabilities - The `.vcxproj` file provides the easiest setup for Visual Studio users who prefer traditional project files over CMake +- All builds are automatically validated to ensure they produce working executables ## Support diff --git a/scripts/validate-vs-build.ps1 b/scripts/validate-vs-build.ps1 new file mode 100644 index 00000000..8a97ba87 --- /dev/null +++ b/scripts/validate-vs-build.ps1 @@ -0,0 +1,146 @@ +# 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/src/app/editor/editor_manager.cc b/src/app/editor/editor_manager.cc index f6185157..d11bce58 100644 --- a/src/app/editor/editor_manager.cc +++ b/src/app/editor/editor_manager.cc @@ -541,7 +541,6 @@ void EditorManager::Initialize(const std::string &filename) { {}, {}, {}, -#ifdef YAZE_ENABLE_TESTING { // Testing and Validation (only when tests are enabled) {absl::StrCat(ICON_MD_SCIENCE, " Test Dashboard"), "Ctrl+T", @@ -553,11 +552,7 @@ void EditorManager::Initialize(const std::string &filename) { {absl::StrCat(ICON_MD_MEMORY, " Run Integration Tests"), "", [&]() { [[maybe_unused]] auto status = test::TestManager::Get().RunTestsByCategory(test::TestCategory::kIntegration); }}, {absl::StrCat(ICON_MD_CLEAR_ALL, " Clear Test Results"), "", - [&]() { test::TestManager::Get().ClearResults(); }}, -#else -{}, -#endif - + [&]() { test::TestManager::Get().ClearResults(); }}, {gui::kSeparator, "", nullptr, []() { return true; }}, // ROM and ASM Management