Skip to content

Commit 53145f8

Browse files
committed
tentative mingw build
1 parent 2191fa2 commit 53145f8

9 files changed

Lines changed: 164 additions & 35 deletions

File tree

.github/workflows/mingw32.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- "master"
7-
#- "gpu"
7+
- "gpu"
88
# - "develop"
99
tags:
1010
- "v*"

.github/workflows/steam-linux.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build Steam Linux Version
22

33
on:
44
push:
5-
branches: [master, gpu]
5+
branches: [master]
66
pull_request:
77
branches: [master]
88

@@ -24,14 +24,14 @@ jobs:
2424
with:
2525
repository: cfrankb/cs3-data-private
2626
path: data
27-
token: ${{ secrets.CS3_REPO_TOKEN }} # Only if internal access is enabled
27+
token: ${{ secrets.CS3_REPO_TOKEN }}
2828

2929
- name: Checkout Steamworks SDK
3030
uses: actions/checkout@v6
3131
with:
3232
repository: cfrankb/steamworks-sdk-private
3333
path: external/steamworks/sdk
34-
token: ${{ secrets.CS3_REPO_TOKEN }} # Only if internal access is enabled
34+
token: ${{ secrets.CS3_REPO_TOKEN }}
3535

3636
#- name: Configure CMake
3737
# run: |
@@ -50,13 +50,18 @@ jobs:
5050
chmod +x bin/build.sh
5151
bin/build.sh steam_linux
5252
53+
- name: Setup
54+
run: |
55+
mkdir setup
56+
copy build/steam-linux/cs3-runtime setup
57+
copy external/steamworks/sdk/redistributable_bin/linux64/libsteam_api.so setup
58+
copy packages/steam/steam_appid.txt setup
59+
copy -r data setup
60+
5361
- name: Upload Artifact
54-
uses: actions/upload-artifact@v4 # Use @v4 for standard stability
62+
uses: actions/upload-artifact@v4
5563
with:
5664
name: steam-linux-build
5765
path: |
58-
build/steam-linux/cs3-runtime
59-
external/steamworks/sdk/redistributable_bin/linux64/libsteam_api.so
60-
packages/steam/steam_appid.txt
61-
data
66+
setup
6267
retention-days: 7

CMakeLists.txt

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
3636
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
3737

3838
elseif(IS_MINGW)
39+
40+
#set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc-posix)
41+
#set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++-posix)
42+
3943
message(STATUS "Targeting MinGW/Windows")
4044
set(SDL3_DIR "${CMAKE_SOURCE_DIR}/external/SDL3")
4145
set(SDL3_DISABLE_INSTALL ON)
@@ -121,12 +125,27 @@ if(BUILDING_FOR_STEAM)
121125
# Add include directory
122126
target_include_directories(${PROJECT_NAME} PRIVATE "${STEAMWORKS_SDK_PATH}/public")
123127

124-
# Don't forget to link the actual Steam library here too
125-
# target_link_libraries(${PROJECT_NAME} PRIVATE ${STEAM_LIBRARY_PATH})
126-
# Link the Linux 64-bit library
127-
target_link_libraries(${PROJECT_NAME} PRIVATE
128-
"${STEAMWORKS_SDK_PATH}/redistributable_bin/linux64/libsteam_api.so"
129-
)
128+
if(IS_MINGW)
129+
# Define path to Windows 64-bit SDK binaries
130+
set(STEAM_WIN_BIN "${CMAKE_SOURCE_DIR}/external/steamworks/sdk/redistributable_bin/win64")
131+
132+
# Link the Windows library
133+
target_link_libraries(${PROJECT_NAME} PRIVATE "${STEAM_WIN_BIN}/steam_api64.lib")
134+
135+
# Optional: Copy the DLL to the build folder so the game can run
136+
#add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
137+
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
138+
# "${STEAM_WIN_BIN}/steam_api64.dll"
139+
# $<TARGET_FILE_DIR:${PROJECT_NAME}>
140+
#)
141+
else()
142+
# Don't forget to link the actual Steam library here too
143+
# target_link_libraries(${PROJECT_NAME} PRIVATE ${STEAM_LIBRARY_PATH})
144+
# Link the Linux 64-bit library
145+
target_link_libraries(${PROJECT_NAME} PRIVATE
146+
"${STEAMWORKS_SDK_PATH}/redistributable_bin/linux64/libsteam_api.so"
147+
)
148+
endif()
130149

