Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
124 changes: 124 additions & 0 deletions .github/workflows/build-games.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Build Games

permissions:
contents: read
pull-requests: write

on:
push:
branches:
- main
paths:
- "Generals/**"
- "GeneralsMD/**"
- "Dependencies/**"
- "cmake/**"
- "CMakeLists.txt"
- "CMakePresets.json"
- ".github/workflows/build-games.yml"
- ".github/workflows/toolchain-common.yml"
pull_request:
branches:
- main
paths:
- "Generals/**"
- "GeneralsMD/**"
- "Dependencies/**"
- "cmake/**"
- "CMakeLists.txt"
- "CMakePresets.json"
- ".github/workflows/build-games.yml"
- ".github/workflows/toolchain-common.yml"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
check-changes:
name: Check Changes
runs-on: ubuntu-latest
outputs:
generals: ${{ steps.filter.outputs.generals }}
generalsmd: ${{ steps.filter.outputs.generalsmd }}
shared: ${{ steps.filter.outputs.shared }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
generals:
- 'Generals/**'
generalsmd:
- 'GeneralsMD/**'
shared:
- 'Dependencies/**'
- 'cmake/**'
- 'CMakeLists.txt'
- 'CMakePresets.json'
- ".github/workflows/build-games.yml"
- '.github/workflows/toolchain-common.yml'

build-generals:
name: Build Generals (${{ matrix.preset }}${{ matrix.tools && '+tools' || '' }})
needs: check-changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-changes.outputs.generals == 'true' || needs.check-changes.outputs.shared == 'true' }}
strategy:
matrix:
include:
- preset: "vc6"
tools: true
- preset: "vc6prof"
tools: true
- preset: "vc6int"
tools: true
- preset: "vc6debug"
tools: true
# - preset: "msvc32" # TODO: Fix preset
# tools: false # TODO: Fix tools
# - preset: "msvc32prof" # TODO: Fix preset
# tools: false # TODO: Fix tools
# - preset: "msvc32int" # TODO: Fix preset
# tools: false # TODO: Fix tools
# - preset: "msvc32debug" # TODO: Fix preset
# tools: false # TODO: Fix tools
fail-fast: false
uses: ./.github/workflows/toolchain-common.yml
with:
game: "Generals"
preset: ${{ matrix.preset }}
tools: ${{ matrix.tools }}
secrets: inherit

build-generalsmd:
name: Build GeneralsMD (${{ matrix.preset }}${{ matrix.tools && '+tools' || '' }})
needs: check-changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-changes.outputs.generalsmd == 'true' || needs.check-changes.outputs.shared == 'true' }}
strategy:
matrix:
include:
- preset: "vc6"
tools: true
- preset: "vc6prof"
tools: true
- preset: "vc6int"
tools: true
- preset: "vc6debug"
tools: true
- preset: "msvc32"
tools: false # TODO: Fix tools
# - preset: "msvc32prof" # TODO: Fix preset
# tools: false # TODO: Fix tools
# - preset: "msvc32int" # TODO: Fix preset
# tools: false # TODO: Fix tools
- preset: "msvc32debug"
tools: false # TODO: Fix tools
fail-fast: false
uses: ./.github/workflows/toolchain-common.yml
with:
game: "GeneralsMD"
preset: ${{ matrix.preset }}
tools: ${{ matrix.tools }}
secrets: inherit
37 changes: 0 additions & 37 deletions .github/workflows/build-vc6-generals.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/build-vc6-zerohour.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
name: Build Game with VC6
name: Common Toolchain

permissions:
contents: read
pull-requests: write

on:
workflow_call:
inputs:
game:
required: true
type: string
description: "Game to build (Generals or GeneralsMD)"
description: "Game to build (Generals, GeneralsMD)"
preset:
required: true
type: string
description: "CMake preset"
tools:
default: false
type: boolean
description: "Build tools"

jobs:
build:
runs-on: windows-latest
timeout-minutes: 15
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache VC6 installation
if: startsWith(inputs.preset, 'vc6')
id: cache-vc6
uses: actions/cache@v4
with:
Expand All @@ -27,13 +40,13 @@ jobs:
id: cache-cmake-deps
uses: actions/cache@v4
with:
path: build\vc6\_deps
key: cmake-deps-${{ hashFiles('cmake/**/*.cmake', '**/CMakeLists.txt') }}
path: build\${{ inputs.preset }}\_deps
key: cmake-deps-${{ inputs.preset }}-${{ hashFiles('cmake/**/*.cmake', '**/CMakeLists.txt') }}
restore-keys: |
cmake-deps-
cmake-deps-${{ inputs.preset }}-

