From 7bd3281efc71f8928aecd33f32640b718dec33ec Mon Sep 17 00:00:00 2001 From: Randy McShandy Date: Sun, 10 Aug 2025 10:03:58 -0500 Subject: [PATCH] Update windows build script for changes, verify that mingw-gcc build runs on a windows machine. --- CMakeLists.txt | 2 ++ build_win.sh | 17 ++++++++--------- src/structs.c | 5 +++++ src/structs.h | 5 +++++ src/utils.c | 5 +++++ src/utils.h | 17 +++++++++++++++++ 6 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 src/utils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 849b59f..bb8962b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS 1) set(CMAKE_C_COMPILER gcc) FILE(GLOB POSIX_SRC src/*.c src/platforms/platform_posix.c) + +# Win is built with ./build_win.sh FILE(GLOB WINDOWS_SRC src/*.c src/platforms/platform_posix.c) add_executable(posix_BC ${POSIX_SRC}) diff --git a/build_win.sh b/build_win.sh index 49bedfc..bd25e59 100755 --- a/build_win.sh +++ b/build_win.sh @@ -6,23 +6,22 @@ # https://wiki.winehq.org/Debug_Channels # WINEDEBUG=warn+module wine release/win/barrow.exe -CC=x86_64-w64-mingw32-gcc -RAYLIB_DIR=/home/randy/Downloads/raylib-5.0_win64_mingw-w64 -LIBDIR=/usr/x86_64-w64-mingw32 -RAYLIB=$RAYLIB_DIR/lib/libraylib.a -PTH=$LIBDIR/bin/libwinpthread-1.dll -SRCS="./src/*.c ./src/platforms/platform_posix.c" -OUTDIR="./release/win" +export CC=x86_64-w64-mingw32-gcc +export RAYLIBDIR=./external/raylib-5.5_win64_mingw-w64 +export LIBDIR=/usr/x86_64-w64-mingw32 +export PTH=$LIBDIR/bin/libwinpthread-1.dll +export SRCS="./src/*.c ./src/platforms/platform_posix.c" +export OUTDIR="./release/win" rm -rf ./release/win mkdir ./release/win mkdir ./release/win/src mkdir ./release/win/src/shaders -$CC $SRCS $PTH raylib.dll -mthreads -mwindows -lwinmm -o ./release/win/barrow.exe +$CC $RAYLIBDIR/lib/raylib.dll $SRCS $PTH -DMINGW -mthreads -mwindows -lwinmm -I$LIBDIR/include -I$RAYLIBDIR/include -o ./release/win/barrow.exe cp $PTH $OUTDIR/ -cp $RAYLIB_DIR/lib/raylib.dll $OUTDIR/ +cp $RAYLIBDIR/lib/raylib.dll $OUTDIR/ cp -r src/shaders $OUTDIR/src/ cp -r assets $OUTDIR/ cp LICENSES.TXT $OUTDIR/ diff --git a/src/structs.c b/src/structs.c index 620a025..55b7159 100644 --- a/src/structs.c +++ b/src/structs.c @@ -1,4 +1,9 @@ +#ifdef MINGW +#include +#else #include +#endif + #include #include "structs.h" diff --git a/src/structs.h b/src/structs.h index 8ab908a..4836c8c 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,7 +1,12 @@ #ifndef __RD_STRUCTS__ #define __RD_STRUCTS__ +#ifdef MINGW +#include +#else #include +#endif + #define GRID_X 256 #define GRID_Y GRID_X diff --git a/src/utils.c b/src/utils.c index 36c2faf..9b805fc 100644 --- a/src/utils.c +++ b/src/utils.c @@ -265,7 +265,12 @@ void* generate_rd(void* args) int save_game(PlaytimeData playtime) { int success = -1; + +#ifdef MINGW + success = mkdir("./save"); +#else success = mkdir("./save", 0755); +#endif if ((success == 0) || (errno == EEXIST)) { diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 0000000..52c3737 --- /dev/null +++ b/src/utils.h @@ -0,0 +1,17 @@ +#ifndef __UTILS_GUARD__ +#define __UTILS_GUARD__ +#include "structs.h" + +#ifdef MINGW +#include +#define MAX(a,b) max(a,b) +#endif + +bool initialize_generation_info(const IVec2 pgrid_size, const int pworker_count); +bool deinitialize_generation_info(); + +int cleanup_generated_files(); +int delete_save(); + +#endif /* __UTILS_GUARD__ */ + -- 2.49.0