Skip to content

Commit 7ad0bd7

Browse files
committed
build(presets): Major CMakePresets overhaul, unify vcpkg, modernize VC6 support
- Deduplicate configure presets for easier maintenance - Make vcpkg the default and speed up dependency installation for all builds - Enable vcpkg integration for VC6 builds - Switch VC6 builds to Ninja Multi-Config: optimization level can now be switched without reconfiguring - Enable ful debug info for VC6 configurations - VC6 environment now requires only the VS6_DIR environment variable to be set - Decouple dev builds from optimization config for more flexible development
1 parent 3db9373 commit 7ad0bd7

File tree

9 files changed

+201
-492
lines changed

9 files changed

+201
-492
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ on:
1111
required: true
1212
type: string
1313
description: "Game to build (Generals, GeneralsMD)"
14-
preset:
14+
configurePreset:
1515
required: true
1616
type: string
17-
description: "CMake preset"
17+
description: "CMake configure preset"
18+
buildPreset:
19+
required: true
20+
type: string
21+
description: "CMake build preset"
1822
tools:
1923
required: false
2024
default: true
@@ -25,18 +29,17 @@ on:
2529
default: false
2630
type: boolean
2731
description: "Build extras"
28-
2932
jobs:
3033
build:
31-
name: ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
34+
name: ${{ inputs.game }} ${{ inputs.configurePreset }} ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
3235
runs-on: windows-2022
3336
timeout-minutes: 20
3437
steps:
3538
- name: Checkout Code
3639
uses: actions/checkout@v4
3740

3841
- name: Cache VC6 Installation
39-
if: startsWith(inputs.preset, 'vc6')
42+
if: startsWith(inputs.buildPreset, 'vc6')
4043
id: cache-vc6
4144
uses: actions/cache@v4
4245
with:
@@ -47,11 +50,11 @@ jobs:
4750
id: cache-cmake-deps
4851
uses: actions/cache@v4
4952
with:
50-
path: build\${{ inputs.preset }}\_deps
51-
key: cmake-deps-${{ inputs.preset }}-${{ hashFiles('CMakePresets.json','cmake/**/*.cmake','**/CMakeLists.txt') }}
53+
path: build\${{ inputs.buildPreset }}\_deps
54+
key: cmake-deps-${{ inputs.buildPreset }}-${{ hashFiles('CMakePresets.json','cmake/**/*.cmake','**/CMakeLists.txt') }}
5255

5356
- name: Download VC6 Portable from Cloudflare R2
54-
if: ${{ startsWith(inputs.preset, 'vc6') && steps.cache-vc6.outputs.cache-hit != 'true' }}
57+
if: ${{ startsWith(inputs.buildPreset, 'vc6') && steps.cache-vc6.outputs.cache-hit != 'true' }}
5558
env:
5659
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
5760
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
@@ -76,39 +79,27 @@ jobs:
7679
Remove-Item VS6_VisualStudio6.7z -Verbose
7780
7881
- name: Set Up VC6 Environment
79-
if: startsWith(inputs.preset, 'vc6')
82+
if: startsWith(inputs.buildPreset, 'vc6')
8083
shell: pwsh
8184
run: |
82-
# Define the base directories as local variables first
83-
$VSCommonDir = "C:\VC6\VC6SP6\Common"
84-
$MSDevDir = "C:\VC6\VC6SP6\Common\msdev98"
85-
$MSVCDir = "C:\VC6\VC6SP6\VC98"
86-
$VcOsDir = "WINNT"
87-
88-
# Set the variables in GitHub environment
89-
"VSCommonDir=$VSCommonDir" >> $env:GITHUB_ENV
90-
"MSDevDir=$MSDevDir" >> $env:GITHUB_ENV
91-
"MSVCDir=$MSVCDir" >> $env:GITHUB_ENV
92-
"VcOsDir=$VcOsDir" >> $env:GITHUB_ENV
93-
"PATH=$MSDevDir\BIN;$MSVCDir\BIN;$VSCommonDir\TOOLS\$VcOsDir;$VSCommonDir\TOOLS;$env:PATH" >> $env:GITHUB_ENV
94-
"INCLUDE=$MSVCDir\ATL\INCLUDE;$MSVCDir\INCLUDE;$MSVCDir\MFC\INCLUDE;$env:INCLUDE" >> $env:GITHUB_ENV
95-
"LIB=$MSVCDir\LIB;$MSVCDir\MFC\LIB;$env:LIB" >> $env:GITHUB_ENV
85+
$VS6_DIR = "C:\VC6\VC6SP6"
86+
"VS6_DIR=$VS6_DIR" >> $env:GITHUB_ENV
9687
9788
- name: Set Up VC2022 Environment
98-
if: startsWith(inputs.preset, 'win32')
89+
if: ${{ !startsWith(inputs.buildPreset, 'vc6') }}
9990
uses: ilammy/msvc-dev-cmd@v1
10091
with:
10192
arch: x86
10293

