1- name : Build Game with VC6
1+ name : Common Toolchain
2+
3+ permissions :
4+ contents : read
5+ pull-requests : write
26
37on :
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
1123jobs :
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