From cbdedb576ebfead7d93b504059ce31fd0a4bbcbf Mon Sep 17 00:00:00 2001 From: hat_kid Date: Fri, 16 Aug 2024 04:18:28 +0700 Subject: [PATCH 1/3] deps(windows): Build SDL3 and satellite libraries --- windows/Makefile | 139 ++++++++++++++++++----------------------------- 1 file changed, 54 insertions(+), 85 deletions(-) diff --git a/windows/Makefile b/windows/Makefile index 576e3a828..46be871ad 100755 --- a/windows/Makefile +++ b/windows/Makefile @@ -11,8 +11,8 @@ RB_PREFIX := $(shell ruby -e "case '$(ARCH)'; \ end \ ") SDL_FLAGS := ${SDL_FLAGS} -SDL2_IMAGE_FLAGS := ${SDL2_IMAGE_FLAGS} -SDL2_TTF_FLAGS := ${SDL2_TTF_FLAGS} +SDL3_IMAGE_FLAGS := ${SDL3_IMAGE_FLAGS} +SDL3_TTF_FLAGS := ${SDL3_TTF_FLAGS} OPENAL_FLAGS := ${OPENAL_FLAGS} OPENSSL_FLAGS := mingw64 ${OPENSSL_FLAGS} RUBY_FLAGS := ${RUBY_FLAGS} @@ -175,94 +175,78 @@ $(DOWNLOADS)/uchardet/cmakebuild/Makefile: $(DOWNLOADS)/uchardet/CMakeLists.txt $(DOWNLOADS)/uchardet/CMakeLists.txt: $(CLONE) $(GITHUB)/mkxp-z/uchardet $(DOWNLOADS)/uchardet -# SDL2 -sdl2: init_dirs $(LIBDIR)/libSDL2.a +# SDL3 +sdl3: init_dirs $(LIBDIR)/libSDL3.a -$(LIBDIR)/libSDL2.a: $(DOWNLOADS)/sdl2/cmakebuild/Makefile - cd $(DOWNLOADS)/sdl2/cmakebuild; \ +$(LIBDIR)/libSDL3.a: $(DOWNLOADS)/sdl3/cmakebuild/Makefile + cd $(DOWNLOADS)/sdl3/cmakebuild; \ make -j$(NPROC); make install -$(DOWNLOADS)/sdl2/cmakebuild/Makefile: $(DOWNLOADS)/sdl2/CMakeLists.txt - cd $(DOWNLOADS)/sdl2; \ +$(DOWNLOADS)/sdl3/cmakebuild/Makefile: $(DOWNLOADS)/sdl3/CMakeLists.txt + cd $(DOWNLOADS)/sdl3; \ mkdir cmakebuild; cd cmakebuild; \ - $(CMAKE) -DBUILD_SHARED_LIBS=no + $(CMAKE) -DSDL_STATIC=YES -DSDL_SHARED=NO -DSDL_OPENGLES=NO -$(DOWNLOADS)/sdl2/CMakeLists.txt: - $(CLONE) $(GITHUB)/Astrabit-ST/SDL $(DOWNLOADS)/sdl2 -b mkxp-z-2.28.1 +$(DOWNLOADS)/sdl3/CMakeLists.txt: + $(CLONE) $(GITHUB)/libsdl-org/SDL -b main --no-checkout $(DOWNLOADS)/sdl3 + cd $(DOWNLOADS)/sdl3; git checkout f95027e3d7a692b9324cfa53f371f8cfdb2575e3 # SDL_image -sdl2image: init_dirs sdl2 $(LIBDIR)/libSDL2_image.a +sdl3image: init_dirs sdl3 $(LIBDIR)/libSDL3_image.a -$(LIBDIR)/libSDL2_image.a: $(DOWNLOADS)/sdl2_image/cmakebuild/Makefile - cd $(DOWNLOADS)/sdl2_image/cmakebuild; \ +$(LIBDIR)/libSDL3_image.a: $(DOWNLOADS)/sdl3_image/cmakebuild/Makefile + cd $(DOWNLOADS)/sdl3_image/cmakebuild; \ make -j$(NPROC); make install -$(DOWNLOADS)/sdl2_image/cmakebuild/Makefile: $(DOWNLOADS)/sdl2_image/CMakeLists.txt - cd $(DOWNLOADS)/sdl2_image; mkdir -p cmakebuild; cd cmakebuild; \ +$(DOWNLOADS)/sdl3_image/cmakebuild/Makefile: $(DOWNLOADS)/sdl3_image/CMakeLists.txt + cd $(DOWNLOADS)/sdl3_image; mkdir -p cmakebuild; cd cmakebuild; \ $(CMAKE) \ -DBUILD_SHARED_LIBS=no \ - -DSDL2IMAGE_JPG_SAVE=yes \ - -DSDL2IMAGE_PNG_SAVE=yes \ - -DSDL2IMAGE_PNG_SHARED=no \ - -DSDL2IMAGE_JPG_SHARED=no \ - -DSDL2IMAGE_JXL=yes \ - -DSDL2IMAGE_JXL_SHARED=no \ - -DSDL2IMAGE_VENDORED=yes - -$(DOWNLOADS)/sdl2_image/CMakeLists.txt: - $(CLONE) $(GITHUB)/mkxp-z/SDL_image $(DOWNLOADS)/sdl2_image -b mkxp-z; \ - cd $(DOWNLOADS)/sdl2_image; \ - ./external/download.sh - -# SDL_sound -sdlsound: init_dirs sdl2 libogg libvorbis $(LIBDIR)/libSDL2_sound.a - -$(LIBDIR)/libSDL2_sound.a: $(DOWNLOADS)/sdl_sound/cmakebuild/Makefile - cd $(DOWNLOADS)/sdl_sound/cmakebuild; \ + -DSDL3IMAGE_JPG_SAVE=yes \ + -DSDL3IMAGE_PNG_SAVE=yes \ + -DSDL3IMAGE_PNG_SHARED=no \ + -DSDL3IMAGE_JPG_SHARED=no \ + -DSDL3IMAGE_JXL=no \ + -DSDL3IMAGE_JXL_SHARED=no \ + -DSDL3IMAGE_AVIF=no \ + -DSDL3IMAGE_VENDORED=yes + +$(DOWNLOADS)/sdl3_image/CMakeLists.txt: + $(CLONE) $(GITHUB)/libsdl-org/SDL_image -b main --no-checkout $(DOWNLOADS)/sdl3_image + cd $(DOWNLOADS)/sdl3_image; git checkout 5c5051cb3e594cf301e76f6e6b55df1c6b54c04b + cd $(DOWNLOADS)/sdl3_image/external; ./download.sh + +# SDL3_sound +sdl3sound: init_dirs sdl3 libogg libvorbis $(LIBDIR)/libSDL3_sound.a + +$(LIBDIR)/libSDL3_sound.a: $(DOWNLOADS)/sdl3_sound/cmakebuild/Makefile + cd $(DOWNLOADS)/sdl3_sound/cmakebuild; \ make -j$(NPROC); make install -$(DOWNLOADS)/sdl_sound/cmakebuild/Makefile: $(DOWNLOADS)/sdl_sound/CMakeLists.txt - cd $(DOWNLOADS)/sdl_sound; mkdir -p cmakebuild; cd cmakebuild; \ +$(DOWNLOADS)/sdl3_sound/cmakebuild/Makefile: $(DOWNLOADS)/sdl3_sound/CMakeLists.txt + cd $(DOWNLOADS)/sdl3_sound; mkdir -p cmakebuild; cd cmakebuild; \ $(CMAKE) \ -DSDLSOUND_BUILD_SHARED=false \ -DSDLSOUND_BUILD_TEST=false -$(DOWNLOADS)/sdl_sound/CMakeLists.txt: - $(CLONE) $(GITHUB)/mkxp-z/SDL_sound $(DOWNLOADS)/sdl_sound -b git +$(DOWNLOADS)/sdl3_sound/CMakeLists.txt: + $(CLONE) $(GITHUB)/Astrabit-ST/SDL3_sound $(DOWNLOADS)/sdl3_sound -# SDL2 (ttf) -sdl2ttf: init_dirs sdl2 freetype $(LIBDIR)/libSDL2_ttf.a +# SDL3 (ttf) +sdl3ttf: init_dirs sdl3 $(LIBDIR)/libSDL3_ttf.a -$(LIBDIR)/libSDL2_ttf.a: $(DOWNLOADS)/sdl2_ttf/Makefile - cd $(DOWNLOADS)/sdl2_ttf; \ +$(LIBDIR)/libSDL3_ttf.a: $(DOWNLOADS)/sdl3_ttf/cmakebuild/Makefile + cd $(DOWNLOADS)/sdl3_ttf/cmakebuild; \ make -j$(NPROC); make install -$(DOWNLOADS)/sdl2_ttf/Makefile: $(DOWNLOADS)/sdl2_ttf/configure - cd $(DOWNLOADS)/sdl2_ttf; \ - $(CONFIGURE) --enable-static=true --enable-shared=false $(SDL2_TTF_FLAGS) - -$(DOWNLOADS)/sdl2_ttf/configure: $(DOWNLOADS)/sdl2_ttf/autogen.sh - cd $(DOWNLOADS)/sdl2_ttf; ./autogen.sh - -$(DOWNLOADS)/sdl2_ttf/autogen.sh: - $(CLONE) $(GITHUB)/mkxp-z/SDL_ttf $(DOWNLOADS)/sdl2_ttf -b mkxp-z - -# Freetype (dependency of SDL2_ttf) -freetype: init_dirs $(LIBDIR)/libfreetype.a - -$(LIBDIR)/libfreetype.a: $(DOWNLOADS)/freetype/Makefile - cd $(DOWNLOADS)/freetype; \ - make -j$(NPROC); make install - -$(DOWNLOADS)/freetype/Makefile: $(DOWNLOADS)/freetype/configure - cd $(DOWNLOADS)/freetype; \ - $(CONFIGURE) --enable-static=true --enable-shared=false +$(DOWNLOADS)/sdl3_ttf/cmakebuild/Makefile: $(DOWNLOADS)/sdl3_ttf/CMakeLists.txt + cd $(DOWNLOADS)/sdl3_ttf; mkdir cmakebuild; cd cmakebuild; \ + $(CMAKE) -DBUILD_SHARED_LIBS=no -DSDL3TTF_VENDORED=ON -$(DOWNLOADS)/freetype/configure: $(DOWNLOADS)/freetype/autogen.sh - cd $(DOWNLOADS)/freetype; ./autogen.sh - -$(DOWNLOADS)/freetype/autogen.sh: - $(CLONE) $(GITHUB)/mkxp-z/freetype2 $(DOWNLOADS)/freetype +$(DOWNLOADS)/sdl3_ttf/CMakeLists.txt: + $(CLONE) $(GITHUB)/libsdl-org/SDL_ttf -b main --no-checkout $(DOWNLOADS)/sdl3_ttf + cd $(DOWNLOADS)/sdl3_ttf; git checkout 22347419ee08e49d77411c680f15e314ef870ab7 + cd $(DOWNLOADS)/sdl3_ttf/external; ./download.sh # OpenAL openal: init_dirs libogg $(LIBDIR)/libOpenAL32.a @@ -326,26 +310,11 @@ $(DOWNLOADS)/ruby/configure: $(DOWNLOADS)/ruby/configure.ac $(DOWNLOADS)/ruby/configure.ac: $(CLONE) $(GITHUB)/mkxp-z/ruby $(DOWNLOADS)/ruby --single-branch --branch mkxp-z-3.1.3 --depth 1; -sdl3: init_dirs $(LIBDIR)/libSDL3.a - -$(LIBDIR)/libSDL3.a: $(DOWNLOADS)/sdl3/cmakebuild/Makefile - cd $(DOWNLOADS)/sdl3/cmakebuild; \ - $(MAKE) -j$(NPROC); $(MAKE) install - -$(DOWNLOADS)/sdl3/cmakebuild/Makefile: $(DOWNLOADS)/sdl3/CMakeLists.txt - cd $(DOWNLOADS)/sdl3; mkdir -p cmakebuild; cd cmakebuild; \ - $(CMAKE) -DSDL_STATIC=1 -DSDL_SHARED=0 - -$(DOWNLOADS)/sdl3/CMakeLists.txt: - $(CLONE) --no-checkout $(GITHUB)/libsdl-org/SDL $(DOWNLOADS)/sdl3 -# Commit made Aug 14 2024 - cd $(DOWNLOADS)/sdl3; git checkout d60e6e25581731f5f0dddd46b45132ba991ff1d6 - libzmq: init_dirs $(LIBDIR)/libzmq.a $(LIBDIR)/libzmq.a: $(DOWNLOADS)/libzmq/cmakebuild/Makefile cd $(DOWNLOADS)/libzmq/cmakebuild; \ - $(MAKE) -j$(NPROC); $(MAKE) install + make -j$(NPROC); make install $(DOWNLOADS)/libzmq/cmakebuild/Makefile: $(DOWNLOADS)/libzmq/CMakeLists.txt cd $(DOWNLOADS)/libzmq; mkdir -p cmakebuild; cd cmakebuild; \ @@ -358,7 +327,7 @@ cppzmq: init_dirs libzmq $(INCLUDEDIR)/zmq.hpp $(INCLUDEDIR)/zmq.hpp: $(DOWNLOADS)/cppzmq/cmakebuild/Makefile cd $(DOWNLOADS)/cppzmq/cmakebuild; \ - $(MAKE) -j$(NPROC); $(MAKE) install + make -j$(NPROC); make install $(DOWNLOADS)/cppzmq/cmakebuild/Makefile: $(DOWNLOADS)/cppzmq/CMakeLists.txt cd $(DOWNLOADS)/cppzmq; mkdir -p cmakebuild; cd cmakebuild; \ @@ -376,5 +345,5 @@ powerwash: clean-downloads clean-downloads: -rm -rf downloads -deps-core: libtheora libvorbis pixman libpng physfs sdl2 sdl2image sdlsound sdl2ttf openal openssl fluidsynth uchardet cppzmq sdl3 +deps-core: libtheora libvorbis pixman libpng physfs sdl3 sdl3image sdl3sound sdl3ttf openal openssl fluidsynth uchardet cppzmq everything: deps-core ruby From e80264ea2c9f132e5d6abe8270372f945405125b Mon Sep 17 00:00:00 2001 From: hat_kid Date: Fri, 16 Aug 2024 04:19:51 +0700 Subject: [PATCH 2/3] chore: Remove `SDL_syswm.h` includes https://github.com/libsdl-org/SDL/commit/fd4a2cce9effc2cc5a69c4bd6fdc4622794ebf23 --- binding/modshot-window-binding.cpp | 1 - macos/views/TouchBar.mm | 1 - src/filesystem/filesystemImplApple.mm | 1 - src/oneshot/oneshot.cpp | 1 - 4 files changed, 4 deletions(-) diff --git a/binding/modshot-window-binding.cpp b/binding/modshot-window-binding.cpp index 73111066f..f52ed7c4d 100644 --- a/binding/modshot-window-binding.cpp +++ b/binding/modshot-window-binding.cpp @@ -5,7 +5,6 @@ #include #include -//#include #ifdef _WIN32 #include diff --git a/macos/views/TouchBar.mm b/macos/views/TouchBar.mm index a92a9e135..bc0be82d5 100644 --- a/macos/views/TouchBar.mm +++ b/macos/views/TouchBar.mm @@ -6,7 +6,6 @@ // #import -#import #import #import #import diff --git a/src/filesystem/filesystemImplApple.mm b/src/filesystem/filesystemImplApple.mm index 9f49762e5..1bc8587e7 100644 --- a/src/filesystem/filesystemImplApple.mm +++ b/src/filesystem/filesystemImplApple.mm @@ -6,7 +6,6 @@ // #import -#import #import diff --git a/src/oneshot/oneshot.cpp b/src/oneshot/oneshot.cpp index 0eb140d53..1e9079092 100644 --- a/src/oneshot/oneshot.cpp +++ b/src/oneshot/oneshot.cpp @@ -22,7 +22,6 @@ #include #include #include - #include #elif defined SDL_PLATFORM_APPLE || __linux__ #include #include From 5321ba3d149eb530334bfae35851e545125ac73b Mon Sep 17 00:00:00 2001 From: hat_kid Date: Fri, 16 Aug 2024 04:22:35 +0700 Subject: [PATCH 3/3] chore: Revert platform-specific definition names --- binding/binding-mri.cpp | 12 ++++++------ binding/miniffi.cpp | 2 +- binding/miniffi.h | 2 +- binding/oneshot-niko-binding.cpp | 8 ++++---- binding/oneshot-wallpaper-binding.cpp | 6 +++--- src/config.cpp | 8 ++++---- src/filesystem/filesystemImpl.cpp | 2 +- src/net/httplib.h | 8 ++++---- src/oneshot/oneshot.cpp | 4 ++-- src/system/system.h | 4 ++-- src/system/systemImpl.cpp | 8 ++++---- src/util/string-util.h | 2 +- src/util/win-consoleutils.cpp | 4 ++-- 13 files changed, 35 insertions(+), 35 deletions(-) diff --git a/binding/binding-mri.cpp b/binding/binding-mri.cpp index 4360de515..7ca1a87a3 100644 --- a/binding/binding-mri.cpp +++ b/binding/binding-mri.cpp @@ -52,7 +52,7 @@ extern "C" { #endif } -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ #include "binding-mri-win32.h" #endif @@ -113,7 +113,7 @@ void oneshotSteamBindingInit(); void oneshotJournalBindingInit(); void oneshotNikoBindingInit(); void oneshotWallpaperBindingInit(); -#ifdef SDL_PLATFORM_LINUX +#ifdef __LINUX__ void oneshotWallpaperBindingTerminate(); #endif @@ -335,7 +335,7 @@ static void mriBindingInit() { // Set $stdout and its ilk accordingly on Windows // I regret teaching you that word -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ if (shState->config().winConsole) configureWindowsStreams(); #endif @@ -521,7 +521,7 @@ RB_METHOD(mkxpUserName) { // Using the Windows API isn't working with usernames that involve Unicode // characters for some dumb reason -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ VALUE env = rb_const_get(rb_mKernel, rb_intern("ENV")); return rb_funcall(env, rb_intern("[]"), 1, rb_str_new_cstr("USERNAME")); #else @@ -677,7 +677,7 @@ RB_METHOD(mkxpStringToUTF8Bang) { return self; } -#ifdef SDL_PLATFORM_APPLE +#ifdef __APPLE__ #define OPENCMD "open " #define OPENARGS "--args" #elif defined(__linux__) @@ -1234,7 +1234,7 @@ static void mriBindingExecute() { #else ruby_init(); rb_eval_string("$KCODE='U'"); -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ if (!conf.winConsole) { VALUE iostr = rb_str_new2("NUL"); // Sysinit isn't a thing yet, so send io to /dev/null instead diff --git a/binding/miniffi.cpp b/binding/miniffi.cpp index 6a3b4b3fa..31183b732 100644 --- a/binding/miniffi.cpp +++ b/binding/miniffi.cpp @@ -1,7 +1,7 @@ #include "miniffi.h" #include -#if defined(__MINGW64__) || defined(__linux__) || defined(SDL_PLATFORM_APPLE) +#if defined(__MINGW64__) || defined(__linux__) || defined(__APPLE__) mffi_value miniffi_call_intern(MINIFFI_FUNC target, MiniFFIFuncArgs *p, int nparams) { assert(nparams <= MINIFFI_MAX_ARGS); // Be sure to add more args to the below line if MINIFFI_MAX_ARGS is bumped diff --git a/binding/miniffi.h b/binding/miniffi.h index b8063984d..d322cdf5b 100644 --- a/binding/miniffi.h +++ b/binding/miniffi.h @@ -4,7 +4,7 @@ #define MINIFFI_MAX_ARGS 16l -#if defined(__linux__) || defined(SDL_PLATFORM_APPLE) +#if defined(__linux__) || defined(__APPLE__) typedef unsigned long mffi_value; // Be sure to add more args to the below line if MINIFFI_MAX_ARGS is bumped // in the future. diff --git a/binding/oneshot-niko-binding.cpp b/binding/oneshot-niko-binding.cpp index cd04dcf49..25f2ab397 100644 --- a/binding/oneshot-niko-binding.cpp +++ b/binding/oneshot-niko-binding.cpp @@ -8,7 +8,7 @@ #define NIKO_Y ((13 * 16) * 2) #include -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ #include #else #include @@ -40,10 +40,10 @@ RB_METHOD(nikoStart) { auto pwd = std::filesystem::current_path(); std::string dir = pwd.string(); -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ dir += "\\_______.exe"; #endif -#ifdef SDL_PLATFORM_LINUX +#ifdef __LINUX__ dir += "/_______"; #endif @@ -53,7 +53,7 @@ RB_METHOD(nikoStart) { const_cast(dir.c_str()), const_cast(window_x.c_str()), const_cast(window_y.c_str())}; -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ spawnv(_P_DETACH, dir.c_str(), args); #else pid_t pid = fork(); diff --git a/binding/oneshot-wallpaper-binding.cpp b/binding/oneshot-wallpaper-binding.cpp index 607ba871d..81415521f 100644 --- a/binding/oneshot-wallpaper-binding.cpp +++ b/binding/oneshot-wallpaper-binding.cpp @@ -26,7 +26,7 @@ static bool setTile = false; static bool isCached = false; #else - #ifdef SDL_PLATFORM_APPLE + #ifdef __APPLE__ #include "mac-desktop.h" static bool isCached = false; #else @@ -253,7 +253,7 @@ RB_METHOD(wallpaperSet) Debug() << "Setting wallpaper to " << path; - #ifdef SDL_PLATFORM_APPLE + #ifdef __APPLE__ if (!isCached) { MacDesktop::CacheCurrentBackground(); isCached = true; @@ -391,7 +391,7 @@ RB_METHOD(wallpaperReset) RegCloseKey(hKey); } #else - #ifdef SDL_PLATFORM_APPLE + #ifdef __APPLE__ MacDesktop::ResetBackground(); #else desktopEnvironmentInit(); diff --git a/src/config.cpp b/src/config.cpp index 899866c02..ee1c21d1b 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -155,13 +155,13 @@ void Config::read(int argc, char *argv[]) { {"frameSkip", false}, {"syncToRefreshrate", false}, {"solidFonts", json::array({})}, -#if defined(SDL_PLATFORM_APPLE) && defined(__aarch64__) +#if defined(__APPLE__) && defined(__aarch64__) {"preferMetalRenderer", true}, #else {"preferMetalRenderer", false}, #endif {"subImageFix", false}, -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ {"enableBlitting", false}, #else {"enableBlitting", true}, @@ -295,7 +295,7 @@ try { exp } catch (...) {} for (std::string & solidFont : solidFonts) std::transform(solidFont.begin(), solidFont.end(), solidFont.begin(), [](unsigned char c) { return std::tolower(c); }); -#ifdef SDL_PLATFORM_APPLE +#ifdef __APPLE__ SET_OPT(preferMetalRenderer, boolean); #endif SET_OPT(subImageFix, boolean); @@ -342,7 +342,7 @@ try { exp } catch (...) {} // Determine whether to open a console window on... Windows winConsole = getEnvironmentBool("MKXPZ_WINDOWS_CONSOLE", editor.debug); -#ifdef SDL_PLATFORM_APPLE +#ifdef __APPLE__ // Determine whether to use the Metal renderer on macOS // Environment variable takes priority over the json setting preferMetalRenderer = isMetalSupported() && getEnvironmentBool("MKXPZ_MACOS_METAL", preferMetalRenderer); diff --git a/src/filesystem/filesystemImpl.cpp b/src/filesystem/filesystemImpl.cpp index bec798b31..c53a2eed6 100644 --- a/src/filesystem/filesystemImpl.cpp +++ b/src/filesystem/filesystemImpl.cpp @@ -81,7 +81,7 @@ std::string filesystemImpl::normalizePath(const char *path, bool preferred, bool for (size_t i = 0; i < ret.length(); i++) { char sep; char sep_alt; -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ if (preferred) { sep = '\\'; sep_alt = '/'; diff --git a/src/net/httplib.h b/src/net/httplib.h index 0881874dd..89449452a 100644 --- a/src/net/httplib.h +++ b/src/net/httplib.h @@ -249,7 +249,7 @@ using socket_t = int; #pragma comment(lib, "crypt32.lib") #pragma comment(lib, "cryptui.lib") #endif -#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && defined(SDL_PLATFORM_APPLE) +#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && defined(__APPLE__) #include #if TARGET_OS_OSX #include @@ -3281,7 +3281,7 @@ inline void get_remote_ip_and_port(socket_t sock, std::string &ip, int &port) { if (getsockopt(sock, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == 0) { port = ucred.pid; } -#elif defined(SOL_LOCAL) && defined(SO_PEERPID) // SDL_PLATFORM_APPLE +#elif defined(SOL_LOCAL) && defined(SO_PEERPID) // __APPLE__ pid_t pid; socklen_t len = sizeof(pid); if (getsockopt(sock, SOL_LOCAL, SO_PEERPID, &pid, &len) == 0) { @@ -4804,7 +4804,7 @@ inline bool load_system_certs_on_windows(X509_STORE *store) { return result; } -#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && defined(SDL_PLATFORM_APPLE) +#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && defined(__APPLE__) #if TARGET_OS_OSX template using CFObjectPtr = @@ -8524,7 +8524,7 @@ inline bool SSLClient::load_certs() { #ifdef _WIN32 loaded = detail::load_system_certs_on_windows(SSL_CTX_get_cert_store(ctx_)); -#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && defined(SDL_PLATFORM_APPLE) +#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && defined(__APPLE__) #if TARGET_OS_OSX loaded = detail::load_system_certs_on_macos(SSL_CTX_get_cert_store(ctx_)); #endif // TARGET_OS_OSX diff --git a/src/oneshot/oneshot.cpp b/src/oneshot/oneshot.cpp index 1e9079092..2ca91cc27 100644 --- a/src/oneshot/oneshot.cpp +++ b/src/oneshot/oneshot.cpp @@ -22,13 +22,13 @@ #include #include #include -#elif defined SDL_PLATFORM_APPLE || __linux__ +#elif defined __APPLE__ || __linux__ #include #include #include #include - #ifdef SDL_PLATFORM_APPLE + #ifdef __APPLE__ #define OS_OSX #include #else diff --git a/src/system/system.h b/src/system/system.h index fa63c439a..4ef873852 100644 --- a/src/system/system.h +++ b/src/system/system.h @@ -14,9 +14,9 @@ #define MKXPZ_PLATFORM_MACOS 1 #define MKXPZ_PLATFORM_LINUX 2 -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ #define MKXPZ_PLATFORM MKXPZ_PLATFORM_WINDOWS -#elif defined SDL_PLATFORM_APPLE +#elif defined __APPLE__ #define MKXPZ_PLATFORM MKXPZ_PLATFORM_MACOS #elif defined __linux__ #define MKXPZ_PLATFORM MKXPZ_PLATFORM_LINUX diff --git a/src/system/systemImpl.cpp b/src/system/systemImpl.cpp index cd1e5120f..5d9489e8e 100644 --- a/src/system/systemImpl.cpp +++ b/src/system/systemImpl.cpp @@ -7,7 +7,7 @@ #include "system.h" -#if defined(SDL_PLATFORM_WIN32) +#if defined(__WIN32__) #include #include #else @@ -20,7 +20,7 @@ std::string systemImpl::getSystemLanguage() { static char buf[50] = {0}; -#if defined(SDL_PLATFORM_WIN32) +#if defined(__WIN32__) wchar_t wbuf[50] = {0}; LANGID lid = GetUserDefaultLangID(); LCIDToLocaleName(lid, wbuf, sizeof(wbuf), 0); @@ -30,7 +30,7 @@ std::string systemImpl::getSystemLanguage() { #endif for (int i = 0; (size_t)i < strlen(buf); i++) { -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ if (buf[i] == '-') { buf[i] = '_'; #else @@ -45,7 +45,7 @@ std::string systemImpl::getSystemLanguage() { std::string systemImpl::getUserName() { -#ifdef SDL_PLATFORM_WIN32 +#ifdef __WIN32__ // The Ruby binding gets the username from the environment loaded // with Ruby instead, should fix getting it from WinAPI at some point return std::string("unused"); diff --git a/src/util/string-util.h b/src/util/string-util.h index 39d24b3aa..e675d1aa2 100644 --- a/src/util/string-util.h +++ b/src/util/string-util.h @@ -1,7 +1,7 @@ #ifndef STRING_UTIL_H #define STRING_UTIL_H -#ifndef SDL_PLATFORM_APPLE +#ifndef __APPLE__ #include diff --git a/src/util/win-consoleutils.cpp b/src/util/win-consoleutils.cpp index 33dbfb220..6eb0c555c 100644 --- a/src/util/win-consoleutils.cpp +++ b/src/util/win-consoleutils.cpp @@ -1,4 +1,4 @@ -#if SDL_PLATFORM_WIN32 +#if __WIN32__ #include "win-consoleutils.h" @@ -67,4 +67,4 @@ static int openStdHandle(const DWORD &nStdHandle) return _open_osfhandle((intptr_t)handle, _O_TEXT); } -#endif // SDL_PLATFORM_WIN32 +#endif // __WIN32__