Skip to content

Commit b7beed8

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 b7beed8

File tree

7 files changed

+176
-476
lines changed

7 files changed

+176
-476
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: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,24 @@ on:
1515
required: true
1616
type: string
1717
description: "Path to folder with replays and maps"
18-
preset:
18+
configurePreset:
1919
required: true
2020
type: string
21-
description: "CMake preset"
21+
buildPreset:
22+
required: true
23+
type: string
24+
tools:
25+
required: false
26+
type: boolean
27+
default: false
28+
extras:
29+
required: false
30+
type: boolean
31+
default: false
2232

2333
jobs:
2434
build:
25-
name: ${{ inputs.preset }}
35+
name: ${{ inputs.configurePreset }} | ${{ inputs.buildPreset }}
2636
runs-on: windows-latest
2737
timeout-minutes: 15
2838
env:
@@ -38,7 +48,7 @@ jobs:
3848
- name: Download Game Artifact
3949
uses: actions/download-artifact@v4
4050
with:
41-
name: ${{ inputs.game }}-${{ inputs.preset }}
51+
name: ${{ inputs.game }}-${{ inputs.configurePreset }}-${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
4252
path: build
4353

4454
- name: Cache Game Data
@@ -236,7 +246,7 @@ jobs:
236246
if: always()
237247
uses: actions/upload-artifact@v4
238248
with:
239-
name: Replay-Debug-Log-${{ inputs.preset }}
249+
name: Replay-Debug-Log-${{ inputs.buildPreset }}
240250
path: build/DebugLogFile*.txt
241251
retention-days: 30
242252
if-no-files-found: ignore

.github/workflows/ci.yml

Lines changed: 35 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -56,127 +56,92 @@ jobs:
5656
echo "- Shared: ${{ steps.filter.outputs.shared == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
5757
5858
build-generals:
59-
name: Build Generals${{ matrix.preset && '' }}
59+
name: Build Generals (${{ matrix.configurePreset }} | ${{ matrix.buildPreset }})
6060
needs: detect-changes
6161
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generals == 'true' || needs.detect-changes.outputs.shared == 'true' }}
6262
strategy:
6363
matrix:
6464
include:
65-
- preset: "vc6"
65+
- configurePreset: "default"
66+
buildPreset: "release"
6667
tools: true
6768
extras: true
68-
- preset: "vc6-profile"
69+
- configurePreset: "dev"
70+
buildPreset: "dev-release"
6971
tools: true
7072
extras: true
71-
- preset: "vc6-debug"
73+
- configurePreset: "vc6"
74+
buildPreset: "vc6-release"
7275
tools: true
7376
extras: true
74-
- preset: "win32"
77+
- configurePreset: "vc6-dev"
78+
buildPreset: "vc6-dev-release"
7579
tools: true
7680
extras: true
77-
- preset: "win32-profile"
78-
tools: true
79-
extras: true
80-
- preset: "win32-debug"
81-
tools: true
82-
extras: true
83-
# vcpkg builds have been disabled for now due to excessive build times of 30 minutes per preset
84-
# - preset: "win32-vcpkg"
85-
# tools: true
86-
# extras: true
87-
# - preset: "win32-vcpkg-profile"
88-
# tools: true
89-
# extras: true
90-
# - preset: "win32-vcpkg-debug"
91-
# tools: true
92-
# extras: true
9381
fail-fast: false
9482
uses: ./.github/workflows/build-toolchain.yml
9583
with:
9684
game: "Generals"
97-
preset: ${{ matrix.preset }}
85+
configurePreset: ${{ matrix.configurePreset }}
86+
buildPreset: ${{ matrix.buildPreset }}
9887
tools: ${{ matrix.tools }}
9988
extras: ${{ matrix.extras }}
10089
secrets: inherit
10190

