initial TDM-GCC switchover

This commit is contained in:
TheTank20
2025-06-04 19:43:22 -04:00
parent 8368b6a6c7
commit 403bcb9dd5
3 changed files with 126 additions and 145 deletions

View File

@@ -23,176 +23,138 @@ name: C/C++ CI (Windows)
on: on:
push: push:
branches: [ "*" ] branches: [ "*" ]
paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip paths-ignore: [ '**.md', 'doc/**', '.idea/**']
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build-32bit: build-tdm64:
runs-on: windows-latest runs-on: windows-latest
env:
OPENSSL_VERSION: "3.1.8"
OPENSSL_PREFIX: "${{ github.workspace }}/openssl-install-64"
steps: steps:
# https://github.com/actions/runner-images/issues/6067#issuecomment-1213069040 - name: Install MSYS2 and dependencies
- name: Install Windows XP Support for Visual Studio uses: msys2/setup-msys2@v2
with:
update: true
install: >-
git
make
perl
mingw-w64-x86_64-gcc
mingw-w64-x86_64-pkg-config
nasm
- name: Cache OpenSSL 64-bit build
id: cache-openssl
uses: actions/cache@v4
with:
path: ${{ env.OPENSSL_PREFIX }}
key: openssl-${{ env.OPENSSL_VERSION }}-msys2-mingw64
- name: Build OpenSSL 64-bit (if not cached)
if: steps.cache-openssl.outputs.cache-hit != 'true'
shell: msys2 {0}
run: | run: |
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" git clone --branch openssl-${OPENSSL_VERSION} https://github.com/openssl/openssl.git
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" cd openssl
$componentsToAdd = @( ./Configure mingw64 no-shared --prefix="${OPENSSL_PREFIX}"
"Microsoft.VisualStudio.Component.WinXP" make -j$(nproc)
) make install
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_}
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
if ($process.ExitCode -eq 0)
{
Write-Host "components have been successfully added"
Get-ChildItem C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.Windows.XPSupport.*
}
else
{
Write-Host "components were not installed"
exit 1
}
- name: Download And Install 32-bit OpenSSL
run: |
$installDir = "$Env:ProgramFiles\OpenSSL"
# Define the URL for the JSON file containing the hashes
$jsonUrl = "https://raw.githubusercontent.com/slproweb/opensslhashes/master/win32_openssl_hashes.json"
# Download the JSON data
$jsonData = Invoke-RestMethod -Uri $jsonUrl
# Initialize variables for the latest version and URL
$latestVersion = "0.0.0"
$latestUrl = ""
# Iterate through the files to find the latest 3.1.x version
foreach ($file in $jsonData.files.PSObject.Properties) {
$details = $file.Value
if ($details.basever -like "3.1*" -and $file.Name -like "Win32OpenSSL*") {
if ([version]$details.basever -gt [version]$latestVersion) {
$latestVersion = $details.basever
$latestUrl = $details.url
}
}
}
# Output the latest version and URL
Write-Output "Latest OpenSSL Win32 3.1.x version: $latestVersion"
Write-Output "Download link: $latestUrl"
$installerURL = $latestURL
$installerName = "Win32OpenSSL.exe"
$installerPath = Join-Path -Path "${env:Temp}" -ChildPath "$installerName"
(New-Object System.Net.WebClient).DownloadFile($installerURL, $installerPath)
Remove-Item "$installDir" -Force -Recurse
$installerArgs = '/silent', '/sp-', '/suppressmsgboxes', "/DIR=`"$installDir`""
Start-Process -FilePath $installerPath -ArgumentList $installerArgs -Wait -PassThru
- name: Checkout Source Tree - name: Checkout Source Tree
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup MSBuild - name: Configure UMSKT (TDM-GCC 64-bit)
uses: microsoft/setup-msbuild@v1 shell: msys2 {0}
run: |
cmake -G "MinGW Makefiles" \
-DCMAKE_C_COMPILER="mingw-w64-x86_64-gcc" \
-DCMAKE_CXX_COMPILER="mingw-w64-x86_64-g++" \
-DOPENSSL_ROOT_DIR="${OPENSSL_PREFIX}" \
-DOPENSSL_INCLUDE_DIR="${OPENSSL_PREFIX}/include" \
-DOPENSSL_CRYPTO_LIBRARY="${OPENSSL_PREFIX}/lib/libcrypto.a" \
-DOPENSSL_SSL_LIBRARY="${OPENSSL_PREFIX}/lib/libssl.a" \
-DCMAKE_C_FLAGS="-m64" \
-DCMAKE_CXX_FLAGS="-m64" \
.
- name: Configure UMSKT - name: Build UMSKT (TDM-GCC 64-bit)
uses: threeal/cmake-action@v1.2.0 shell: msys2 {0}
with: run: make
generator: "Visual Studio 17 2022"
options: CMAKE_SYSTEM_VERSION="5.1.2600"
args: -A "Win32" -T v141_xp
- name: Build UMSKT
working-directory: build
run: msbuild ALL_BUILD.vcxproj /P:Configuration=Release
- name: Upload build artifact - name: Upload build artifact
uses: actions/upload-artifact@v4.6.2 uses: actions/upload-artifact@v4.6.2
with: with:
name: UMSKT-Win32 name: UMSKT-TDM64
path: build/Release path: ./Release/*
build-64bit: build-tdm32:
runs-on: windows-latest runs-on: windows-latest
env:
OPENSSL_VERSION: "3.1.8"
OPENSSL_PREFIX: "${{ github.workspace }}/openssl-install-32"
steps: steps:
- name: Install Windows XP Support for Visual Studio - name: Install MSYS2 and dependencies
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
git
make
perl
mingw-w64-i686-gcc
nasm
- name: Download and Install TDM-GCC-64
run: | run: |
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" Invoke-WebRequest -Uri "https://jmeubank.github.io/tdm-gcc/download/tdm64-gcc-10.3.0.exe" -OutFile "$env:TEMP\tdm64-gcc.exe"
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" Start-Process -FilePath "$env:TEMP\tdm64-gcc.exe" -ArgumentList "/VERYSILENT", "/DIR=C:\TDM-GCC-64" -Wait
$componentsToAdd = @(
"Microsoft.VisualStudio.Component.WinXP" - name: Cache OpenSSL 32-bit build
) id: cache-openssl
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_} uses: actions/cache@v4
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache') with:
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden path: ${{ env.OPENSSL_PREFIX }}
if ($process.ExitCode -eq 0) key: openssl-${{ env.OPENSSL_VERSION }}-msys2-tdmgcc32
{
Write-Host "components have been successfully added" - name: Build OpenSSL 32-bit (if not cached)
Get-ChildItem C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.Windows.XPSupport.* if: steps.cache-openssl.outputs.cache-hit != 'true'
} shell: msys2 {0}
else
{
Write-Host "components were not installed"
exit 1
}
- name: Download And Install 64-bit OpenSSL
run: | run: |
$installDir = "$Env:ProgramFiles\OpenSSL" export PATH="/c/TDM-GCC-64/bin:$PATH"
# Define the URL for the JSON file containing the hashes git clone --branch openssl-${OPENSSL_VERSION} https://github.com/openssl/openssl.git
$jsonUrl = "https://raw.githubusercontent.com/slproweb/opensslhashes/master/win32_openssl_hashes.json" cd openssl
./Configure mingw no-shared --prefix="${OPENSSL_PREFIX}" CFLAGS="-m32" CXXFLAGS="-m32"
# Download the JSON data make -j$(nproc)
$jsonData = Invoke-RestMethod -Uri $jsonUrl make install
# Initialize variables for the latest version and URL
$latestVersion = "0.0.0"
$latestUrl = ""
# Iterate through the files to find the latest 3.1.x version
foreach ($file in $jsonData.files.PSObject.Properties) {
$details = $file.Value
if ($details.basever -like "3.1*" -and $file.Name -like "Win64OpenSSL*") {
if ([version]$details.basever -gt [version]$latestVersion) {
$latestVersion = $details.basever
$latestUrl = $details.url
}
}
}
# Output the latest version and URL
Write-Output "Latest OpenSSL Win64 3.1.x version: $latestVersion"
Write-Output "Download link: $latestUrl"
$installerURL = $latestURL
$installerName = "Win64OpenSSL.exe"
$installerPath = Join-Path -Path "${env:Temp}" -ChildPath "$installerName"
(New-Object System.Net.WebClient).DownloadFile($installerURL, $installerPath)
Remove-Item "$installDir" -Force -Recurse
$installerArgs = '/silent', '/sp-', '/suppressmsgboxes', "/DIR=`"$installDir`""
Start-Process -FilePath $installerPath -ArgumentList $installerArgs -Wait -PassThru
- name: Checkout Source Tree - name: Checkout Source Tree
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup MSBuild - name: Configure UMSKT (TDM-GCC 32-bit)
uses: microsoft/setup-msbuild@v1 shell: msys2 {0}
run: |
export PATH="/c/TDM-GCC-64/bin:$PATH"
cmake -G "MinGW Makefiles" \
-DCMAKE_C_COMPILER="gcc" \
-DCMAKE_CXX_COMPILER="g++" \
-DOPENSSL_ROOT_DIR="${OPENSSL_PREFIX}" \
-DOPENSSL_INCLUDE_DIR="${OPENSSL_PREFIX}/include" \
-DOPENSSL_CRYPTO_LIBRARY="${OPENSSL_PREFIX}/lib/libcrypto.a" \
-DOPENSSL_SSL_LIBRARY="${OPENSSL_PREFIX}/lib/libssl.a" \
-DCMAKE_C_FLAGS="-m32" \
-DCMAKE_CXX_FLAGS="-m32" \
.
- name: Configure UMSKT - name: Build UMSKT (TDM-GCC 32-bit)
uses: threeal/cmake-action@v1.2.0 shell: msys2 {0}
with: run: |
generator: "Visual Studio 17 2022" export PATH="/c/TDM-GCC-64/bin:$PATH"
args: -A "x64" -T "v141_xp" make
- name: Build UMSKT
working-directory: build
run: msbuild ALL_BUILD.vcxproj /P:Configuration=Release
- name: Upload build artifact - name: Upload build artifact
uses: actions/upload-artifact@v4.6.2 uses: actions/upload-artifact@v4.6.2
with: with:
name: UMSKT-Win64 name: UMSKT-TDM32
path: build/Release path: ./Release/*

8
.gitignore vendored
View File

@@ -252,4 +252,10 @@ _deps
CMakeSettings.json CMakeSettings.json
# Visual Studio # Visual Studio
.vs/ .vs/
CPM_modules
CPM_*.cmake
cpm-package-lock.cmake
*.a
*_cmrc*

View File

@@ -21,6 +21,13 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.12) CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
PROJECT(UMSKT) PROJECT(UMSKT)
# Force TDM-GCC on Windows if not using MSVC
if (WIN32 AND NOT MSVC)
set(CMAKE_C_COMPILER "C:/TDM-GCC-64/bin/gcc.exe" CACHE FILEPATH "C Compiler" FORCE)
set(CMAKE_CXX_COMPILER "C:/TDM-GCC-64/bin/g++.exe" CACHE FILEPATH "C++ Compiler" FORCE)
message(STATUS "[UMSKT] Forcing use of TDM-GCC in C:/TDM-GCC-64")
endif()
SET(CMAKE_CXX_STANDARD 17) SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_OSX_SYSROOT "macosx" CACHE PATH "macOS SDK path") SET(CMAKE_OSX_SYSROOT "macosx" CACHE PATH "macOS SDK path")
@@ -207,6 +214,12 @@ ELSE()
TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC ${OPENSSL_INCLUDE_DIR}) TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(umskt _umskt ${OPENSSL_CRYPTO_LIBRARIES} ${ZLIB_LIBRARIES} fmt nlohmann_json::nlohmann_json umskt::rc ${UMSKT_LINK_LIBS}) TARGET_LINK_LIBRARIES(umskt _umskt ${OPENSSL_CRYPTO_LIBRARIES} ${ZLIB_LIBRARIES} fmt nlohmann_json::nlohmann_json umskt::rc ${UMSKT_LINK_LIBS})
TARGET_LINK_DIRECTORIES(umskt PUBLIC ${UMSKT_LINK_DIRS}) TARGET_LINK_DIRECTORIES(umskt PUBLIC ${UMSKT_LINK_DIRS})
# Link required Windows system libraries for OpenSSL
if (WIN32)
target_link_libraries(umskt crypt32 ws2_32)
endif()
IF(MSVC AND MSVC_MSDOS_STUB) IF(MSVC AND MSVC_MSDOS_STUB)
SET_PROPERTY(TARGET umskt APPEND PROPERTY LINK_FLAGS /STUB:${MSVC_MSDOS_STUB}) SET_PROPERTY(TARGET umskt APPEND PROPERTY LINK_FLAGS /STUB:${MSVC_MSDOS_STUB})
ENDIF() ENDIF()