131150
#set(CMAKE_INSTALL_RPATH "$ORIGIN")
132151
#set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)

bin/build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ elif [[ "$1" == "mingw" ]] ; then
3232
BPATH=build/mingw
3333
cmake -DCMAKE_TOOLCHAIN_FILE=packages/cmake/mingw.toolchain.cmake -DIS_MINGW=ON -B ${BPATH} -DCMAKE_BUILD_TYPE=Release
3434
cmake --build ${BPATH} -- VERBOSE=1
35+
elif [[ "$1" == "steam_mingw" ]] ; then
36+
# Export the full paths
37+
export CC=/usr/bin/x86_64-w64-mingw32-gcc-posix
38+
export CXX=/usr/bin/x86_64-w64-mingw32-g++-posix
39+
BPATH=build/steam-mingw
40+
# Run CMake
41+
cmake -DCMAKE_TOOLCHAIN_FILE=packages/cmake/mingw.toolchain.cmake -DIS_MINGW=ON -B ${BPATH} \
42+
-DCMAKE_BUILD_TYPE=Release \
43+
-DCMAKE_SYSTEM_NAME=Windows
44+
cmake --build ${BPATH} -- VERBOSE=1
3545
elif [[ "$1" == "run_ems" ]] ; then
3646
emrun --hostname 0.0.0.0 build/ems/cs3-runtime.html
3747
elif [[ "$1" == "clean" ]] ; then

bin/mingw/steam.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
sudo docker run \
3+
--rm \
4+
--init \
5+
-v "$PWD":/cs3-runtime-sdl \
6+
-v /home:/home \
7+
-v /etc/passwd:/etc/passwd:ro \
8+
-v /etc/group:/etc/group:ro \
9+
-w /cs3-runtime-sdl \
10+
-e HOME="$HOME" \
11+
-u "$(id -u):$(id -g)" \
12+
-v /tmp:/tmp \
13+
-it \
14+
sniper-sdk-mingw \
15+
/bin/bash

packages/bin/makesetup.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ cp -R data/* setup/data
99
cp ${BPATH}/*.exe setup
1010
cp -R techdocs/legal/* setup/legal
1111
cp techdocs/*.md setup/legal
12-
cp LICENSE setup
12+
#cp LICENSE setup
13+
cp techdocs/legal/eula.txt setup/LICENSE
1314
PTHREAD_DLL=$(find /usr/x86_64-w64-mingw32/ | grep libwinpthread-1.dll | head -n 1)
1415
echo PTHREAD_DLL=$PTHREAD_DLL
1516
cp $PTHREAD_DLL setup
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set(CMAKE_SYSTEM_NAME Windows)
2-
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
3-
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
2+
#set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
3+
#set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
44
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
55

66
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
@@ -9,10 +9,14 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
99
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
1010

1111

12-
set(CMAKE_SYSTEM_NAME Windows)
13-
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
14-
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
15-
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
16-
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
17-
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
18-
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
12+
#set(CMAKE_SYSTEM_NAME Windows)
13+
#set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
14+
#set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
15+
#set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
16+
#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
17+
#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
18+
#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
19+
20+
# Use absolute paths
21+
set(CMAKE_C_COMPILER /usr/bin/x86_64-w64-mingw32-gcc-posix)
22+
set(CMAKE_CXX_COMPILER /usr/bin/x86_64-w64-mingw32-g++-posix)

src/main.cpp

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,47 @@ namespace fs = std::filesystem;
188188

189189
std::string GetAppDataPath()
190190
{
191-
PWSTR path = NULL;
192-
// Get the roaming AppData folder (C:\Users\Name\AppData\Roaming)
193-
HRESULT hr = SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &path);
191+
std::string result = "";
192+
193+
// Check if we are using a modern compiler/SDK that supports the new API
194+
// MinGW usually needs _WIN32_WINNT >= 0x0600 for SHGetKnownFolderPath
194195

195-
if (SUCCEEDED(hr))
196+
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
197+
PWSTR path = NULL;
198+
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &path)))
196199
{
197-
// Convert PWSTR (wchar_t*) to std::string
200+
// Convert Wide string to UTF-8/string (simplified)
198201
std::wstring ws(path);
199-
std::string s(ws.begin(), ws.end());
200-
CoTaskMemFree(path); // Free the memory allocated by SHGetKnownFolderPath
201-
return s;
202+
result = std::string(ws.begin(), ws.end());
203+
CoTaskMemFree(path);
202204
}
203-
CoTaskMemFree(path);
204-
return "";
205+
#else
206+
// Fallback for MinGW or older Windows targets
207+
char path[MAX_PATH];
208+
if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, path)))
209+
{
210+
result = std::string(path);
211+
}
212+
#endif
213+
214+
return result;
215+
216+
/*/
217+
PWSTR path = NULL;
218+
// Get the roaming AppData folder (C:\Users\Name\AppData\Roaming)
219+
HRESULT hr = SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &path);
220+
221+
if (SUCCEEDED(hr))
222+
{
223+
// Convert PWSTR (wchar_t*) to std::string
224+
std::wstring ws(path);
225+
std::string s(ws.begin(), ws.end());
226+
CoTaskMemFree(path); // Free the memory allocated by SHGetKnownFolderPath
227+
return s;
228+
}
229+
CoTaskMemFree(path);
230+
return "";
231+
*/
205232
}
206233