102-
# Note build-generalsmd is split into two jobs for vc6 and win32 because replaycheck-generalsmd
103-
# only requires the vc6 build and compiling vc6 is much faster than win32
104-
build-generalsmd-vc6:
105-
name: Build GeneralsMD${{ matrix.preset && '' }}
91+
build-generalsmd:
92+
name: Build GeneralsMD (${{ matrix.configurePreset }} | ${{ matrix.buildPreset }})
10693
needs: detect-changes
10794
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }}
10895
strategy:
10996
matrix:
11097
include:
111-
- preset: "vc6"
98+
- configurePreset: "default"
99+
buildPreset: "release"
112100
tools: true
113101
extras: true
114-
- preset: "vc6-profile"
102+
- configurePreset: "dev"
103+
buildPreset: "dev-release"
115104
tools: true
116105
extras: true
117-
- preset: "vc6-debug"
106+
- configurePreset: "vc6"
107+
buildPreset: "vc6-release"
118108
tools: true
119109
extras: true
120-
- preset: "vc6-releaselog"
110+
- configurePreset: "vc6-dev"
111+
buildPreset: "vc6-dev-release"
121112
tools: true
122113
extras: true
123114
fail-fast: false
124115
uses: ./.github/workflows/build-toolchain.yml
125116
with:
126117
game: "GeneralsMD"
127-
preset: ${{ matrix.preset }}
118+
configurePreset: ${{ matrix.configurePreset }}
119+
buildPreset: ${{ matrix.buildPreset }}
128120
tools: ${{ matrix.tools }}
129121
extras: ${{ matrix.extras }}
130-
secrets: inherit
131-
132-
build-generalsmd-win32:
133-
name: Build GeneralsMD${{ matrix.preset && '' }}
122+
secrets: inherit
123+
124+
build-generalsmd-vc6-log-release:
125+
name: Build GeneralsMD (vc6-log | vc6-log-release)
134126
needs: detect-changes
135127
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }}
136-
strategy:
137-
matrix:
138-
include:
139-
- preset: "win32"
140-
tools: true
141-
extras: true
142-
- preset: "win32-profile"
143-
tools: true
144-
extras: true
145-
- preset: "win32-debug"
146-
tools: true
147-
extras: true
148-
# vcpkg builds have been disabled for now due to excessive build times of 30 minutes per preset
149-
# - preset: "win32-vcpkg"
150-
# tools: true
151-
# extras: true
152-
# - preset: "win32-vcpkg-profile"
153-
# tools: true
154-
# extras: true
155-
# - preset: "win32-vcpkg-debug"
156-
# tools: true
157-
# extras: true
158-
fail-fast: false
159128
uses: ./.github/workflows/build-toolchain.yml
160129
with:
161130
game: "GeneralsMD"
162-
preset: ${{ matrix.preset }}
163-
tools: ${{ matrix.tools }}
164-
extras: ${{ matrix.extras }}
131+
configurePreset: "vc6-log"
132+
buildPreset: "vc6-log-release"
133+
tools: false
134+
extras: false
165135
secrets: inherit
166136

167137
replaycheck-generalsmd:
168-
name: Replay Check GeneralsMD${{ matrix.preset && '' }}
169-
needs: build-generalsmd-vc6
138+
name: Replay Check
139+
needs: build-generalsmd-vc6-log-release
170140
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }}
171-
strategy:
172-
matrix:
173-
include:
174-
- preset: "vc6+t+e"
175-
- preset: "vc6-releaselog+t+e" # optimized build with logging and crashing enabled should be compatible, so we test that here.
176-
fail-fast: false
177141
uses: ./.github/workflows/check-replays.yml
178142
with:
179143
game: "GeneralsMD"
144+
configurePreset: "vc6-log"
145+
buildPreset: "vc6-log-release"
180146
userdata: "GeneralsReplays/GeneralsZH/1.04"
181-
preset: ${{ matrix.preset }}
182147
secrets: inherit

0 commit comments

Comments
 (0)