Skip to content

Commit a861bd2

Browse files
committed
Refactor CI, add support for msvc32
1 parent f692775 commit a861bd2

File tree

4 files changed

+171
-115
lines changed

4 files changed

+171
-115
lines changed

.github/workflows/build-games.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Build Games
2+
3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
paths:
12+
- "Generals/**"
13+
- "GeneralsMD/**"
14+
- "Dependencies/**"
15+
- "cmake/**"
16+
- "CMakeLists.txt"
17+
- "CMakePresets.json"
18+
- ".github/workflows/build-games.yml"
19+
- ".github/workflows/toolchain-common.yml"
20+
pull_request:
21+
branches:
22+
- main
23+
paths:
24+
- "Generals/**"
25+
- "GeneralsMD/**"
26+
- "Dependencies/**"
27+
- "cmake/**"
28+
- "CMakeLists.txt"
29+
- "CMakePresets.json"
30+
- ".github/workflows/build-games.yml"
31+
- ".github/workflows/toolchain-common.yml"
32+
workflow_dispatch:
33+
34+
concurrency:
35+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
36+
cancel-in-progress: true
37+
38+
jobs:
39+
check-changes:
40+
name: Check Changes
41+
runs-on: ubuntu-latest
42+
outputs:
43+
generals: ${{ steps.filter.outputs.generals }}
44+
generalsmd: ${{ steps.filter.outputs.generalsmd }}
45+
shared: ${{ steps.filter.outputs.shared }}
46+
steps:
47+
- uses: actions/checkout@v3
48+
- uses: dorny/paths-filter@v2
49+
id: filter
50+
with:
51+
filters: |
52+
generals:
53+
- 'Generals/**'
54+
generalsmd:
55+
- 'GeneralsMD/**'
56+
shared:
57+
- 'Dependencies/**'
58+
- 'cmake/**'
59+
- 'CMakeLists.txt'
60+
- 'CMakePresets.json'
61+
- ".github/workflows/build-games.yml"
62+
- '.github/workflows/toolchain-common.yml'
63+
64+
build-generals:
65+
name: Build Generals (${{ matrix.preset }}${{ matrix.tools && '+tools' || '' }})
66+
needs: check-changes
67+
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-changes.outputs.generals == 'true' || needs.check-changes.outputs.shared == 'true' }}
68+
strategy:
69+
matrix:
70+
include:
71+
- preset: "vc6"
72+
tools: true
73+
- preset: "vc6prof"
74+
tools: true
75+
- preset: "vc6int"
76+
tools: true
77+
- preset: "vc6debug"
78+
tools: true
79+
# - preset: "msvc32" # TODO: Fix preset
80+
# tools: false # TODO: Fix tools
81+
# - preset: "msvc32prof" # TODO: Fix preset
82+
# tools: false # TODO: Fix tools
83+
# - preset: "msvc32int" # TODO: Fix preset
84+
# tools: false # TODO: Fix tools
85+
# - preset: "msvc32debug" # TODO: Fix preset
86+
# tools: false # TODO: Fix tools
87+
fail-fast: false
88+
uses: ./.github/workflows/toolchain-common.yml
89+
with:
90+
game: "Generals"
91+
preset: ${{ matrix.preset }}
92+
tools: ${{ matrix.tools }}
93+
secrets: inherit
94+
95+
build-generalsmd:
96+
name: Build GeneralsMD (${{ matrix.preset }}${{ matrix.tools && '+tools' || '' }})
97+
needs: check-changes
98+
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-changes.outputs.generalsmd == 'true' || needs.check-changes.outputs.shared == 'true' }}
99+
strategy:
100+
matrix:
101+
include:
102+
- preset: "vc6"
103+
tools: true
104+
- preset: "vc6prof"
105+
tools: true
106+
- preset: "vc6int"
107+
tools: true
108+
- preset: "vc6debug"
109+
tools: true
110+
- preset: "msvc32"
111+
tools: false # TODO: Fix tools
112+
# - preset: "msvc32prof" # TODO: Fix preset
113+
# tools: false # TODO: Fix tools
114+
# - preset: "msvc32int" # TODO: Fix preset
115+
# tools: false # TODO: Fix tools
116+
- preset: "msvc32debug"
117+
tools: false # TODO: Fix tools
118+
fail-fast: false
119+
uses: ./.github/workflows/toolchain-common.yml
120+
with:
121+
game: "GeneralsMD"
122+
preset: ${{ matrix.preset }}
123+
tools: ${{ matrix.tools }}
124+
secrets: inherit

