Skip to content
Draft
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,26 @@ jobs:
userdata: "GeneralsReplays/GeneralsZH/1.04"
preset: ${{ matrix.preset }}
secrets: inherit

# Release preset only. mingw-w64-i686-profile is excluded because profiling uses MSVC inline assembly, which GCC does not compile.
build-mingw-generals:
name: Build Generals MinGW-w64
needs: detect-changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generals == 'true' || needs.detect-changes.outputs.shared == 'true' }}
permissions:
contents: read
uses: ./.github/workflows/reusable-build-mingw.yml
with:
game: "Generals"
preset: "mingw-w64-i686"

build-mingw-generalsmd:
name: Build GeneralsMD MinGW-w64
needs: detect-changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }}
permissions:
contents: read
uses: ./.github/workflows/reusable-build-mingw.yml
with:
game: "GeneralsMD"
preset: "mingw-w64-i686"
80 changes: 80 additions & 0 deletions .github/workflows/reusable-build-mingw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build MinGW-w64

# WARNING: Do not declare permissions in this reusable workflow.
# Declare the required permissions in each calling job:
# contents: read - required for all builds.

on:
workflow_call:
inputs:
game:
required: true
type: string
description: "Game to build (Generals or GeneralsMD)"
preset:
required: true
type: string
description: "CMake preset"

jobs:
build:
name: ${{ inputs.preset }}
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install MinGW-w64 Toolchain
run: |
sudo apt-get update
sudo apt-get install -y mingw-w64 cmake

- name: Install widl
run: |
# widl compiles the IDL files. wine64-tools has widl and depends on libwine-dev, which has the system IDL files.
sudo apt-get install -y --no-install-recommends wine64-tools

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Major · Functional Correctness · Quick win

Replace the Wine-dependent widl setup.

This step still installs wine64-tools. On Ubuntu 24.04, that package pulls in libwine-dev and libwine, so both MinGW jobs remain Wine-dependent. Replace it with mingw-w64-tools and update cmake/widl.cmake to find i686-w64-mingw32-widl and the MinGW IDL headers. Changing this install command alone will not complete the switch. (packages.ubuntu.com)


- name: Cache CMake Dependencies
id: cache-cmake-deps
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: build/${{ inputs.preset }}/_deps
key: cmake-deps-mingw-${{ inputs.preset }}-${{ hashFiles('CMakePresets.json','cmake/**/*.cmake','**/CMakeLists.txt') }}

- name: Configure ${{ inputs.game }} with CMake (${{ inputs.preset }})
run: |
# Unset LD_LIBRARY_PATH to avoid library conflicts
unset LD_LIBRARY_PATH

# Configure with appropriate flags
cmake --preset ${{ inputs.preset }} \
-DRTS_BUILD_ZEROHOUR=${{ inputs.game == 'GeneralsMD' && 'ON' || 'OFF' }} \
-DRTS_BUILD_GENERALS=${{ inputs.game == 'Generals' && 'ON' || 'OFF' }} \
-DRTS_BUILD_CORE_TOOLS=OFF \
-DRTS_BUILD_GENERALS_TOOLS=OFF \
-DRTS_BUILD_ZEROHOUR_TOOLS=OFF \
-DRTS_BUILD_CORE_EXTRAS=OFF \
-DRTS_BUILD_GENERALS_EXTRAS=OFF \
-DRTS_BUILD_ZEROHOUR_EXTRAS=OFF

- name: Build ${{ inputs.game }} (${{ inputs.preset }})
run: |
# Build with parallel jobs
cmake --build build/${{ inputs.preset }} --target ${{ inputs.game == 'Generals' && 'g_generals' || 'z_generals' }} -j$(nproc)

- name: Collect ${{ inputs.game }} Artifacts
run: |
ARTIFACTS_DIR="build/${{ inputs.preset }}/${{ inputs.game }}/artifacts"
mkdir -p "$ARTIFACTS_DIR"

# Copy executables, DLLs, and debug symbols
find build/${{ inputs.preset }}/Core build/${{ inputs.preset }}/${{ inputs.game }} -path "$ARTIFACTS_DIR" -prune -o -type f \( -name "*.exe" -o -name "*.dll" -o -name "*.exe.debug" \) -exec cp -t "$ARTIFACTS_DIR" {} +

- name: Upload ${{ inputs.game }} ${{ inputs.preset }} Artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: ${{ inputs.game }}-${{ inputs.preset }}
path: build/${{ inputs.preset }}/${{ inputs.game }}/artifacts
retention-days: 30
if-no-files-found: error
1 change: 1 addition & 0 deletions Core/Libraries/Source/WWVegas/WWDownload/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ target_sources(corei_wwdownload INTERFACE ${WWDOWNLOAD_SRC})

target_link_libraries(corei_wwdownload INTERFACE
core_wwcommon
ws2_32
)
6 changes: 6 additions & 0 deletions Generals/Code/GameEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,12 @@ target_link_libraries(g_gameengine PUBLIC
g_wwvegas
)

# The engine calls functions that are implemented in the engine device, such as OSDisplaySetBusyState.
# Declaring this circular dependency lets linkers that read static libraries in order resolve them.
target_link_libraries(g_gameengine INTERFACE
g_gameenginedevice
)

target_precompile_headers(g_gameengine PRIVATE
[["Precompiled/BasePrecomp.h"]] # Must be first
)
6 changes: 6 additions & 0 deletions GeneralsMD/Code/GameEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,12 @@ target_link_libraries(z_gameengine PUBLIC
z_wwvegas
)

# The engine calls functions that are implemented in the engine device, such as OSDisplaySetBusyState.
# Declaring this circular dependency lets linkers that read static libraries in order resolve them.
target_link_libraries(z_gameengine INTERFACE
z_gameenginedevice
)

target_precompile_headers(z_gameengine PRIVATE
[["Precompiled/BasePrecomp.h"]] # Must be first
)
1 change: 1 addition & 0 deletions cmake/mingw.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if(MINGW)
# Compatibility flags for legacy code
add_compile_options(
-fno-strict-aliasing # Avoid type-punning issues with DX8/COM
-msse2 # GameMath uses SSE intrinsics; some i686 toolchains default to no SSE
)

# MSVC compatibility macros for MinGW
Expand Down
Loading