Skip to content

Commit 75f053e

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 line info for fast VC6 release builds - Re-enable debug info for VC6 configurations - Add RelWithDebInfo configs to all presets, including VC6 - 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 fba5df7 commit 75f053e

File tree

6 files changed

+182
-402
lines changed

6 files changed

+182
-402
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 31 additions & 43 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
@@ -28,15 +32,15 @@ on:
2832

2933
jobs:
3034
build:
31-
name: Preset ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
35+
name: Preset ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
3236
runs-on: windows-latest
3337
timeout-minutes: 40
3438
steps:
3539
- name: Checkout Code
3640
uses: actions/checkout@v4
3741

3842
- name: Cache VC6 Installation
39-
if: startsWith(inputs.preset, 'vc6')
43+
if: startsWith(inputs.buildPreset, 'vc6')
4044
id: cache-vc6
4145
uses: actions/cache@v4
4246
with:
@@ -47,11 +51,11 @@ jobs:
4751
id: cache-cmake-deps
4852
uses: actions/cache@v4
4953
with:
50-
path: build\${{ inputs.preset }}\_deps
51-
key: cmake-deps-${{ inputs.preset }}-${{ hashFiles('CMakePresets.json','cmake/**/*.cmake','**/CMakeLists.txt') }}
54+
path: build\${{ inputs.buildPreset }}\_deps
55+
key: cmake-deps-${{ inputs.buildPreset }}-${{ hashFiles('CMakePresets.json','cmake/**/*.cmake','**/CMakeLists.txt') }}
5256

