sdl2-compat: Don't forward SDL_GetRevision

From c7d3b534272c92d49e61ebf249e6dcd08703b4e9 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sun, 30 Jul 2023 15:00:24 +0200
Subject: [PATCH] Don't forward SDL_GetRevision

---
 CMakeLists.txt    |  2 ++
 src/sdl2_compat.c | 12 ++++++++++++
 src/sdl3_syms.h   |  4 ++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ad1061..f8dadca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -184,6 +184,7 @@ target_include_directories(SDL2
     "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
     "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>"
 )
+target_compile_definitions(SDL2 PRIVATE "SDL2COMPAT_REVISION=\"${SDL_REVISION}\"")
 
 set(EXTRA_CFLAGS )
 if(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
@@ -514,6 +515,7 @@ if(SDL2COMPAT_STATICDEVEL AND SDL2COMPAT_DEVEL)
       "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>"
   )
   target_compile_definitions(SDL2-static PRIVATE _REENTRANT)
+  target_compile_definitions(SDL2-static PRIVATE "SDL2COMPAT_REVISION=\"${SDL_REVISION}\"")
   target_link_libraries(SDL2-static PRIVATE ${CMAKE_DL_LIBS})
   set_target_properties(SDL2-static PROPERTIES
     VERSION "${PROJECT_VERSION}"
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index b0af6d2..1cd13db 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -45,6 +45,9 @@ This breaks the build when creating SDL_ ## DisableScreenSaver
 #define DECLSPEC
 #endif
 
+#define STRINGIFY2(V) #V
+#define STRINGIFY(V) STRINGIFY2(V)
+
 /*
  * We report the library version as
  * 2.$(SDL2_COMPAT_VERSION_MINOR).$(SDL2_COMPAT_VERSION_PATCH). This number
@@ -57,6 +60,10 @@ This breaks the build when creating SDL_ ## DisableScreenSaver
 #define SDL2_COMPAT_VERSION_MINOR 90
 #define SDL2_COMPAT_VERSION_PATCH 0
 
+#ifndef SDL2COMPAT_REVISION
+#define SDL2COMPAT_REVISION "SDL-2." STRINGIFY(SDL2_COMPAT_VERSION_MINOR) "." STRINGIFY(SDL2_COMPAT_VERSION_PATCH) "-no-vcs"
+#endif
+
 #include <stdarg.h>
 #include <limits.h>
 #include <stddef.h>
@@ -1172,6 +1179,11 @@ SDL_GetRevisionNumber(void)
     return 0;
 }
 
+DECLSPEC const char * SDLCALL
+SDL_GetRevision(void)
+{
+    return SDL2COMPAT_REVISION;
+}
 
 DECLSPEC int SDLCALL
 SDL_SetError(const char *fmt, ...)
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index 2fe4dd6..0381537 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -471,7 +471,7 @@ SDL3_SYM_PASSTHROUGH(SDL_TouchID,GetTouchDevice,(int a),(a),return)
 SDL3_SYM_PASSTHROUGH(int,GetNumTouchFingers,(SDL_TouchID a),(a),return)
 SDL3_SYM_PASSTHROUGH(SDL_Finger*,GetTouchFinger,(SDL_TouchID a, int b),(a,b),return)
 SDL3_SYM(int,GetVersion,(SDL_version *a),(a),return)
-SDL3_SYM_PASSTHROUGH(const char*,GetRevision,(void),(),return)
+SDL3_SYM(const char*,GetRevision,(void),(),return)
 SDL3_SYM_PASSTHROUGH(int,GetNumVideoDrivers,(void),(),return)
 SDL3_SYM_PASSTHROUGH(const char*,GetVideoDriver,(int a),(a),return)
 SDL3_SYM_PASSTHROUGH(const char*,GetCurrentVideoDriver,(void),(),return)
@@ -906,7 +906,7 @@ SDL3_SYM(SDL_DisplayID*,GetDisplays,(int *a),(a),return)
 SDL3_SYM(SDL_DisplayID,GetDisplayForWindow,(SDL_Window *a),(a),return)
 SDL3_SYM(SDL_DisplayID,GetDisplayForPoint,(const SDL_Point *a),(a),return)
 SDL3_SYM(SDL_DisplayID,GetDisplayForRect,(const SDL_Rect *a),(a),return)
-SDL3_SYM(SDL_DisplayID,GetPrimaryDisplay,(),(),return)
+SDL3_SYM(SDL_DisplayID,GetPrimaryDisplay,(void),(),return)
 SDL3_SYM(int,RunApp,(int a, char **b, SDL_main_func c, void *d),(a,b,c,d),return)
 SDL3_SYM(const SDL_DisplayMode *,GetWindowFullscreenMode,(SDL_Window *a),(a),return)
 SDL3_SYM(const SDL_DisplayMode **,GetFullscreenDisplayModes,(SDL_DisplayID a, int *b),(a,b),return)