Skip to content

build(presets): Major CMakePresets overhaul, unify vcpkg, modernize VC6 support #1373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 28 additions & 44 deletions .github/workflows/build-toolchain.yml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug builds are excluded from ci because they are not redistributable

Do I understand correctly that each Job compiles Debug and Release, but only uploads Release binaries? Why don't we upload the debug builds? We don't need to upload the debug c++ runtime.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a comparison of before:
grafik
and after:
grafik
Can we remove this redundant information and clean it up a bit?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the resulting vc6 binary depends on zlib.dll. Before it didn't require any additional dependencies. Is there a way to keep it that way?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will developers now be required to install vcpkg to compile with VC6? If so, please put a instructions in the first post of the PR. (Ideally in the build instructions, but they are sadly in another repo).

Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ on:
required: true
type: string
description: "Game to build (Generals, GeneralsMD)"
preset:
configurePreset:
required: true
type: string
description: "CMake preset"
description: "CMake configure preset"
buildPreset:
required: true
type: string
description: "CMake build preset"
tools:
required: false
default: true
Expand All @@ -25,18 +29,17 @@ on:
default: false
type: boolean
description: "Build extras"

jobs:
build:
name: ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
name: ${{ inputs.game }} ${{ inputs.configurePreset }} ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
runs-on: windows-2022
timeout-minutes: 20
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Cache VC6 Installation
if: startsWith(inputs.preset, 'vc6')
if: startsWith(inputs.buildPreset, 'vc6')
id: cache-vc6
uses: actions/cache@v4
with:
Expand All @@ -47,11 +50,11 @@ jobs:
id: cache-cmake-deps
uses: actions/cache@v4
with:
path: build\${{ inputs.preset }}\_deps
key: cmake-deps-${{ inputs.preset }}-${{ hashFiles('CMakePresets.json','cmake/**/*.cmake','**/CMakeLists.txt') }}
path: build\${{ inputs.buildPreset }}\_deps
key: cmake-deps-${{ inputs.buildPreset }}-${{ hashFiles('CMakePresets.json','cmake/**/*.cmake','**/CMakeLists.txt') }}