5357
- name: Download VC6 Portable from Cloudflare R2
54-
if: ${{ startsWith(inputs.preset, 'vc6') && steps.cache-vc6.outputs.cache-hit != 'true' }}
58+
if: ${{ startsWith(inputs.buildPreset, 'vc6') && steps.cache-vc6.outputs.cache-hit != 'true' }}
5559
env:
5660
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
5761
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
@@ -66,7 +70,7 @@ jobs:
6670
$fileHash = (Get-FileHash -Path VS6_VisualStudio6.7z -Algorithm SHA256).Hash
6771
Write-Host "Downloaded file SHA256: $fileHash"
6872
Write-Host "Expected file SHA256: $env:EXPECTED_HASH"
69-
if ($hash -ne $env:EXPECTED_HASH) {
73+
if ($fileHash -ne $env:EXPECTED_HASH) {
7074
Write-Error "Hash verification failed! File may be corrupted or tampered with."
7175
exit 1
7276
}
@@ -76,39 +80,27 @@ jobs:
7680
Remove-Item VS6_VisualStudio6.7z -Verbose
7781
7882
- name: Set Up VC6 Environment
79-
if: startsWith(inputs.preset, 'vc6')
83+
if: startsWith(inputs.buildPreset, 'vc6')
8084
shell: pwsh
8185
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
86+
$VS6_DIR = "C:\VC6\VC6SP6"
87+
"VS6_DIR=$VS6_DIR" >> $env:GITHUB_ENV
9688
9789
- name: Set Up VC2022 Environment
98-
if: startsWith(inputs.preset, 'win32')
90+
if: ${{ !startsWith(inputs.buildPreset, 'vc6') }}
9991
uses: ilammy/msvc-dev-cmd@v1
10092
with:
10193
arch: x86
10294

10395
- name: Setup vcpkg
10496
uses: lukka/run-vcpkg@v11
10597

106-
- name: Configure ${{ inputs.game }} with CMake Using ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
98+
- name: Configure ${{ inputs.game }} with CMake Using ${{ inputs.configurePreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
10799
shell: pwsh
108100
run: |
109101
$buildFlags = @(
110-
"-DRTS_BUILD_ZEROHOUR=${{ inputs.game == 'GeneralsMD' && 'ON' || 'OFF' }}",
111-
"-DRTS_BUILD_GENERALS=${{ inputs.game == 'Generals' && 'ON' || 'OFF' }}"
102+
"-DRTS_BUILD_ZEROHOUR=${{ inputs.game == 'GeneralsMD' && 'ON' || 'OFF' }}",
103+
"-DRTS_BUILD_GENERALS=${{ inputs.game == 'Generals' && 'ON' || 'OFF' }}"
112104
)
113105
114106
$gamePrefix = "${{ inputs.game == 'Generals' && 'GENERALS' || 'ZEROHOUR' }}"
@@ -119,32 +111,28 @@ jobs:
119111
120112
Write-Host "Build flags: $($buildFlags -join ' | ')"
121113
122-
cmake --preset ${{ inputs.preset }} $buildFlags
114+
cmake --preset ${{ inputs.configurePreset }} $buildFlags
123115
124-
- name: Build ${{ inputs.game }} with CMake Using ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
116+
- name: Build ${{ inputs.game }} with CMake Using ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
125117
shell: pwsh
126118
run: |
127-
cmake --build --preset ${{ inputs.preset }}
119+
cmake --build --preset ${{ inputs.buildPreset }}
128120
129-
- name: Collect ${{ inputs.game }} ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
121+
- name: Collect ${{ inputs.game }} ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
130122
shell: pwsh
131123
run: |
132-
$buildDir = "build\${{ inputs.preset }}"
124+
$buildDir = "build\${{ inputs.configurePreset }}"
133125
$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-
}
126+
$configToUse = if ("${{ inputs.buildPreset }}" -match "relwithdebinfo") { "RelWithDebInfo" } elseif ("${{ inputs.buildPreset }}" -match "debug") { "Debug" } else { "Release" }
127+
$files = Get-ChildItem -Path "$buildDir\Core\$configToUse","$buildDir\${{ inputs.game }}\$configToUse" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
142128
$files | Move-Item -Destination $artifactsDir -Verbose -Force
143129
144-
- name: Upload ${{ inputs.game }} ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
130+
- name: Upload ${{ inputs.game }} ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
145131
uses: actions/upload-artifact@v4
146132
with:
147-
name: ${{ inputs.game }}-${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
148-
path: build\${{ inputs.preset }}\${{ inputs.game }}\artifacts
133+
name: ${{ inputs.game }}-${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
134+
path: build\${{ inputs.configurePreset }}\${{ inputs.game }}\artifacts
149135
retention-days: 30
150136
if-no-files-found: error
137+
138+

.github/workflows/ci.yml

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,89 +57,99 @@ jobs:
5757
echo "- Shared: ${{ steps.filter.outputs.shared == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
5858
5959
build-generals:
60-
name: Build Generals${{ matrix.preset && '' }}
60+
name: Build Generals (${{ matrix.configurePreset }} | ${{ matrix.buildPreset }})
6161
needs: detect-changes
6262
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generals == 'true' || needs.detect-changes.outputs.shared == 'true' }}
6363
strategy:
6464
matrix:
6565
include:
66-
- preset: "vc6"
66+
- configurePreset: "default"
67+
buildPreset: "release"
6768
tools: true
6869
extras: true
69-
- preset: "vc6-profile"
70+
- configurePreset: "default"
71+
buildPreset: "relwithdebinfo"
7072
tools: true
7173
extras: true
72-
- preset: "vc6-debug"
74+
- configurePreset: "dev"
75+
buildPreset: "dev-release"
7376
tools: true
7477
extras: true
75-
- preset: "win32"
78+
- configurePreset: "dev"
79+
buildPreset: "dev-relwithdebinfo"
7680
tools: true
7781
extras: true
78-
- preset: "win32-profile"
82+
- configurePreset: "vc6"
83+
buildPreset: "vc6-release"
7984
tools: true
8085
extras: true
81-
- preset: "win32-debug"
86+
- configurePreset: "vc6"
87+
buildPreset: "vc6-relwithdebinfo"
88+
tools: true
89+
extras: true
90+
- configurePreset: "vc6-dev"
91+
buildPreset: "vc6-dev-release"
92+
tools: true
93+
extras: true
94+
- configurePreset: "vc6-dev"
95+
buildPreset: "vc6-dev-relwithdebinfo"
8296
tools: true
8397
extras: true
84-
# vcpkg builds have been disabled for now due to excessive build times of 30 minutes per preset
85-
# - preset: "win32-vcpkg"
86-
# tools: true
87-
# extras: true
88-
# - preset: "win32-vcpkg-profile"
89-
# tools: true
90-
# extras: true
91-
# - preset: "win32-vcpkg-debug"
92-
# tools: true
93-
# extras: true
9498
fail-fast: false
9599
uses: ./.github/workflows/build-toolchain.yml
96100
with:
97101
game: "Generals"
98-
preset: ${{ matrix.preset }}
102+
configurePreset: ${{ matrix.configurePreset }}
103+
buildPreset: ${{ matrix.buildPreset }}
99104
tools: ${{ matrix.tools }}
100105
extras: ${{ matrix.extras }}
101106
secrets: inherit
102107

103108
build-generalsmd:
104-
name: Build GeneralsMD${{ matrix.preset && '' }}
109+
name: Build GeneralsMD (${{ matrix.configurePreset }} | ${{ matrix.buildPreset }})
105110
needs: detect-changes
106111
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }}
107112
strategy:
108113
matrix:
109114
include:
110-
- preset: "vc6"
115+
- configurePreset: "default"
116+
buildPreset: "release"
117+
tools: true
118+
extras: true
119+
- configurePreset: "default"
120+
buildPreset: "relwithdebinfo"
121+
tools: true
122+
extras: true
123+
- configurePreset: "dev"
124+
buildPreset: "dev-release"
111125
tools: true
112126
extras: true
113-
- preset: "vc6-profile"
127+
- configurePreset: "dev"
128+
buildPreset: "dev-relwithdebinfo"
114129
tools: true
115130
extras: true
116-
- preset: "vc6-debug"
131+
- configurePreset: "vc6"
132+
buildPreset: "vc6-release"
117133
tools: true
118134
extras: true
119-
- preset: "win32"
135+
- configurePreset: "vc6"
136+
buildPreset: "vc6-relwithdebinfo"
120137
tools: true
121138
extras: true
122-
- preset: "win32-profile"
139+
- configurePreset: "vc6-dev"
140+
buildPreset: "vc6-dev-release"
123141
tools: true
124142
extras: true
125-
- preset: "win32-debug"
143+
- configurePreset: "vc6-dev"
144+
buildPreset: "vc6-dev-relwithdebinfo"
126145
tools: true
127146
extras: true
128-
# vcpkg builds have been disabled for now due to excessive build times of 30 minutes per preset
129-
# - preset: "win32-vcpkg"
130-
# tools: true
131-
# extras: true
132-
# - preset: "win32-vcpkg-profile"
133-
# tools: true
134-
# extras: true
135-
# - preset: "win32-vcpkg-debug"
136-
# tools: true
137-
# extras: true
138147
fail-fast: false
139148
uses: ./.github/workflows/build-toolchain.yml
140149
with:
141150
game: "GeneralsMD"
142-
preset: ${{ matrix.preset }}
151+
configurePreset: ${{ matrix.configurePreset }}
152+
buildPreset: ${{ matrix.buildPreset }}
143153
tools: ${{ matrix.tools }}
144154
extras: ${{ matrix.extras }}
145155
secrets: inherit

0 commit comments

Comments
 (0)