Skip to content

Commit

Permalink
Replace MSVC with MinGW GCC
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeeynamo committed Oct 6, 2024
1 parent 0050d8b commit e266c85
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/picci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ jobs:
mkdir C:\temp-sdl2
powershell Invoke-WebRequest 'https:/libsdl-org/SDL/releases/download/release-2.28.5/SDL2-devel-2.28.5-VC.zip' -OutFile C:\temp-sdl2\SDL2-devel-2.28.5-VC.zip
7z x C:\temp-sdl2\SDL2-devel-2.28.5-VC.zip -oC:\temp-sdl2
choco install ninja
- name: Clone repo
uses: actions/checkout@v4
with:
Expand All @@ -130,7 +131,7 @@ jobs:
& make -j build_assets SOTNASSETS=$SOTN_ASSETS
- name: Build
run: |
cmake -B ${{github.workspace}}/pc -DCMAKE_BUILD_TYPE=Release -DSDL2_PATH=C:\temp-sdl2\SDL2-2.28.5
cmake -B ${{github.workspace}}/pc -G "Ninja" -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=Release -DSDL2_PATH=C:\temp-sdl2\SDL2-2.28.5
cmake --build ${{github.workspace}}/pc --config Release
build-linux-lle:
Expand Down
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address")
if (NOT WIN32)
# asan is not supported on Windows
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-function-declaration")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-incompatible-pointer-types")
Expand Down
2 changes: 1 addition & 1 deletion include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ typedef unsigned int size_t;
#include <sys/types.h>
#endif

#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__MINGW32__)
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned long long u_long;
Expand Down
2 changes: 1 addition & 1 deletion src/pc/psxsdk/PsyCross/src/gte/psx/inline_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
extern "C" {
#endif

#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__MINGW32__)
typedef unsigned int uint;
typedef unsigned short ushort;
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/pc/psxsdk/libapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ long TestEvent(unsigned long event) {
return 1;
}

#if !defined(_MSC_VER) && !defined(__MINGW32__)
// needs to be disabled on Windows as it overlaps with the kernel32 API:
// https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-entercriticalsection
void EnterCriticalSection(void) { NOT_IMPLEMENTED; }
#endif

void ExitCriticalSection(void) { NOT_IMPLEMENTED; }

Expand Down
2 changes: 1 addition & 1 deletion src/pc/render_gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <log.h>
#include <game.h>
#include <stdlib.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__MINGW32__)
#define SDL_MAIN_HANDLED
#include <SDL.h>
#else
Expand Down
2 changes: 1 addition & 1 deletion src/pc/render_soft.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <log.h>
#include <game.h>
#include <stdlib.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__MINGW32__)
#define SDL_MAIN_HANDLED
#include <SDL.h>
#else
Expand Down
2 changes: 1 addition & 1 deletion src/pc/sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <log.h>
#include <game.h>
#include <stdlib.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__MINGW32__)
#define SDL_MAIN_HANDLED
#include <SDL.h>
#else
Expand Down
2 changes: 1 addition & 1 deletion src/pc/sdl2_macros.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include <game.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__MINGW32__)
#define SDL_MAIN_HANDLED
#include <SDL.h>
#else
Expand Down

0 comments on commit e266c85

Please sign in to comment.