|
| 1 | +name: Build Game with VC6 |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + game: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + description: "Game to build (Generals or GeneralsMD)" |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: windows-latest |
| 14 | + timeout-minutes: 15 |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Cache VC6 installation |
| 20 | + id: cache-vc6 |
| 21 | + uses: actions/cache@v4 |
| 22 | + with: |
| 23 | + path: C:\VC6 |
| 24 | + key: vc6-permanent-cache-v1 |
| 25 | + |
| 26 | + - name: Cache CMake Dependencies |
| 27 | + id: cache-cmake-deps |
| 28 | + uses: actions/cache@v4 |
| 29 | + with: |
| 30 | + path: build\vc6\_deps |
| 31 | + key: cmake-deps-${{ hashFiles('cmake/**/*.cmake', '**/CMakeLists.txt') }} |
| 32 | + restore-keys: | |
| 33 | + cmake-deps- |
| 34 | +
|
| 35 | + - name: Download VC6 Portable from Cloudflare R2 |
| 36 | + if: steps.cache-vc6.outputs.cache-hit != 'true' |
| 37 | + env: |
| 38 | + AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} |
| 39 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} |
| 40 | + AWS_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT_URL }} |
| 41 | + EXPECTED_HASH: "118D0F1ACBBD70C3F8B081CA4DBAF955FE0C6C359A76636E930AA89FDC551091" |
| 42 | + shell: pwsh |
| 43 | + run: | |
| 44 | + Write-Host "Downloading VC6 portable installation" |
| 45 | + aws s3 cp s3://github-ci/VS6_VisualStudio6.7z VS6_VisualStudio6.7z --endpoint-url $env:AWS_ENDPOINT_URL |
| 46 | +
|
| 47 | + Write-Host "Verifying file integrity..." |
| 48 | + $hash = (Get-FileHash -Path VS6_VisualStudio6.7z -Algorithm SHA256).Hash |
| 49 | + Write-Host "Downloaded file SHA256: $hash" |
| 50 | + Write-Host "Expected SHA256: $env:EXPECTED_HASH" |
| 51 | + if ($hash -ne $env:EXPECTED_HASH) { |
| 52 | + Write-Error "Hash verification failed! File may be corrupted or tampered with." |
| 53 | + exit 1 |
| 54 | + } |
| 55 | +
|
| 56 | + Write-Host "Extracting archive..." |
| 57 | + & 7z x VS6_VisualStudio6.7z -oC:\VC6 |
| 58 | +
|
| 59 | + Write-Host "Cleaning up downloaded archive" |
| 60 | + Remove-Item VS6_VisualStudio6.7z |
| 61 | +
|
| 62 | + - name: Set up VC6 environment |
| 63 | + shell: pwsh |
| 64 | + run: | |
| 65 | + Write-Host "Setting up environment for using Microsoft Visual C++ tools" |
| 66 | +
|
| 67 | + # Define the base directories as local variables first |
| 68 | + $VSCommonDir = "C:\VC6\VC6SP6\Common" |
| 69 | + $MSDevDir = "C:\VC6\VC6SP6\Common\msdev98" |
| 70 | + $MSVCDir = "C:\VC6\VC6SP6\VC98" |
| 71 | + $VcOsDir = "WINNT" |
| 72 | +
|
| 73 | + # Set the variables in GitHub environment |
| 74 | + "VSCommonDir=$VSCommonDir" >> $env:GITHUB_ENV |
| 75 | + "MSDevDir=$MSDevDir" >> $env:GITHUB_ENV |
| 76 | + "MSVCDir=$MSVCDir" >> $env:GITHUB_ENV |
| 77 | + "VcOsDir=$VcOsDir" >> $env:GITHUB_ENV |
| 78 | +
|
| 79 | + # Set PATH |
| 80 | + "PATH=$MSDevDir\BIN;$MSVCDir\BIN;$VSCommonDir\TOOLS\$VcOsDir;$VSCommonDir\TOOLS;$env:PATH" >> $env:GITHUB_ENV |
| 81 | +
|
| 82 | + # Set INCLUDE |
| 83 | + "INCLUDE=$MSVCDir\ATL\INCLUDE;$MSVCDir\INCLUDE;$MSVCDir\MFC\INCLUDE;$env:INCLUDE" >> $env:GITHUB_ENV |
| 84 | +
|
| 85 | + # Set LIB |
| 86 | + "LIB=$MSVCDir\LIB;$MSVCDir\MFC\LIB;$env:LIB" >> $env:GITHUB_ENV |
| 87 | +
|
| 88 | + - name: Build with CMake using VC6 preset |
| 89 | + shell: pwsh |
| 90 | + run: | |
| 91 | + Write-Host "Configuring project with CMake using VC6 preset - building only ${{ inputs.game }}" |
| 92 | +
|
| 93 | + # Set build flags based on game |
| 94 | + if ("${{ inputs.game }}" -eq "Generals") { |
| 95 | + $buildFlags = @("-DGENZH_BUILD_ZEROHOUR=OFF", "-DGENZH_BUILD_GENERALS=ON", "-DGENZH_BUILD_GENERALS_TOOLS=ON") |
| 96 | + } else { |
| 97 | + $buildFlags = @("-DGENZH_BUILD_ZEROHOUR=ON", "-DGENZH_BUILD_GENERALS=OFF", "-DGENZH_BUILD_ZEROHOUR_TOOLS=ON") |
| 98 | + } |
| 99 | +
|
| 100 | + cmake --preset vc6 $buildFlags |
| 101 | +
|
| 102 | + Write-Host "Building project with CMake using VC6 preset - building only ${{ inputs.game }}" |
| 103 | +
|
| 104 | + $buildDir = "build/vc6" |
| 105 | + "buildDir=$buildDir" >> $env:GITHUB_ENV |
| 106 | +
|
| 107 | + cmake --build $buildDir |
| 108 | +
|
| 109 | + Write-Host "Collecting ${{ inputs.game }} tools" |
| 110 | + $toolsDir = New-Item -ItemType Directory -Force -Path "$buildDir\${{ inputs.game }}\Tools" |
| 111 | + $files = Get-ChildItem -Path "$buildDir\${{ inputs.game }}" -File | Where-Object { ($_.Extension -eq ".exe" -or $_.Extension -eq ".dll") -and $_.Name -ne "generals.exe" } |
| 112 | + $files | Move-Item -Destination $toolsDir |
| 113 | +
|
| 114 | + - name: Upload ${{ inputs.game }} executable |
| 115 | + uses: actions/upload-artifact@v4 |
| 116 | + with: |
| 117 | + name: ${{ inputs.game }} |
| 118 | + path: ${{ env.buildDir }}/${{ inputs.game }}/generals.exe |
| 119 | + retention-days: 30 |
| 120 | + if-no-files-found: error |
| 121 | + |
| 122 | + - name: Upload ${{ inputs.game }} tools |
| 123 | + uses: actions/upload-artifact@v4 |
| 124 | + with: |
| 125 | + name: ${{ inputs.game }}-Tools |
| 126 | + path: ${{ env.buildDir }}/${{ inputs.game }}/Tools |
| 127 | + retention-days: 30 |
| 128 | + if-no-files-found: error |
0 commit comments