10394
- name: Setup vcpkg
10495
uses: lukka/run-vcpkg@v11
10596

106-
- name: Configure ${{ inputs.game }} with CMake Using ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
97+
- name: Configure ${{ inputs.game }} with CMake Using ${{ inputs.configurePreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
10798
shell: pwsh
10899
run: |
109100
$buildFlags = @(
110-
"-DRTS_BUILD_ZEROHOUR=${{ inputs.game == 'GeneralsMD' && 'ON' || 'OFF' }}",
111-
"-DRTS_BUILD_GENERALS=${{ inputs.game == 'Generals' && 'ON' || 'OFF' }}"
101+
"-DRTS_BUILD_ZEROHOUR=${{ inputs.game == 'GeneralsMD' && 'ON' || 'OFF' }}",
102+
"-DRTS_BUILD_GENERALS=${{ inputs.game == 'Generals' && 'ON' || 'OFF' }}"
112103
)
113104
114105
$gamePrefix = "${{ inputs.game == 'Generals' && 'GENERALS' || 'ZEROHOUR' }}"
@@ -118,33 +109,26 @@ jobs:
118109
$buildFlags += "-DRTS_BUILD_${gamePrefix}_EXTRAS=${{ inputs.extras && 'ON' || 'OFF' }}"
119110
120111
Write-Host "Build flags: $($buildFlags -join ' | ')"
112+
cmake --preset ${{ inputs.configurePreset }} $($buildFlags -join ' ')
121113
122-
cmake --preset ${{ inputs.preset }} $buildFlags
123-
124-
- name: Build ${{ inputs.game }} with CMake Using ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
114+
- name: Build ${{ inputs.game }} with CMake Using ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
125115
shell: pwsh
126116
run: |
127-
cmake --build --preset ${{ inputs.preset }}
117+
cmake --build --preset ${{ inputs.buildPreset }}
128118
129-
- name: Collect ${{ inputs.game }} ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
119+
- name: Collect ${{ inputs.game }} ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
130120
shell: pwsh
131121
run: |
132-
$buildDir = "build\${{ inputs.preset }}"
122+
$buildDir = "build\${{ inputs.configurePreset }}"
133123
$artifactsDir = New-Item -ItemType Directory -Force -Path "$buildDir\${{ inputs.game }}\artifacts" -Verbose
134-
135-
if ("${{ inputs.preset }}" -like "win32*") {
136-
# For win32 preset, look in config-specific subdirectories
137-
$configToUse = if ("${{ inputs.preset }}" -match "debug") { "Debug" } else { "Release" }
138-
$files = Get-ChildItem -Path "$buildDir\Core\$configToUse","$buildDir\${{ inputs.game }}\$configToUse" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
139-
} else {
140-
$files = Get-ChildItem -Path "$buildDir\Core","$buildDir\${{ inputs.game }}" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
141-
}
124+
$configToUse = if ("${{ inputs.buildPreset }}" -match "relwithdebinfo") { "RelWithDebInfo" } elseif ("${{ inputs.buildPreset }}" -match "debug") { "Debug" } else { "Release" }
125+
$files = Get-ChildItem -Path "$buildDir\Core\$configToUse","$buildDir\${{ inputs.game }}\$configToUse" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
142126
$files | Move-Item -Destination $artifactsDir -Verbose -Force
143127
144-
- name: Upload ${{ inputs.game }} ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
128+
- name: Upload ${{ inputs.game }} ${{ inputs.configurePreset }} ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
145129
uses: actions/upload-artifact@v4
146130
with:
147-
name: ${{ inputs.game }}-${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
148-
path: build\${{ inputs.preset }}\${{ inputs.game }}\artifacts
131+
name: ${{ inputs.game }}-${{ inputs.configurePreset }}-${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
132+
path: build\${{ inputs.configurePreset }}\${{ inputs.game }}\artifacts
149133
retention-days: 30
150134
if-no-files-found: error

.github/workflows/check-replays.yml

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,27 @@ on:
1010
game:
1111
required: true
1212
type: string
13-
description: "Game to check (only GeneralsMD for now)"
1413
userdata:
1514
required: true
1615
type: string
17-
description: "Path to folder with replays and maps"
18-
preset:
16+
configurePreset:
1917
required: true
2018
type: string
21-
description: "CMake preset"
19+
buildPreset:
20+
required: true
21+
type: string
22+
tools:
23+
required: false
24+
type: boolean
25+
default: false
26+
extras:
27+
required: false
28+
type: boolean
29+
default: false
2230

2331
jobs:
2432
build:
25-
name: ${{ inputs.preset }}
33+
name: ${{ inputs.configurePreset }} | ${{ inputs.buildPreset }}
2634
runs-on: windows-latest
2735
timeout-minutes: 15
2836
env:
@@ -38,7 +46,7 @@ jobs:
3846
- name: Download Game Artifact
3947
uses: actions/download-artifact@v4
4048
with:
41-
name: ${{ inputs.game }}-${{ inputs.preset }}
49+
name: ${{ inputs.game }}-${{ inputs.configurePreset }}-${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
4250
path: build
4351

4452
- name: Cache Game Data
@@ -169,22 +177,35 @@ jobs:
169177
New-Item -ItemType Directory -Path $destination -Force | Out-Null
170178
Move-Item -Path "$source\*" -Destination $destination -Force
171179
180+
- name: List build directory after artifact download
181+
shell: pwsh
182+
run: |
183+
Write-Host "Current Directory: $(Get-Location)"
184+
Get-ChildItem -Path build -Recurse | Write-Host
185+
172186
- name: Run Replay Compatibility Tests
173187
shell: pwsh
174188
run: |
175-
$exePath = "build/generalszh.exe"
189+
$exePath = "build/Release/generalszh.exe"
190+
if (-not (Test-Path $exePath)) {
191+
Write-Host "ERROR: Executable not found at $exePath"
192+
# Fallback: Try searching everywhere under build
193+
$exePaths = Get-ChildItem -Path "build" -Recurse -Filter "generalszh.exe" | Select-Object -ExpandProperty FullName
194+
if ($exePaths) {
195+
Write-Host "Found generalszh.exe at: $($exePaths -join ', ')"
196+
$exePath = $exePaths | Select-Object -First 1
197+
} else {
198+
Write-Host "ERROR: generalszh.exe not found under build/"
199+
exit 1
200+
}
201+
}
176202
$arguments = "-jobs 4 -headless -replay *.rep"
177203
$timeoutSeconds = 10*60
178204
$stdoutPath = "stdout.log"
179205
$stderrPath = "stderr.log"
180206
181-
if (-not (Test-Path $exePath)) {
182-
Write-Host "ERROR: Executable not found at $exePath"
183-
exit 1
184-
}
207+
Write-Host "Using exe path: $exePath"
185208
186-
# Note that the game is a gui application. That means we need to redirect console output to a file
187-
# in order to retrieve it.
188209
# Clean previous logs
189210
Remove-Item $stdoutPath, $stderrPath -ErrorAction SilentlyContinue
190211
@@ -219,24 +240,19 @@ jobs:
219240
220241
# Check exit code
221242
$exitCode = $process.ExitCode
222-
223-
# The above doesn't work on all Windows versions. If not, try this: (see https://stackoverflow.com/a/16018287)
224-
#$process.HasExited | Out-Null # Needs to be called for the command below to work correctly
225-
#$exitCode = $process.GetType().GetField('exitCode', 'NonPublic, Instance').GetValue($process)
226-
#Write-Host "exit code $exitCode"
227-
228243
if ($exitCode -ne 0) {
229244
Write-Host "ERROR: Process failed with exit code $exitCode"
230245
exit $exitCode
231246
}
232247
233248
Write-Host "Success!"
234249
250+
235251
- name: Upload Debug Log
236252
if: always()
237253
uses: actions/upload-artifact@v4
238254
with:
239-
name: Replay-Debug-Log-${{ inputs.preset }}
240-
path: build/DebugLogFile*.txt
255+
name: Replay-Debug-Log-${{ inputs.game }}-${{ inputs.configurePreset }}-${{ inputs.buildPreset }}
256+
path: build/${{ inputs.configurePreset }}/${{ inputs.game }}/*/DebugLogFile*.txt
241257
retention-days: 30
242258
if-no-files-found: ignore

0 commit comments

Comments
 (0)