|
| 1 | +name: Windows Build Fallback |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + build_type: |
| 7 | + description: 'Build type (Debug/Release)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + default: 'Release' |
| 11 | + platform: |
| 12 | + description: 'Platform (x64/x86)' |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + default: 'x64' |
| 16 | + |
| 17 | +env: |
| 18 | + BUILD_TYPE: ${{ inputs.build_type }} |
| 19 | + PLATFORM: ${{ inputs.platform }} |
| 20 | + |
| 21 | +jobs: |
| 22 | + build-windows-fallback: |
| 23 | + name: Windows ${{ inputs.platform }} ${{ inputs.build_type }} (Fallback) |
| 24 | + runs-on: windows-2022 |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout code |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + submodules: recursive |
| 31 | + |
| 32 | + # Try vcpkg first |
| 33 | + - name: Set up vcpkg (Primary) |
| 34 | + id: vcpkg_primary |
| 35 | + uses: lukka/run-vcpkg@v11 |
| 36 | + continue-on-error: true |
| 37 | + with: |
| 38 | + vcpkgGitCommitId: 'c8696863d371ab7f46e213d8f5ca923c4aef2a00' |
| 39 | + runVcpkgInstall: true |
| 40 | + vcpkgJsonGlob: '**/vcpkg.json' |
| 41 | + vcpkgDirectory: '${{ github.workspace }}/vcpkg' |
| 42 | + env: |
| 43 | + VCPKG_FORCE_SYSTEM_BINARIES: 1 |
| 44 | + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" |
| 45 | + VCPKG_DEFAULT_TRIPLET: '${{ inputs.platform }}-windows' |
| 46 | + VCPKG_INSTALL_OPTIONS: '--x-install-root="${{ github.workspace }}/vcpkg_installed"' |
| 47 | + |
| 48 | + # Fallback to newer baseline if primary fails |
| 49 | + - name: Set up vcpkg (Fallback) |
| 50 | + if: steps.vcpkg_primary.outcome == 'failure' |
| 51 | + uses: lukka/run-vcpkg@v11 |
| 52 | + with: |
| 53 | + vcpkgGitCommitId: '2024.01.12' |
| 54 | + runVcpkgInstall: true |
| 55 | + vcpkgJsonGlob: '**/vcpkg.json.backup' |
| 56 | + vcpkgDirectory: '${{ github.workspace }}/vcpkg' |
| 57 | + env: |
| 58 | + VCPKG_FORCE_SYSTEM_BINARIES: 1 |
| 59 | + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" |
| 60 | + VCPKG_DEFAULT_TRIPLET: '${{ inputs.platform }}-windows' |
| 61 | + VCPKG_INSTALL_OPTIONS: '--x-install-root="${{ github.workspace }}/vcpkg_installed"' |
| 62 | + |
| 63 | + # Fallback to manual dependency installation if both vcpkg attempts fail |
| 64 | + - name: Install dependencies manually |
| 65 | + if: steps.vcpkg_primary.outcome == 'failure' |
| 66 | + shell: pwsh |
| 67 | + run: | |
| 68 | + Write-Host "Installing dependencies manually using Chocolatey and pre-built libraries..." |
| 69 | + |
| 70 | + # Install Chocolatey if not present |
| 71 | + if (-not (Get-Command choco -ErrorAction SilentlyContinue)) { |
| 72 | + Set-ExecutionPolicy Bypass -Scope Process -Force |
| 73 | + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 |
| 74 | + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) |
| 75 | + } |
| 76 | + |
| 77 | + # Install basic dependencies |
| 78 | + choco install -y cmake ninja |
| 79 | + |
| 80 | + # Create a minimal build configuration |
| 81 | + Write-Host "Creating minimal build configuration for CI..." |
| 82 | + |
| 83 | + # Set up environment variables for minimal build |
| 84 | + echo "YAZE_MINIMAL_BUILD=ON" >> $env:GITHUB_ENV |
| 85 | + echo "CMAKE_PREFIX_PATH=$env:GITHUB_WORKSPACE\vcpkg_installed\${{ inputs.platform }}-windows" >> $env:GITHUB_ENV |
| 86 | +
|
| 87 | + - name: Configure CMake |
| 88 | + shell: cmd |
| 89 | + run: | |
| 90 | + if exist "${{ github.workspace }}\vcpkg_installed" ( |
| 91 | + echo "Using vcpkg installation..." |
| 92 | + cmake -B build ^ |
| 93 | + -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^ |
| 94 | + -DCMAKE_POLICY_VERSION_MINIMUM=3.16 ^ |
| 95 | + -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" ^ |
| 96 | + -DYAZE_BUILD_TESTS=OFF ^ |
| 97 | + -DYAZE_BUILD_EMU=OFF ^ |
| 98 | + -DYAZE_BUILD_Z3ED=OFF ^ |
| 99 | + -DYAZE_ENABLE_ROM_TESTS=OFF ^ |
| 100 | + -DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF ^ |
| 101 | + -DYAZE_INSTALL_LIB=OFF ^ |
| 102 | + -DYAZE_MINIMAL_BUILD=ON ^ |
| 103 | + -G "Visual Studio 17 2022" ^ |
| 104 | + -A %PLATFORM% |
| 105 | + ) else ( |
| 106 | + echo "Using minimal build configuration..." |
| 107 | + cmake -B build ^ |
| 108 | + -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^ |
| 109 | + -DCMAKE_POLICY_VERSION_MINIMUM=3.16 ^ |
| 110 | + -DYAZE_BUILD_TESTS=OFF ^ |
| 111 | + -DYAZE_BUILD_EMU=OFF ^ |
| 112 | + -DYAZE_BUILD_Z3ED=OFF ^ |
| 113 | + -DYAZE_ENABLE_ROM_TESTS=OFF ^ |
| 114 | + -DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF ^ |
| 115 | + -DYAZE_INSTALL_LIB=OFF ^ |
| 116 | + -DYAZE_MINIMAL_BUILD=ON ^ |
| 117 | + -G "Visual Studio 17 2022" ^ |
| 118 | + -A %PLATFORM% |
| 119 | + ) |
| 120 | +
|
| 121 | + - name: Build |
| 122 | + run: cmake --build build --config %BUILD_TYPE% --parallel |
| 123 | + |
| 124 | + - name: Test executable |
| 125 | + shell: pwsh |
| 126 | + run: | |
| 127 | + $exePath = "build\bin\$env:BUILD_TYPE\yaze.exe" |
| 128 | + if (Test-Path $exePath) { |
| 129 | + Write-Host "✓ Executable created: $exePath" -ForegroundColor Green |
| 130 | + |
| 131 | + # Test that it's not the test main |
| 132 | + $testResult = & $exePath --help 2>&1 |
| 133 | + if ($testResult -match "Google Test" -or $testResult -match "gtest") { |
| 134 | + Write-Error "Executable is running test main instead of app main!" |
| 135 | + exit 1 |
| 136 | + } |
| 137 | + |
| 138 | + Write-Host "✓ Executable runs correctly" -ForegroundColor Green |
| 139 | + } else { |
| 140 | + Write-Error "Executable not found at: $exePath" |
| 141 | + exit 1 |
| 142 | + } |
| 143 | +
|
| 144 | + - name: Upload build artifacts |
| 145 | + uses: actions/upload-artifact@v4 |
| 146 | + if: always() |
| 147 | + with: |
| 148 | + name: yaze-${{ inputs.platform }}-${{ inputs.build_type }}-fallback |
| 149 | + path: | |
| 150 | + build/bin/${{ inputs.build_type }}/ |
| 151 | + retention-days: 7 |
0 commit comments