.github/workflows/build-vc6-generals.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/build-vc6-zerohour.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
1-
name: Build Game with VC6
1+
name: Common Toolchain
2+
3+
permissions:
4+
contents: read
5+
pull-requests: write
26

37
on:
48
workflow_call:
59
inputs:
610
game:
711
required: true
812
type: string
9-
description: "Game to build (Generals or GeneralsMD)"
13+
description: "Game to build (Generals, GeneralsMD)"
14+
preset:
15+
required: true
16+
type: string
17+
description: "CMake preset"
18+
tools:
19+
default: false
20+
type: boolean
21+
description: "Build tools"
1022

1123
jobs:
1224
build:
1325
runs-on: windows-latest
14-
timeout-minutes: 15
26+
timeout-minutes: 20
1527
steps:
1628
- name: Checkout code
1729
uses: actions/checkout@v4
1830

1931
- name: Cache VC6 installation
32+
if: startsWith(inputs.preset, 'vc6')
2033
id: cache-vc6
2134
uses: actions/cache@v4
2235
with:
@@ -27,13 +40,13 @@ jobs:
2740
id: cache-cmake-deps
2841
uses: actions/cache@v4
2942
with:
30-
path: build\vc6\_deps
31-
key: cmake-deps-${{ hashFiles('cmake/**/*.cmake', '**/CMakeLists.txt') }}
43+
path: build\${{ inputs.preset }}\_deps
44+
key: cmake-deps-${{ inputs.preset }}-${{ hashFiles('cmake/**/*.cmake', '**/CMakeLists.txt') }}
3245
restore-keys: |
33-
cmake-deps-
46+
cmake-deps-${{ inputs.preset }}-
3447
3548
- name: Download VC6 Portable from Cloudflare R2
36-
if: steps.cache-vc6.outputs.cache-hit != 'true'
49+
if: ${{ startsWith(inputs.preset, 'vc6') && steps.cache-vc6.outputs.cache-hit != 'true' }}
3750
env:
3851
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
3952
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
@@ -56,14 +69,12 @@ jobs:
5669
Write-Host "Extracting archive..."
5770
& 7z x VS6_VisualStudio6.7z -oC:\VC6
5871
59-
Write-Host "Cleaning up downloaded archive"
60-
Remove-Item VS6_VisualStudio6.7z
72+
Remove-Item VS6_VisualStudio6.7z -Verbose
6173
6274
- name: Set up VC6 environment
75+
if: startsWith(inputs.preset, 'vc6')
6376
shell: pwsh
6477
run: |
65-
Write-Host "Setting up environment for using Microsoft Visual C++ tools"
66-
6778
# Define the base directories as local variables first
6879
$VSCommonDir = "C:\VC6\VC6SP6\Common"
6980
$MSDevDir = "C:\VC6\VC6SP6\Common\msdev98"
@@ -75,54 +86,49 @@ jobs:
7586
"MSDevDir=$MSDevDir" >> $env:GITHUB_ENV
7687
"MSVCDir=$MSVCDir" >> $env:GITHUB_ENV
7788
"VcOsDir=$VcOsDir" >> $env:GITHUB_ENV
78-
79-
# Set PATH
8089
"PATH=$MSDevDir\BIN;$MSVCDir\BIN;$VSCommonDir\TOOLS\$VcOsDir;$VSCommonDir\TOOLS;$env:PATH" >> $env:GITHUB_ENV
81-
82-
# Set INCLUDE
8390
"INCLUDE=$MSVCDir\ATL\INCLUDE;$MSVCDir\INCLUDE;$MSVCDir\MFC\INCLUDE;$env:INCLUDE" >> $env:GITHUB_ENV
84-
85-
# Set LIB
8691
"LIB=$MSVCDir\LIB;$MSVCDir\MFC\LIB;$env:LIB" >> $env:GITHUB_ENV
8792
88-
- name: Build with CMake using VC6 preset
93+
- name: Build ${{ inputs.game }} with CMake using ${{ inputs.preset }} preset
8994
shell: pwsh
9095
run: |
91-
Write-Host "Configuring project with CMake using VC6 preset - building only ${{ inputs.game }}"
96+
Write-Host "Configuring project with CMake using preset: ${{ inputs.game }} (${{ inputs.preset }})"
9297
93-
# Set build flags based on game
98+
# Set build flags based on game and tools
9499
if ("${{ inputs.game }}" -eq "Generals") {
95-
$buildFlags = @("-DGENZH_BUILD_ZEROHOUR=OFF", "-DGENZH_BUILD_GENERALS=ON", "-DGENZH_BUILD_GENERALS_TOOLS=ON")
100+
$buildFlags = @("-DGENZH_BUILD_ZEROHOUR=OFF", "-DGENZH_BUILD_GENERALS=ON")
101+
if ("${{ inputs.tools }}" -eq "true") {
102+
$buildFlags += "-DGENZH_BUILD_GENERALS_TOOLS=ON"
103+
}
96104
} else {
97-
$buildFlags = @("-DGENZH_BUILD_ZEROHOUR=ON", "-DGENZH_BUILD_GENERALS=OFF", "-DGENZH_BUILD_ZEROHOUR_TOOLS=ON")
105+
$buildFlags = @("-DGENZH_BUILD_ZEROHOUR=ON", "-DGENZH_BUILD_GENERALS=OFF")
106+
if ("${{ inputs.tools }}" -eq "true") {
107+
$buildFlags += "-DGENZH_BUILD_ZEROHOUR_TOOLS=ON"
108+
}
98109
}
99110
100-
cmake --preset vc6 $buildFlags
111+
cmake --preset ${{ inputs.preset }} $buildFlags
101112
102-
Write-Host "Building project with CMake using VC6 preset - building only ${{ inputs.game }}"
113+
Write-Host "Building project with CMake using preset: ${{ inputs.game }} (${{ inputs.preset }})"
103114
104-
$buildDir = "build/vc6"
105-
"buildDir=$buildDir" >> $env:GITHUB_ENV
115+
$buildDir = "build\${{ inputs.preset }}"
106116
107117
cmake --build $buildDir
108118
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
119+
Write-Host "Collecting ${{ inputs.game }} artifacts"
120+
$artifactsDir = New-Item -ItemType Directory -Force -Path "$buildDir\${{ inputs.game }}\artifacts" -Verbose
121+
if ("${{ inputs.preset }}" -like "msvc32*") {
122+
$files = Get-ChildItem -Path "$buildDir\${{ inputs.game }}\Debug" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
123+
} else {
124+
$files = Get-ChildItem -Path "$buildDir\${{ inputs.game }}" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
125+
}
126+
$files | Move-Item -Destination $artifactsDir -Verbose
121127
122-
- name: Upload ${{ inputs.game }} tools
128+
- name: Upload ${{ inputs.game }} (${{ inputs.preset }}) artifact
123129
uses: actions/upload-artifact@v4
124130
with:
125-
name: ${{ inputs.game }}-Tools
126-
path: ${{ env.buildDir }}/${{ inputs.game }}/Tools
131+
name: ${{ inputs.game }}-${{ inputs.preset }}${{ inputs.tools == true && '-tools' || '' }}
132+
path: build\${{ inputs.preset }}\${{ inputs.game }}\artifacts
127133
retention-days: 30
128134
if-no-files-found: error

0 commit comments

Comments
 (0)