- name: Download VC6 Portable from Cloudflare R2
if: ${{ startsWith(inputs.preset, 'vc6') && steps.cache-vc6.outputs.cache-hit != 'true' }}
if: ${{ startsWith(inputs.buildPreset, 'vc6') && steps.cache-vc6.outputs.cache-hit != 'true' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
Expand All @@ -76,39 +79,27 @@ jobs:
Remove-Item VS6_VisualStudio6.7z -Verbose

- name: Set Up VC6 Environment
if: startsWith(inputs.preset, 'vc6')
if: startsWith(inputs.buildPreset, 'vc6')
shell: pwsh
run: |
# Define the base directories as local variables first
$VSCommonDir = "C:\VC6\VC6SP6\Common"
$MSDevDir = "C:\VC6\VC6SP6\Common\msdev98"
$MSVCDir = "C:\VC6\VC6SP6\VC98"
$VcOsDir = "WINNT"

# Set the variables in GitHub environment
"VSCommonDir=$VSCommonDir" >> $env:GITHUB_ENV
"MSDevDir=$MSDevDir" >> $env:GITHUB_ENV
"MSVCDir=$MSVCDir" >> $env:GITHUB_ENV
"VcOsDir=$VcOsDir" >> $env:GITHUB_ENV
"PATH=$MSDevDir\BIN;$MSVCDir\BIN;$VSCommonDir\TOOLS\$VcOsDir;$VSCommonDir\TOOLS;$env:PATH" >> $env:GITHUB_ENV
"INCLUDE=$MSVCDir\ATL\INCLUDE;$MSVCDir\INCLUDE;$MSVCDir\MFC\INCLUDE;$env:INCLUDE" >> $env:GITHUB_ENV
"LIB=$MSVCDir\LIB;$MSVCDir\MFC\LIB;$env:LIB" >> $env:GITHUB_ENV
$VS6_DIR = "C:\VC6\VC6SP6"
"VS6_DIR=$VS6_DIR" >> $env:GITHUB_ENV

- name: Set Up VC2022 Environment
if: startsWith(inputs.preset, 'win32')
if: ${{ !startsWith(inputs.buildPreset, 'vc6') }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x86

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11

- name: Configure ${{ inputs.game }} with CMake Using ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
- name: Configure ${{ inputs.game }} with CMake Using ${{ inputs.configurePreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
shell: pwsh
run: |
$buildFlags = @(
"-DRTS_BUILD_ZEROHOUR=${{ inputs.game == 'GeneralsMD' && 'ON' || 'OFF' }}",
"-DRTS_BUILD_GENERALS=${{ inputs.game == 'Generals' && 'ON' || 'OFF' }}"
"-DRTS_BUILD_ZEROHOUR=${{ inputs.game == 'GeneralsMD' && 'ON' || 'OFF' }}",
"-DRTS_BUILD_GENERALS=${{ inputs.game == 'Generals' && 'ON' || 'OFF' }}"
)

$gamePrefix = "${{ inputs.game == 'Generals' && 'GENERALS' || 'ZEROHOUR' }}"
Expand All @@ -118,33 +109,26 @@ jobs:
$buildFlags += "-DRTS_BUILD_${gamePrefix}_EXTRAS=${{ inputs.extras && 'ON' || 'OFF' }}"

Write-Host "Build flags: $($buildFlags -join ' | ')"
cmake --preset ${{ inputs.configurePreset }} $($buildFlags -join ' ')

cmake --preset ${{ inputs.preset }} $buildFlags

- name: Build ${{ inputs.game }} with CMake Using ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
- name: Build ${{ inputs.game }} with CMake Using ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
shell: pwsh
run: |
cmake --build --preset ${{ inputs.preset }}
cmake --build --preset ${{ inputs.buildPreset }}

- name: Collect ${{ inputs.game }} ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
- name: Collect ${{ inputs.game }} ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
shell: pwsh
run: |
$buildDir = "build\${{ inputs.preset }}"
$buildDir = "build\${{ inputs.configurePreset }}"
$artifactsDir = New-Item -ItemType Directory -Force -Path "$buildDir\${{ inputs.game }}\artifacts" -Verbose

if ("${{ inputs.preset }}" -like "win32*") {
# For win32 preset, look in config-specific subdirectories
$configToUse = if ("${{ inputs.preset }}" -match "debug") { "Debug" } else { "Release" }
$files = Get-ChildItem -Path "$buildDir\Core\$configToUse","$buildDir\${{ inputs.game }}\$configToUse" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
} else {
$files = Get-ChildItem -Path "$buildDir\Core","$buildDir\${{ inputs.game }}" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
}
$configToUse = if ("${{ inputs.buildPreset }}" -match "relwithdebinfo") { "RelWithDebInfo" } elseif ("${{ inputs.buildPreset }}" -match "debug") { "Debug" } else { "Release" }
$files = Get-ChildItem -Path "$buildDir\Core\$configToUse","$buildDir\${{ inputs.game }}\$configToUse" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
$files | Move-Item -Destination $artifactsDir -Verbose -Force

- name: Upload ${{ inputs.game }} ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
- name: Upload ${{ inputs.game }} ${{ inputs.configurePreset }} ${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.game }}-${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
path: build\${{ inputs.preset }}\${{ inputs.game }}\artifacts
name: ${{ inputs.game }}-${{ inputs.configurePreset }}-${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
path: build\${{ inputs.configurePreset }}\${{ inputs.game }}\artifacts
retention-days: 30
if-no-files-found: error
20 changes: 15 additions & 5 deletions .github/workflows/check-replays.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,24 @@ on:
required: true
type: string
description: "Path to folder with replays and maps"
preset:
configurePreset:
required: true
type: string
description: "CMake preset"
buildPreset:
required: true
type: string
tools:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is tools and extras added here?

required: false
type: boolean
default: false
extras:
required: false
type: boolean
default: false

jobs:
build:
name: ${{ inputs.preset }}
name: ${{ inputs.configurePreset }} | ${{ inputs.buildPreset }}
runs-on: windows-latest
timeout-minutes: 15
env:
Expand All @@ -38,7 +48,7 @@ jobs:
- name: Download Game Artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.game }}-${{ inputs.preset }}
name: ${{ inputs.game }}-${{ inputs.configurePreset }}-${{ inputs.buildPreset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
path: build

- name: Cache Game Data
Expand Down Expand Up @@ -236,7 +246,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: Replay-Debug-Log-${{ inputs.preset }}
name: Replay-Debug-Log-${{ inputs.buildPreset }}
path: build/DebugLogFile*.txt
retention-days: 30
if-no-files-found: ignore
105 changes: 35 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,127 +56,92 @@ jobs:
echo "- Shared: ${{ steps.filter.outputs.shared == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY

build-generals:
name: Build Generals${{ matrix.preset && '' }}
name: Build Generals (${{ matrix.configurePreset }} | ${{ matrix.buildPreset }})
needs: detect-changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generals == 'true' || needs.detect-changes.outputs.shared == 'true' }}
strategy:
matrix:
include:
- preset: "vc6"
- configurePreset: "default"
buildPreset: "release"
tools: true
extras: true
- preset: "vc6-profile"
- configurePreset: "dev"
buildPreset: "dev-release"
tools: true
extras: true
- preset: "vc6-debug"
- configurePreset: "vc6"
buildPreset: "vc6-release"
tools: true
extras: true
- preset: "win32"
- configurePreset: "vc6-dev"
buildPreset: "vc6-dev-release"
tools: true
extras: true
- preset: "win32-profile"
tools: true
extras: true
- preset: "win32-debug"
tools: true
extras: true
# vcpkg builds have been disabled for now due to excessive build times of 30 minutes per preset
# - preset: "win32-vcpkg"
# tools: true
# extras: true
# - preset: "win32-vcpkg-profile"
# tools: true
# extras: true
# - preset: "win32-vcpkg-debug"
# tools: true
# extras: true
fail-fast: false
uses: ./.github/workflows/build-toolchain.yml
with:
game: "Generals"
preset: ${{ matrix.preset }}
configurePreset: ${{ matrix.configurePreset }}
buildPreset: ${{ matrix.buildPreset }}
tools: ${{ matrix.tools }}
extras: ${{ matrix.extras }}
secrets: inherit

# Note build-generalsmd is split into two jobs for vc6 and win32 because replaycheck-generalsmd

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why delete this comment?

# only requires the vc6 build and compiling vc6 is much faster than win32
build-generalsmd-vc6:
name: Build GeneralsMD${{ matrix.preset && '' }}
build-generalsmd:
name: Build GeneralsMD (${{ matrix.configurePreset }} | ${{ matrix.buildPreset }})
needs: detect-changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }}
strategy:
matrix:
include:
- preset: "vc6"
- configurePreset: "default"
buildPreset: "release"
tools: true
extras: true
- preset: "vc6-profile"
- configurePreset: "dev"
buildPreset: "dev-release"
tools: true
extras: true
- preset: "vc6-debug"
- configurePreset: "vc6"
buildPreset: "vc6-release"
tools: true
extras: true
- preset: "vc6-releaselog"
- configurePreset: "vc6-dev"
buildPreset: "vc6-dev-release"
tools: true
extras: true
fail-fast: false
uses: ./.github/workflows/build-toolchain.yml
with:
game: "GeneralsMD"
preset: ${{ matrix.preset }}
configurePreset: ${{ matrix.configurePreset }}
buildPreset: ${{ matrix.buildPreset }}
tools: ${{ matrix.tools }}
extras: ${{ matrix.extras }}
secrets: inherit

build-generalsmd-win32:
name: Build GeneralsMD${{ matrix.preset && '' }}
secrets: inherit
build-generalsmd-vc6-log-release:
name: Build GeneralsMD (vc6-log | vc6-log-release)
needs: detect-changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }}
strategy:
matrix:
include:
- preset: "win32"
tools: true
extras: true
- preset: "win32-profile"
tools: true
extras: true
- preset: "win32-debug"
tools: true
extras: true
# vcpkg builds have been disabled for now due to excessive build times of 30 minutes per preset
# - preset: "win32-vcpkg"
# tools: true
# extras: true
# - preset: "win32-vcpkg-profile"
# tools: true
# extras: true
# - preset: "win32-vcpkg-debug"
# tools: true
# extras: true
fail-fast: false
uses: ./.github/workflows/build-toolchain.yml
with:
game: "GeneralsMD"
preset: ${{ matrix.preset }}
tools: ${{ matrix.tools }}
extras: ${{ matrix.extras }}
configurePreset: "vc6-log"
buildPreset: "vc6-log-release"
tools: false
extras: false
secrets: inherit

replaycheck-generalsmd:
name: Replay Check GeneralsMD${{ matrix.preset && '' }}
needs: build-generalsmd-vc6
name: Replay Check
needs: build-generalsmd-vc6-log-release
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }}
strategy:
matrix:
include:
- preset: "vc6+t+e"
- preset: "vc6-releaselog+t+e" # optimized build with logging and crashing enabled should be compatible, so we test that here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not check replays for release and releaselog?
The Release version is the one we'll ship, so I think it doesn't hurt to test it as well.
It might also help track down issues when we know that only one version mismatches or doesn't run.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not that good at ci stuff atm. I just fixed stuff on the cmake side and tried my best to adjust the ci accordingly. Perhaps someone else can do the ci update/fix.

fail-fast: false
uses: ./.github/workflows/check-replays.yml
with:
game: "GeneralsMD"
configurePreset: "vc6-log"
buildPreset: "vc6-log-release"
userdata: "GeneralsReplays/GeneralsZH/1.04"
preset: ${{ matrix.preset }}
secrets: inherit
Loading
Loading