From 4006d9ce01a213c6a5109884a2632e8d6054ab1e Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 19 Jan 2024 13:43:08 +0000 Subject: [PATCH] Work on fixing windows amalgamated build. --- compile_windows.sh | 3 +++ sfw/core/aabb.cpp | 4 ---- sfw/core/sub_process.h | 3 +++ tools/merger/sfw_core.cpp.inl | 7 +++++-- tools/merger/sfw_full.cpp.inl | 22 +++++++++++++++++++--- tools/merger/sfw_full.h.inl | 2 +- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/compile_windows.sh b/compile_windows.sh index c42affb..78b644e 100755 --- a/compile_windows.sh +++ b/compile_windows.sh @@ -48,6 +48,8 @@ ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/thread.cpp -o sfw/core/thread ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/socket.cpp -o sfw/core/socket.o ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/inet_address.cpp -o sfw/core/inet_address.o +ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/sub_process.cpp -o sfw/core/sub_process.o + ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/sfw_core.cpp -o sfw/core/sfw_core.o ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/object/object.cpp -o sfw/object/object.o @@ -116,6 +118,7 @@ ccache g++ -Wall \ sfw/core/pool_vector.o sfw/core/pool_allocator.o sfw/core/mutex.o sfw/core/sfw_time.o \ sfw/core/dir_access.o sfw/core/file_access.o sfw/core/thread.o \ sfw/core/socket.o sfw/core/inet_address.o \ + sfw/core/sub_process.o \ sfw/core/sfw_core.o \ sfw/object/object.o sfw/object/reference.o sfw/object/core_string_names.o \ sfw/object/variant.o sfw/object/variant_op.o sfw/object/psignal.o \ diff --git a/sfw/core/aabb.cpp b/sfw/core/aabb.cpp index 33a10a8..afe7e71 100644 --- a/sfw/core/aabb.cpp +++ b/sfw/core/aabb.cpp @@ -114,10 +114,6 @@ AABB AABB::intersection(const AABB &p_aabb) const { return AABB(min, max - min); } -// MSVC -#undef near -#undef far - bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const { Vector3 c1, c2; Vector3 end = position + size; diff --git a/sfw/core/sub_process.h b/sfw/core/sub_process.h index 0ea2da1..2153294 100644 --- a/sfw/core/sub_process.h +++ b/sfw/core/sub_process.h @@ -25,6 +25,9 @@ #include "core/local_vector.h" //--STRIP +#define WIN32_LEAN_AND_MEAN +#include + typedef struct tagLOGCONTEXTW { WCHAR lcName[40]; UINT lcOptions; diff --git a/tools/merger/sfw_core.cpp.inl b/tools/merger/sfw_core.cpp.inl index e13dc8a..1b48e5b 100644 --- a/tools/merger/sfw_core.cpp.inl +++ b/tools/merger/sfw_core.cpp.inl @@ -7,14 +7,17 @@ #include #include #include -#include #include -#include #include #include #include #include +#if !defined(_WIN64) && !defined(_WIN32) +#include +#include +#endif + #ifndef SFW_H #include "sfw.h" #endif diff --git a/tools/merger/sfw_full.cpp.inl b/tools/merger/sfw_full.cpp.inl index 31cb485..ad72859 100644 --- a/tools/merger/sfw_full.cpp.inl +++ b/tools/merger/sfw_full.cpp.inl @@ -8,14 +8,17 @@ #include #include #include -#include #include -#include #include #include #include #include +#if !defined(_WIN64) && !defined(_WIN32) +#include +#include +#endif + #ifndef SFW_H #ifdef __APPLE__ @@ -44,9 +47,22 @@ #define Font The_Font_I_dont_care #endif +// Note: On Windows we need to make sure that +// GLFW includes it's needed windows headers first, as it has quite a bit of setup. +// Also windows headers can define quite a bit of stuff like far and near macros +// Wee need to make sure it's safe to undo those as soon as possible +// This means that cannot be included in sfw.h if rendering is enabled. +// Also since it pull in lots of defines it probably shouldn't anyway. #undef ONLY_GLAD #include "sfw_3rd.m" +#if defined(_WIN64) || defined(_WIN32) +#undef far +#undef near +#undef FAR +#undef NEAR +#endif + #undef CursorShape #if defined(__linux__) @@ -414,7 +430,7 @@ //#include //#include //--STRIP -{{FILE:sfw/core/sub_process.cpp}} +//{//{FILE:sfw/core/sub_process.cpp}} //--STRIP //#include "core/pool_vector.h" diff --git a/tools/merger/sfw_full.h.inl b/tools/merger/sfw_full.h.inl index bb25bb0..58dd1a0 100644 --- a/tools/merger/sfw_full.h.inl +++ b/tools/merger/sfw_full.h.inl @@ -443,7 +443,7 @@ //Win Only //#include "core/local_vector.h" //--STRIP -{{FILE:sfw/core/sub_process.h}} +//{//{FILE:sfw/core/sub_process.h}} //--STRIP //no includes