- name: Download VC6 Portable from Cloudflare R2
if: steps.cache-vc6.outputs.cache-hit != 'true'
if: ${{ startsWith(inputs.preset, '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 @@ -56,14 +69,12 @@ jobs:
Write-Host "Extracting archive..."
& 7z x VS6_VisualStudio6.7z -oC:\VC6

Write-Host "Cleaning up downloaded archive"
Remove-Item VS6_VisualStudio6.7z
Remove-Item VS6_VisualStudio6.7z -Verbose

- name: Set up VC6 environment
if: startsWith(inputs.preset, 'vc6')
shell: pwsh
run: |
Write-Host "Setting up environment for using Microsoft Visual C++ tools"

# Define the base directories as local variables first
$VSCommonDir = "C:\VC6\VC6SP6\Common"
$MSDevDir = "C:\VC6\VC6SP6\Common\msdev98"
Expand All @@ -75,54 +86,49 @@ jobs:
"MSDevDir=$MSDevDir" >> $env:GITHUB_ENV
"MSVCDir=$MSVCDir" >> $env:GITHUB_ENV
"VcOsDir=$VcOsDir" >> $env:GITHUB_ENV

# Set PATH
"PATH=$MSDevDir\BIN;$MSVCDir\BIN;$VSCommonDir\TOOLS\$VcOsDir;$VSCommonDir\TOOLS;$env:PATH" >> $env:GITHUB_ENV

# Set INCLUDE
"INCLUDE=$MSVCDir\ATL\INCLUDE;$MSVCDir\INCLUDE;$MSVCDir\MFC\INCLUDE;$env:INCLUDE" >> $env:GITHUB_ENV

# Set LIB
"LIB=$MSVCDir\LIB;$MSVCDir\MFC\LIB;$env:LIB" >> $env:GITHUB_ENV

- name: Build with CMake using VC6 preset
- name: Build ${{ inputs.game }} with CMake using ${{ inputs.preset }} preset
shell: pwsh
run: |
Write-Host "Configuring project with CMake using VC6 preset - building only ${{ inputs.game }}"
Write-Host "Configuring project with CMake using preset: ${{ inputs.game }} (${{ inputs.preset }})"

# Set build flags based on game
# Set build flags based on game and tools
if ("${{ inputs.game }}" -eq "Generals") {
$buildFlags = @("-DGENZH_BUILD_ZEROHOUR=OFF", "-DGENZH_BUILD_GENERALS=ON", "-DGENZH_BUILD_GENERALS_TOOLS=ON")
$buildFlags = @("-DGENZH_BUILD_ZEROHOUR=OFF", "-DGENZH_BUILD_GENERALS=ON")
if ("${{ inputs.tools }}" -eq "true") {
$buildFlags += "-DGENZH_BUILD_GENERALS_TOOLS=ON"
}
} else {
$buildFlags = @("-DGENZH_BUILD_ZEROHOUR=ON", "-DGENZH_BUILD_GENERALS=OFF", "-DGENZH_BUILD_ZEROHOUR_TOOLS=ON")
$buildFlags = @("-DGENZH_BUILD_ZEROHOUR=ON", "-DGENZH_BUILD_GENERALS=OFF")
if ("${{ inputs.tools }}" -eq "true") {
$buildFlags += "-DGENZH_BUILD_ZEROHOUR_TOOLS=ON"
}
}

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

Write-Host "Building project with CMake using VC6 preset - building only ${{ inputs.game }}"
Write-Host "Building project with CMake using preset: ${{ inputs.game }} (${{ inputs.preset }})"

$buildDir = "build/vc6"
"buildDir=$buildDir" >> $env:GITHUB_ENV
$buildDir = "build\${{ inputs.preset }}"

cmake --build $buildDir

Write-Host "Collecting ${{ inputs.game }} tools"
$toolsDir = New-Item -ItemType Directory -Force -Path "$buildDir\${{ inputs.game }}\Tools"
$files = Get-ChildItem -Path "$buildDir\${{ inputs.game }}" -File | Where-Object { ($_.Extension -eq ".exe" -or $_.Extension -eq ".dll") -and $_.Name -ne "generals.exe" }
$files | Move-Item -Destination $toolsDir

- name: Upload ${{ inputs.game }} executable
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.game }}
path: ${{ env.buildDir }}/${{ inputs.game }}/generals.exe
retention-days: 30
if-no-files-found: error
Write-Host "Collecting ${{ inputs.game }} artifacts"
$artifactsDir = New-Item -ItemType Directory -Force -Path "$buildDir\${{ inputs.game }}\artifacts" -Verbose
if ("${{ inputs.preset }}" -like "msvc32*") {
$files = Get-ChildItem -Path "$buildDir\${{ inputs.game }}\Debug" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
} else {
$files = Get-ChildItem -Path "$buildDir\${{ inputs.game }}" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
}
$files | Move-Item -Destination $artifactsDir -Verbose

- name: Upload ${{ inputs.game }} tools
- name: Upload ${{ inputs.game }} (${{ inputs.preset }}) artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.game }}-Tools
path: ${{ env.buildDir }}/${{ inputs.game }}/Tools
name: ${{ inputs.game }}-${{ inputs.preset }}${{ inputs.tools == true && '-tools' || '' }}
path: build\${{ inputs.preset }}\${{ inputs.game }}\artifacts
retention-days: 30
if-no-files-found: error
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ endif()
# Top level project, doesn't really affect anything.
project(genzh LANGUAGES C CXX)

# Print some information
message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
if (DEFINED MSVC_VERSION)
message(STATUS "MSVC_VERSION: ${MSVC_VERSION}")
endif()

# Set variable for VS6 to handle special cases.
if (DEFINED MSVC_VERSION AND MSVC_VERSION LESS 1300)
set(IS_VS6_BUILD TRUE)
else()
set(IS_VS6_BUILD FALSE)
endif()

# Create PDB for Release as long as debug info was generated during compile.
if(MSVC)
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE " /DEBUG /OPT:REF /OPT:ICF")
Expand All @@ -57,6 +71,20 @@ add_subdirectory(Dependencies/Benchmark)
add_subdirectory(Dependencies/SafeDisc)
add_subdirectory(Dependencies/MaxSDK)

if (NOT IS_VS6_BUILD)
# Set C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) # Ensures only ISO features are used

if (MSVC)
# Multithreaded build.
add_compile_options(/MP)
# Enforce strict __cplusplus version
add_compile_options(/Zc:__cplusplus)
endif()
endif()

# Do we want to build extra SDK stuff or just the game binary?
option(GENZH_BUILD_ZEROHOUR "Build Zero Hour code." ON)
option(GENZH_BUILD_GENERALS "Build Generals code." ON)
Expand Down
Loading