207234
bool makePath(const std::string &path)

techdocs/legal/eula.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
END USER LICENSE AGREEMENT (EULA)
2+
3+
Last Updated: April 6, 2026
4+
5+
Please read this End User License Agreement (“Agreement”) carefully before clicking the "I Agree" button, downloading, or using [INSERT GAME NAME] (“the Game”). By downloading or using the Game, you are agreeing to be bound by the terms and conditions of this Agreement.
6+
1. THE LICENSE
7+
8+
[INSERT STUDIO/DEVELOPER NAME] (“Developer”) grants you a personal, non-exclusive, non-transferable, limited license to install and use the Game for your personal, non-commercial entertainment purposes strictly in accordance with the terms of this Agreement and the Steam Subscriber Agreement.
9+
2. RESTRICTIONS
10+
11+
You agree not to, and you will not permit others to:
12+
13+
Reverse Engineer: Decompile, disassemble, or attempt to derive the source code of the Game.
14+
15+
Commercial Use: Use the Game for any commercial purpose (e.g., "pay-to-play" gaming centers) without a separate license.
16+
17+
Distribution: Copy, rent, lease, lend, sell, or sublicense the Game to any third party.
18+
19+
Hacking/Cheating: Create, use, or distribute "cheats," "hacks," "mods," or "trainers" that interfere with the Game's intended balance or online functionality.
20+
21+
3. OWNERSHIP
22+
23+
The Game, including all code, characters, story, assets, and music, is the property of the Developer and is protected by copyright and intellectual property laws. This Agreement is a license, not a sale; you do not own the Game itself, but rather a right to access it.
24+
4. USER-GENERATED CONTENT (UGC)
25+
26+
If the Game allows you to create or upload content (such as through the Steam Workshop):
27+
28+
You retain ownership of your original ideas.
29+
30+
You grant the Developer a perpetual, irrevocable, worldwide, royalty-free license to use, copy, modify, and display that content in connection with the Game.
31+
32+
5. PRIVACY AND DATA
33+
34+
The Game may collect certain technical information (IP addresses, hardware specs, gameplay statistics) to improve performance and security. All data handling is governed by our Privacy Policy found at [INSERT URL].
35+
6. STEAM PLATFORM
36+
37+
You acknowledge that the Game is distributed through Steam, operated by Valve Corporation. Your use of the Game is also subject to the Steam Subscriber Agreement (SSA). In the event of a conflict between this EULA and the SSA, the SSA shall take precedence.
38+
7. TERMINATION
39+
40+
This Agreement is effective until terminated by you or the Developer. Your rights under this license will terminate automatically without notice if you fail to comply with any terms of this Agreement. Upon termination, you must cease all use of the Game and delete all copies.
41+
8. LIMITATION OF LIABILITY
42+
43+
To the maximum extent permitted by law, the Game is provided "AS IS" without warranty of any kind. The Developer shall not be liable for any special, incidental, or consequential damages resulting from possession, use, or malfunction of the Game.
44+
9. CONTACT INFORMATION
45+
46+
If you have any questions about this Agreement, please contact us at:
47+
Email: [INSERT CONTACT EMAIL]
48+
Website: [INSERT WEBSITE]

0 commit comments

Comments
 (0)