Browse Source

Fix SDL threading on macOS/Linux.

And fixup pkg-config check for SDL on Linux.

Co-authored-by: Rémi Verschelde <[email protected]>
Pāvels Nadtočajevs 2 months ago
parent
commit
71dd7b5712

+ 2 - 3
drivers/sdl/SCsub

@@ -90,9 +90,6 @@ if env["builtin_sdl"]:
         "stdlib/SDL_string.c",
         "stdlib/SDL_strtokr.c",
         "thread/SDL_thread.c",
-        "thread/generic/SDL_syscond.c",
-        "thread/generic/SDL_sysrwlock.c",
-        "thread/generic/SDL_systhread.c",
         "timer/SDL_timer.c",
     ]
 
@@ -182,6 +179,8 @@ if env["builtin_sdl"]:
             "joystick/windows/SDL_windows_gaming_input.c",
             "joystick/windows/SDL_windowsjoystick.c",
             "joystick/windows/SDL_xinputjoystick.c",
+            "thread/generic/SDL_syscond.c",
+            "thread/generic/SDL_sysrwlock.c",
             "thread/windows/SDL_syscond_cv.c",
             "thread/windows/SDL_sysmutex.c",
             "thread/windows/SDL_sysrwlock_srw.c",

+ 1 - 1
platform/linuxbsd/detect.py

@@ -397,7 +397,7 @@ def configure(env: "SConsEnvironment"):
     if env["sdl"]:
         if env["builtin_sdl"]:
             env.Append(CPPDEFINES=["SDL_ENABLED"])
-        elif os.system("pkg-config --exists fontconfig") == 0:  # 0 means found
+        elif os.system("pkg-config --exists sdl3") == 0:  # 0 means found
             env.ParseConfig("pkg-config sdl3 --cflags --libs")
             env.Append(CPPDEFINES=["SDL_ENABLED"])
         else:

+ 0 - 57
thirdparty/sdl/thread/generic/SDL_systhread.c

@@ -1,57 +0,0 @@
-/*
-  Simple DirectMedia Layer
-  Copyright (C) 1997-2025 Sam Lantinga <[email protected]>
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-*/
-#include "SDL_internal.h"
-
-// Thread management routines for SDL
-
-#include "../SDL_systhread.h"
-
-bool SDL_SYS_CreateThread(SDL_Thread *thread,
-                          SDL_FunctionPointer pfnBeginThread,
-                          SDL_FunctionPointer pfnEndThread)
-{
-    return SDL_SetError("Threads are not supported on this platform");
-}
-
-void SDL_SYS_SetupThread(const char *name)
-{
-    return;
-}
-
-SDL_ThreadID SDL_GetCurrentThreadID(void)
-{
-    return 0;
-}
-
-bool SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
-{
-    return true;
-}
-
-void SDL_SYS_WaitThread(SDL_Thread *thread)
-{
-    return;
-}
-
-void SDL_SYS_DetachThread(SDL_Thread *thread)
-{
-    return;
-}

+ 6 - 2
thirdparty/sdl/update-sdl.sh

@@ -63,8 +63,12 @@ mkdir $target/sensor
 cp -rv sensor/{*.{c,h},dummy} $target/sensor
 
 mkdir $target/thread
-cp -rv thread/{*.{c,h},generic,pthread,windows} $target/thread
-rm -f $target/thread/generic/SDL_{sysmutex*.{c,h},systls.c}
+cp -rv thread/{*.{c,h},pthread,windows} $target/thread
+# Despite being 'generic', syssem.c is included in the Unix driver for macOS,
+# and syscond/sysrwlock are used by the Windows driver.
+# systhread_c.h is included by all these, but we should NOT compile the matching .c file.
+mkdir $target/thread/generic
+cp -v thread/generic/SDL_{syssem.c,{syscond,sysrwlock}*.{c,h},systhread_c.h} $target/thread/generic
 
 mkdir $target/timer
 cp -rv timer/{*.{c,h},unix,windows} $target/timer