Browse Source

Removed the SDL_Version structure, moved SDL version to SDL.h

Inspired by https://github.com/libsdl-org/SDL/issues/9788
Sam Lantinga 11 months ago
parent
commit
661f2fc1fc

+ 2 - 2
.wikiheaders-options

@@ -5,10 +5,10 @@ wikisubdir =
 readmesubdir = docs
 apiprefixregex = (SDL_|SDLK_)
 mainincludefname = SDL3/SDL.h
-versionfname = include/SDL3/SDL_version.h
+versionfname = include/SDL3/SDL.h
 versionmajorregex = \A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z
 versionminorregex = \A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z
-versionpatchregex = \A\#define\s+SDL_PATCHLEVEL\s+(\d+)\Z
+versionmicroregex = \A\#define\s+SDL_MICRO_VERSION\s+(\d+)\Z
 selectheaderregex = \ASDL.*?\.h\Z
 projecturl = https://libsdl.org/
 wikiurl = https://wiki.libsdl.org

+ 8 - 8
VisualC/pkg-support/cmake/sdl3-config-version.cmake

@@ -3,22 +3,22 @@
 # SDL CMake version configuration file:
 # This file is meant to be placed in a cmake subfolder of SDL3-devel-3.x.y-VC
 
-if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../include/SDL3/SDL_version.h")
-    message(AUTHOR_WARNING "Could not find SDL3/SDL_version.h. This script is meant to be placed in the root of SDL3-devel-3.x.y-VC")
+if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../include/SDL3/SDL.h")
+    message(AUTHOR_WARNING "Could not find SDL3/SDL.h. This script is meant to be placed in the root of SDL3-devel-3.x.y-VC")
     return()
 endif()
 
-file(READ "${CMAKE_CURRENT_LIST_DIR}/../include/SDL3/SDL_version.h" _sdl_version_h)
+file(READ "${CMAKE_CURRENT_LIST_DIR}/../include/SDL3/SDL.h" _sdl_version_h)
 string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re "${_sdl_version_h}")
 set(_sdl_major "${CMAKE_MATCH_1}")
 string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}")
 set(_sdl_minor "${CMAKE_MATCH_1}")
-string(REGEX MATCH "#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_version_h}")
-set(_sdl_patch "${CMAKE_MATCH_1}")
-if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re)
-    set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}")
+string(REGEX MATCH "#define[ \t]+SDL_MICRO_VERSION[ \t]+([0-9]+)" _sdl_micro_re "${_sdl_version_h}")
+set(_sdl_micro "${CMAKE_MATCH_1}")
+if(_sdl_major_re AND _sdl_minor_re AND _sdl_micro_re)
+    set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_micro}")
 else()
-    message(AUTHOR_WARNING "Could not extract version from SDL3/SDL_version.h.")
+    message(AUTHOR_WARNING "Could not extract version from SDL3/SDL.h.")
     return()
 endif()
 

+ 8 - 8
Xcode/SDL/pkg-support/resources/CMake/sdl3-config-version.cmake

@@ -12,7 +12,7 @@ get_filename_component(_sdl3_xcframework_parent_path "${_sdl3_xcframework_parent
 get_filename_component(_sdl3_xcframework_parent_path "${_sdl3_xcframework_parent_path}" PATH)           # /
 set(_sdl3_xcframework "${_sdl3_xcframework_parent_path}/SDL3.xcframework")                              # /SDL3.xcframework
 set(_sdl3_framework "${_sdl3_xcframework}/macos-arm64_x86_64/SDL3.framework")                           # /SDL3.xcframework/macos-arm64_x86_64/SDL3.framework
-set(_sdl3_version_h "${_sdl3_framework}/Headers/SDL_version.h")                                         # /SDL3.xcframework/macos-arm64_x86_64/SDL3.framework/Headers/SDL_version.h
+set(_sdl3_version_h "${_sdl3_framework}/Headers/SDL.h")                                         # /SDL3.xcframework/macos-arm64_x86_64/SDL3.framework/Headers/SDL.h
 
 if(NOT EXISTS "${_sdl3_version_h}")
     message(AUTHOR_WARNING "Cannot not find ${_sdl3_framework}. This script is meant to be placed in share/cmake/SDL3, next to SDL3.xcframework")
@@ -30,12 +30,12 @@ string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re
 set(_sdl_major "${CMAKE_MATCH_1}")
 string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}")
 set(_sdl_minor "${CMAKE_MATCH_1}")
-string(REGEX MATCH "#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_version_h}")
-set(_sdl_patch "${CMAKE_MATCH_1}")
-if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re)
-    set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}")
+string(REGEX MATCH "#define[ \t]+SDL_MICRO_VERSION[ \t]+([0-9]+)" _sdl_micro_re "${_sdl_version_h}")
+set(_sdl_micro "${CMAKE_MATCH_1}")
+if(_sdl_major_re AND _sdl_minor_re AND _sdl_micro_re)
+    set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_micro}")
 else()
-    message(AUTHOR_WARNING "Could not extract version from SDL_version.h.")
+    message(AUTHOR_WARNING "Could not extract version from SDL.h.")
     return()
 endif()
 
@@ -43,8 +43,8 @@ unset(_sdl_major_re)
 unset(_sdl_major)
 unset(_sdl_minor_re)
 unset(_sdl_minor)
-unset(_sdl_patch_re)
-unset(_sdl_patch)
+unset(_sdl_micro_re)
+unset(_sdl_micro)
 
 if(PACKAGE_FIND_VERSION_RANGE)
     # Package version must be in the requested version range

+ 12 - 9
build-scripts/SDL_migration.cocci

@@ -2985,11 +2985,6 @@ SDL_GamepadBinding *e1;
 - e1->outputType
 + e1->output_type
 @@
-typedef SDL_version, SDL_Version;
-@@
-- SDL_version
-+ SDL_Version
-@@
 @@
 - SDL_HINT_ALLOW_TOPMOST
 + SDL_HINT_WINDOW_ALLOW_TOPMOST
@@ -3137,15 +3132,23 @@ typedef SDL_Colour, SDL_Color;
   (...)
 @@
 @@
-- SDL_TABLESIZE
-+ SDL_arraysize
-@@
-@@
 - SDL_iPhoneSetEventPump
 + SDL_iOSSetEventPump
   (...)
 @@
 @@
+- SDL_COMPILEDVERSION
++ SDL_VERSION
+@@
+@@
+- SDL_PATCHLEVEL
++ SDL_MICRO_VERSION
+@@
+@@
+- SDL_TABLESIZE
++ SDL_arraysize
+@@
+@@
 - SDLK_QUOTE
 + SDLK_APOSTROPHE
 @@

+ 4 - 4
build-scripts/android-prefab.sh

@@ -40,10 +40,10 @@ android_api=19
 android_ndk=21
 android_stl="c++_shared"
 
-sdl_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION  *//p' "${sdl_root}/include/SDL3/SDL_version.h")
-sdl_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION  *//p' "${sdl_root}/include/SDL3/SDL_version.h")
-sdl_patch=$(sed -ne 's/^#define SDL_PATCHLEVEL  *//p' "${sdl_root}/include/SDL3/SDL_version.h")
-sdl_version="${sdl_major}.${sdl_minor}.${sdl_patch}"
+sdl_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION  *//p' "${sdl_root}/include/SDL3/SDL.h")
+sdl_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION  *//p' "${sdl_root}/include/SDL3/SDL.h")
+sdl_micro=$(sed -ne 's/^#define SDL_MICRO_VERSION  *//p' "${sdl_root}/include/SDL3/SDL.h")
+sdl_version="${sdl_major}.${sdl_minor}.${sdl_micro}"
 echo "Building Android prefab package for SDL version $sdl_version"
 
 prefabhome="${build_root}/prefab-${sdl_version}"

+ 3 - 3
build-scripts/build-release.py

@@ -509,12 +509,12 @@ class Releaser:
 
     @classmethod
     def extract_sdl_version(cls, root: Path, project: str):
-        with open(root / f"include/{project}/SDL_version.h", "r") as f:
+        with open(root / f"include/{project}/SDL.h", "r") as f:
             text = f.read()
         major = next(re.finditer(r"^#define SDL_MAJOR_VERSION\s+([0-9]+)$", text, flags=re.M)).group(1)
         minor = next(re.finditer(r"^#define SDL_MINOR_VERSION\s+([0-9]+)$", text, flags=re.M)).group(1)
-        patch = next(re.finditer(r"^#define SDL_PATCHLEVEL\s+([0-9]+)$", text, flags=re.M)).group(1)
-        return f"{major}.{minor}.{patch}"
+        micro = next(re.finditer(r"^#define SDL_MICRO_VERSION\s+([0-9]+)$", text, flags=re.M)).group(1)
+        return f"{major}.{minor}.{micro}"
 
 
 def main(argv=None):

+ 1 - 1
build-scripts/rename_api.py

@@ -23,7 +23,7 @@ def main():
         exit(1)
 
     # Check whether we can still modify the ABI
-    version_header = pathlib.Path( SDL_INCLUDE_DIR / "SDL_version.h" ).read_text()
+    version_header = pathlib.Path( SDL_INCLUDE_DIR / "SDL.h" ).read_text()
     if not re.search("SDL_MINOR_VERSION\s+[01]\s", version_header):
         raise Exception("ABI is frozen, symbols cannot be renamed")
 

+ 3 - 3
build-scripts/showrev.sh

@@ -10,9 +10,9 @@ if [ -e ./VERSION.txt ]; then
     exit 0
 fi
 
-major=$(sed -ne 's/^#define SDL_MAJOR_VERSION  *//p' include/SDL3/SDL_version.h)
-minor=$(sed -ne 's/^#define SDL_MINOR_VERSION  *//p' include/SDL3/SDL_version.h)
-micro=$(sed -ne 's/^#define SDL_PATCHLEVEL  *//p' include/SDL3/SDL_version.h)
+major=$(sed -ne 's/^#define SDL_MAJOR_VERSION  *//p' include/SDL3/SDL.h)
+minor=$(sed -ne 's/^#define SDL_MINOR_VERSION  *//p' include/SDL3/SDL.h)
+micro=$(sed -ne 's/^#define SDL_MICRO_VERSION  *//p' include/SDL3/SDL.h)
 version="${major}.${minor}.${micro}"
 
 if [ -x "$(command -v git)" ]; then

+ 12 - 12
build-scripts/test-versioning.sh

@@ -6,9 +6,9 @@ set -eu
 
 cd `dirname $0`/..
 
-ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION  *//p' include/SDL3/SDL_version.h)
-ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION  *//p' include/SDL3/SDL_version.h)
-ref_micro=$(sed -ne 's/^#define SDL_PATCHLEVEL  *//p' include/SDL3/SDL_version.h)
+ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION  *//p' include/SDL3/SDL.h)
+ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION  *//p' include/SDL3/SDL.h)
+ref_micro=$(sed -ne 's/^#define SDL_MICRO_VERSION  *//p' include/SDL3/SDL.h)
 ref_version="${ref_major}.${ref_minor}.${ref_micro}"
 
 tests=0
@@ -30,7 +30,7 @@ version=$(sed -Ene 's/^project\(SDL[0-9]+ LANGUAGES C VERSION "([0-9.]*)"\)$/\1/
 if [ "$ref_version" = "$version" ]; then
     ok "CMakeLists.txt $version"
 else
-    not_ok "CMakeLists.txt $version disagrees with SDL_version.h $ref_version"
+    not_ok "CMakeLists.txt $version disagrees with SDL.h $ref_version"
 fi
 
 major=$(sed -ne 's/.*SDL_MAJOR_VERSION = \([0-9]*\);/\1/p' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java)
@@ -41,7 +41,7 @@ version="${major}.${minor}.${micro}"
 if [ "$ref_version" = "$version" ]; then
     ok "SDLActivity.java $version"
 else
-    not_ok "android-project/app/src/main/java/org/libsdl/app/SDLActivity.java $version disagrees with SDL_version.h $ref_version"
+    not_ok "android-project/app/src/main/java/org/libsdl/app/SDLActivity.java $version disagrees with SDL.h $ref_version"
 fi
 
 tuple=$(sed -ne 's/^ *FILEVERSION *//p' src/core/windows/version.rc | tr -d '\r')
@@ -50,7 +50,7 @@ ref_tuple="${ref_major},${ref_minor},${ref_micro},0"
 if [ "$ref_tuple" = "$tuple" ]; then
     ok "version.rc FILEVERSION $tuple"
 else
-    not_ok "version.rc FILEVERSION $tuple disagrees with SDL_version.h $ref_tuple"
+    not_ok "version.rc FILEVERSION $tuple disagrees with SDL.h $ref_tuple"
 fi
 
 tuple=$(sed -ne 's/^ *PRODUCTVERSION *//p' src/core/windows/version.rc | tr -d '\r')
@@ -58,7 +58,7 @@ tuple=$(sed -ne 's/^ *PRODUCTVERSION *//p' src/core/windows/version.rc | tr -d '
 if [ "$ref_tuple" = "$tuple" ]; then
     ok "version.rc PRODUCTVERSION $tuple"
 else
-    not_ok "version.rc PRODUCTVERSION $tuple disagrees with SDL_version.h $ref_tuple"
+    not_ok "version.rc PRODUCTVERSION $tuple disagrees with SDL.h $ref_tuple"
 fi
 
 tuple=$(sed -Ene 's/^ *VALUE "FileVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/core/windows/version.rc | tr -d '\r')
@@ -67,7 +67,7 @@ ref_tuple="${ref_major}, ${ref_minor}, ${ref_micro}, 0"
 if [ "$ref_tuple" = "$tuple" ]; then
     ok "version.rc FileVersion $tuple"
 else
-    not_ok "version.rc FileVersion $tuple disagrees with SDL_version.h $ref_tuple"
+    not_ok "version.rc FileVersion $tuple disagrees with SDL.h $ref_tuple"
 fi
 
 tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/core/windows/version.rc | tr -d '\r')
@@ -75,7 +75,7 @@ tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/cor
 if [ "$ref_tuple" = "$tuple" ]; then
     ok "version.rc ProductVersion $tuple"
 else
-    not_ok "version.rc ProductVersion $tuple disagrees with SDL_version.h $ref_tuple"
+    not_ok "version.rc ProductVersion $tuple disagrees with SDL.h $ref_tuple"
 fi
 
 version=$(sed -Ene '/CFBundleShortVersionString/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist)
@@ -83,7 +83,7 @@ version=$(sed -Ene '/CFBundleShortVersionString/,+1 s/.*<string>(.*)<\/string>.*
 if [ "$ref_version" = "$version" ]; then
     ok "Info-Framework.plist CFBundleShortVersionString $version"
 else
-    not_ok "Info-Framework.plist CFBundleShortVersionString $version disagrees with SDL_version.h $ref_version"
+    not_ok "Info-Framework.plist CFBundleShortVersionString $version disagrees with SDL.h $ref_version"
 fi
 
 version=$(sed -Ene '/CFBundleVersion/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist)
@@ -91,7 +91,7 @@ version=$(sed -Ene '/CFBundleVersion/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcod
 if [ "$ref_version" = "$version" ]; then
     ok "Info-Framework.plist CFBundleVersion $version"
 else
-    not_ok "Info-Framework.plist CFBundleVersion $version disagrees with SDL_version.h $ref_version"
+    not_ok "Info-Framework.plist CFBundleVersion $version disagrees with SDL.h $ref_version"
 fi
 
 version=$(sed -Ene 's/Title SDL (.*)/\1/p' Xcode/SDL/pkg-support/SDL.info)
@@ -99,7 +99,7 @@ version=$(sed -Ene 's/Title SDL (.*)/\1/p' Xcode/SDL/pkg-support/SDL.info)
 if [ "$ref_version" = "$version" ]; then
     ok "SDL.info Title $version"
 else
-    not_ok "SDL.info Title $version disagrees with SDL_version.h $ref_version"
+    not_ok "SDL.info Title $version disagrees with SDL.h $ref_version"
 fi
 
 marketing=$(sed -Ene 's/.*MARKETING_VERSION = (.*);/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)

+ 13 - 13
build-scripts/update-version.sh

@@ -22,8 +22,8 @@ fi
 
 MAJOR="$1"
 MINOR="$2"
-PATCH="$3"
-NEWVERSION="$MAJOR.$MINOR.$PATCH"
+MICRO="$3"
+NEWVERSION="$MAJOR.$MINOR.$MICRO"
 
 echo "Updating version to '$NEWVERSION' ..."
 
@@ -41,14 +41,14 @@ perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;
 perl -w -pi -e 's/(DYLIB_COMPATIBILITY_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
 
 # non-zero patch?
-if [ "x$PATCH" != "x0" ]; then
+if [ "x$MICRO" != "x0" ]; then
     if [ `expr $MINOR % 2` = "0" ]; then
         # If patch is not zero, but minor is even, it's a bugfix release.
-        perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.'$PATCH'.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
+        perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.'$MICRO'.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
 
     else
         # If patch is not zero, but minor is odd, it's a development prerelease.
-        DYVER=`expr $MINOR \* 100 + $PATCH + 1`
+        DYVER=`expr $MINOR \* 100 + $MICRO + 1`
         perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
         perl -w -pi -e 's/(DYLIB_COMPATIBILITY_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
     fi
@@ -58,16 +58,16 @@ perl -w -pi -e 's/\A(project\(SDL[0-9]+ LANGUAGES C VERSION ")[0-9.]+/${1}'$NEWV
 
 perl -w -pi -e 's/\A(.* SDL_MAJOR_VERSION = )\d+/${1}'$MAJOR'/;' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
 perl -w -pi -e 's/\A(.* SDL_MINOR_VERSION = )\d+/${1}'$MINOR'/;' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
-perl -w -pi -e 's/\A(.* SDL_MICRO_VERSION = )\d+/${1}'$PATCH'/;' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+perl -w -pi -e 's/\A(.* SDL_MICRO_VERSION = )\d+/${1}'$MICRO'/;' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
 
-perl -w -pi -e 's/(\#define SDL_MAJOR_VERSION\s+)\d+/${1}'$MAJOR'/;' include/SDL3/SDL_version.h
-perl -w -pi -e 's/(\#define SDL_MINOR_VERSION\s+)\d+/${1}'$MINOR'/;' include/SDL3/SDL_version.h
-perl -w -pi -e 's/(\#define SDL_PATCHLEVEL\s+)\d+/${1}'$PATCH'/;' include/SDL3/SDL_version.h
+perl -w -pi -e 's/(\#define SDL_MAJOR_VERSION\s+)\d+/${1}'$MAJOR'/;' include/SDL3/SDL.h
+perl -w -pi -e 's/(\#define SDL_MINOR_VERSION\s+)\d+/${1}'$MINOR'/;' include/SDL3/SDL.h
+perl -w -pi -e 's/(\#define SDL_MICRO_VERSION\s+)\d+/${1}'$MICRO'/;' include/SDL3/SDL.h
 
-perl -w -pi -e 's/(FILEVERSION\s+)\d+,\d+,\d+/${1}'$MAJOR','$MINOR','$PATCH'/;' src/core/windows/version.rc
-perl -w -pi -e 's/(PRODUCTVERSION\s+)\d+,\d+,\d+/${1}'$MAJOR','$MINOR','$PATCH'/;' src/core/windows/version.rc
-perl -w -pi -e 's/(VALUE "FileVersion", ")\d+, \d+, \d+/${1}'$MAJOR', '$MINOR', '$PATCH'/;' src/core/windows/version.rc
-perl -w -pi -e 's/(VALUE "ProductVersion", ")\d+, \d+, \d+/${1}'$MAJOR', '$MINOR', '$PATCH'/;' src/core/windows/version.rc
+perl -w -pi -e 's/(FILEVERSION\s+)\d+,\d+,\d+/${1}'$MAJOR','$MINOR','$MICRO'/;' src/core/windows/version.rc
+perl -w -pi -e 's/(PRODUCTVERSION\s+)\d+,\d+,\d+/${1}'$MAJOR','$MINOR','$MICRO'/;' src/core/windows/version.rc
+perl -w -pi -e 's/(VALUE "FileVersion", ")\d+, \d+, \d+/${1}'$MAJOR', '$MINOR', '$MICRO'/;' src/core/windows/version.rc
+perl -w -pi -e 's/(VALUE "ProductVersion", ")\d+, \d+, \d+/${1}'$MAJOR', '$MINOR', '$MICRO'/;' src/core/windows/version.rc
 
 echo "Running build-scripts/test-versioning.sh to verify changes..."
 ./build-scripts/test-versioning.sh

+ 12 - 12
build-scripts/wikiheaders.pl

@@ -13,10 +13,10 @@ my $wikisubdir = '';
 my $incsubdir = 'include';
 my $readmesubdir = undef;
 my $apiprefixregex = undef;
-my $versionfname = 'include/SDL_version.h';
+my $versionfname = 'include/SDL.h';
 my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
 my $versionminorregex = '\A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z';
-my $versionpatchregex = '\A\#define\s+SDL_PATCHLEVEL\s+(\d+)\Z';
+my $versionmicroregex = '\A\#define\s+SDL_MICRO_VERSION\s+(\d+)\Z';
 my $mainincludefname = 'SDL.h';
 my $selectheaderregex = '\ASDL.*?\.h\Z';
 my $projecturl = 'https://libsdl.org/';
@@ -92,7 +92,7 @@ if (defined $optionsfname) {
             $readmesubdir = $val, next if $key eq 'readmesubdir';
             $versionmajorregex = $val, next if $key eq 'versionmajorregex';
             $versionminorregex = $val, next if $key eq 'versionminorregex';
-            $versionpatchregex = $val, next if $key eq 'versionpatchregex';
+            $versionmicroregex = $val, next if $key eq 'versionmicroregex';
             $versionfname = $val, next if $key eq 'versionfname';
             $mainincludefname = $val, next if $key eq 'mainincludefname';
             $selectheaderregex = $val, next if $key eq 'selectheaderregex';
@@ -2036,19 +2036,19 @@ if ($copy_direction == 1) {  # --copy-to-headers
     open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n");
     my $majorver = 0;
     my $minorver = 0;
-    my $patchver = 0;
+    my $microver = 0;
     while (<FH>) {
         chomp;
         if (/$versionmajorregex/) {
             $majorver = int($1);
         } elsif (/$versionminorregex/) {
             $minorver = int($1);
-        } elsif (/$versionpatchregex/) {
-            $patchver = int($1);
+        } elsif (/$versionmicroregex/) {
+            $microver = int($1);
         }
     }
     close(FH);
-    my $fullversion = "$majorver.$minorver.$patchver";
+    my $fullversion = "$majorver.$minorver.$microver";
 
     foreach (keys %headersyms) {
         my $sym = $_;
@@ -2318,19 +2318,19 @@ if ($copy_direction == 1) {  # --copy-to-headers
     open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n");
     my $majorver = 0;
     my $minorver = 0;
-    my $patchver = 0;
+    my $microver = 0;
     while (<FH>) {
         chomp;
         if (/$versionmajorregex/) {
             $majorver = int($1);
         } elsif (/$versionminorregex/) {
             $minorver = int($1);
-        } elsif (/$versionpatchregex/) {
-            $patchver = int($1);
+        } elsif (/$versionmicroregex/) {
+            $microver = int($1);
         }
     }
     close(FH);
-    my $fullversion = "$majorver.$minorver.$patchver";
+    my $fullversion = "$majorver.$minorver.$microver";
 
     my $latex_fname = "$srcpath/$projectshortname.tex";
     my $latex_tmpfname = "$latex_fname.tmp";
@@ -2369,7 +2369,7 @@ if ($copy_direction == 1) {  # --copy-to-headers
 \\begin{document}
 \\frontmatter
 
-\\title{$projectfullname $majorver.$minorver.$patchver Reference Manual}
+\\title{$projectfullname $majorver.$minorver.$microver Reference Manual}
 \\author{The $projectshortname Developers}
 \\maketitle
 

+ 7 - 2
docs/README-migration.md

@@ -1671,9 +1671,14 @@ The following functions have been removed:
 
 SDL_GetRevisionNumber() has been removed from the API, it always returned 0 in SDL 2.0.
 
+SDL_GetVersion() returns the version number, which can be directly compared with another version wrapped with SDL_VERSIONNUM().
 
-The following structures have been renamed:
-* SDL_version => SDL_Version
+The following structures have been removed:
+* SDL_version
+
+The following symbols have been renamed:
+* SDL_COMPILEDVERSION => SDL_VERSION
+* SDL_PATCHLEVEL => SDL_MICRO_VERSION
 
 ## SDL_video.h
 

+ 8 - 0
include/SDL3/SDL.h

@@ -28,6 +28,14 @@
 #ifndef SDL_h_
 #define SDL_h_
 
+/**
+ * The current version of SDL
+ */
+#define SDL_MAJOR_VERSION   3
+#define SDL_MINOR_VERSION   1
+#define SDL_MICRO_VERSION   2
+
+
 #include <SDL3/SDL_stdinc.h>
 #include <SDL3/SDL_assert.h>
 #include <SDL3/SDL_atomic.h>

+ 4 - 2
include/SDL3/SDL_oldnames.h

@@ -529,7 +529,8 @@
 #define SDL_GetTicks64 SDL_GetTicks
 
 /* ##SDL_version.h */
-#define SDL_version SDL_Version
+#define SDL_COMPILEDVERSION SDL_VERSION
+#define SDL_PATCHLEVEL SDL_MICRO_VERSION
 
 /* ##SDL_video.h */
 #define SDL_GetClosestDisplayMode SDL_GetClosestFullscreenDisplayMode
@@ -1038,7 +1039,8 @@
 #define SDL_GetTicks64 SDL_GetTicks64_renamed_SDL_GetTicks
 
 /* ##SDL_version.h */
-#define SDL_version SDL_version_renamed_SDL_Version
+#define SDL_COMPILEDVERSION SDL_COMPILEDVERSION_renamed_SDL_VERSION
+#define SDL_PATCHLEVEL SDL_PATCHLEVEL_renamed_SDL_MICRO_VERSION
 
 /* ##SDL_video.h */
 #define SDL_GetClosestDisplayMode SDL_GetClosestDisplayMode_renamed_SDL_GetClosestFullscreenDisplayMode

+ 33 - 51
include/SDL3/SDL_version.h

@@ -38,75 +38,59 @@ extern "C" {
 #endif
 
 /**
- * Information about the version of SDL in use.
+ * This macro turns the version numbers into a numeric value.
  *
- * Represents the library's version as three levels: major revision
- * (increments with massive changes, additions, and enhancements), minor
- * revision (increments with backwards-compatible changes to the major
- * revision), and patchlevel (increments with fixes to the minor revision).
+ * (1,2,3) becomes 1002003.
  *
- * \since This struct is available since SDL 3.0.0.
+ * \param major the major version number.
+ * \param minor the minorversion number.
+ * \param patch the patch version number.
  *
- * \sa SDL_VERSION
- * \sa SDL_GetVersion
+ * \since This macro is available since SDL 3.0.0.
  */
-typedef struct SDL_Version
-{
-    Uint8 major;        /**< major version */
-    Uint8 minor;        /**< minor version */
-    Uint8 patch;        /**< update version */
-} SDL_Version;
-
-/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL */
-#define SDL_MAJOR_VERSION   3
-#define SDL_MINOR_VERSION   1
-#define SDL_PATCHLEVEL      2
+#define SDL_VERSIONNUM(major, minor, patch) \
+    ((major) * 1000000 + (minor) * 1000 + (patch))
 
 /**
- * Macro to determine SDL version program was compiled against.
+ * This macro extracts the major version from a version number
  *
- * This macro fills in an SDL_Version structure with the version of the
- * library you compiled against. This is determined by what header the
- * compiler uses. Note that if you dynamically linked the library, you might
- * have a slightly newer or older version at runtime. That version can be
- * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), is not a
- * macro.
+ * 1002003 becomes 1.
  *
- * \param x A pointer to an SDL_Version struct to initialize.
+ * \param version the version number.
  *
  * \since This macro is available since SDL 3.0.0.
+ */
+#define SDL_VERSIONNUM_MAJOR(version) ((version) / 1000000)
+
+/**
+ * This macro extracts the minor version from a version number
  *
- * \sa SDL_Version
- * \sa SDL_GetVersion
+ * 1002003 becomes 2.
+ *
+ * \param version the version number.
+ *
+ * \since This macro is available since SDL 3.0.0.
  */
-#define SDL_VERSION(x)                \
-{                                     \
-    (x)->major = SDL_MAJOR_VERSION;   \
-    (x)->minor = SDL_MINOR_VERSION;   \
-    (x)->patch = SDL_PATCHLEVEL;      \
-}
+#define SDL_VERSIONNUM_MINOR(version) (((version) / 1000) % 1000)
 
 /**
- * This macro turns the version numbers into a numeric value.
+ * This macro extracts the micro version from a version number
  *
- * (1,2,3) becomes 0x1000203.
+ * 1002003 becomes 3.
  *
- * \param major the major version number.
- * \param minor the minorversion number.
- * \param patch the patch version number.
+ * \param version the version number.
  *
  * \since This macro is available since SDL 3.0.0.
  */
-#define SDL_VERSIONNUM(major, minor, patch) \
-    ((major) << 24 | (minor) << 8 | (patch) << 0)
+#define SDL_VERSIONNUM_MICRO(version) ((version) % 1000)
 
 /**
  * This is the version number macro for the current SDL version.
  *
  * \since This macro is available since SDL 3.0.0.
  */
-#define SDL_COMPILEDVERSION \
-    SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
+#define SDL_VERSION \
+    SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION)
 
 /**
  * This macro will evaluate to true if compiled with SDL at least X.Y.Z.
@@ -114,27 +98,25 @@ typedef struct SDL_Version
  * \since This macro is available since SDL 3.0.0.
  */
 #define SDL_VERSION_ATLEAST(X, Y, Z) \
-    (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
+    (SDL_VERSION >= SDL_VERSIONNUM(X, Y, Z))
 
 /**
  * Get the version of SDL that is linked against your program.
  *
  * If you are linking to SDL dynamically, then it is possible that the current
  * version will be different than the version you compiled against. This
- * function returns the current version, while SDL_VERSION() is a macro that
- * tells you what version you compiled with.
+ * function returns the current version, while SDL_VERSION is the version you
+ * compiled with.
  *
  * This function may be called safely at any time, even before SDL_Init().
  *
- * \param ver the SDL_Version structure that contains the version information
- * \returns 0 on success or a negative error code on failure; call
- *          SDL_GetError() for more information.
+ * \returns the version of the linked library.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_GetRevision
  */
-extern DECLSPEC int SDLCALL SDL_GetVersion(SDL_Version * ver);
+extern DECLSPEC int SDLCALL SDL_GetVersion(void);
 
 /**
  * Get the code revision of SDL that is linked against your program.

+ 8 - 31
src/SDL.c

@@ -65,20 +65,16 @@ SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MAJOR_VERSION,
 SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MINOR_VERSION,
                         SDL_MINOR_VERSION == SDL_BUILD_MINOR_VERSION);
 SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MICRO_VERSION,
-                        SDL_PATCHLEVEL == SDL_BUILD_MICRO_VERSION);
+                        SDL_MICRO_VERSION == SDL_BUILD_MICRO_VERSION);
 #endif
 
+/* Limited by its encoding in SDL_VERSIONNUM */
 SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_min, SDL_MAJOR_VERSION >= 0);
-/* Limited only by the need to fit in SDL_Version */
-SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_max, SDL_MAJOR_VERSION <= 255);
-
+SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_max, SDL_MAJOR_VERSION <= 10);
 SDL_COMPILE_TIME_ASSERT(SDL_MINOR_VERSION_min, SDL_MINOR_VERSION >= 0);
-/* Limited only by the need to fit in SDL_Version */
-SDL_COMPILE_TIME_ASSERT(SDL_MINOR_VERSION_max, SDL_MINOR_VERSION <= 255);
-
-SDL_COMPILE_TIME_ASSERT(SDL_PATCHLEVEL_min, SDL_PATCHLEVEL >= 0);
-/* Limited by its encoding in SDL_VERSIONNUM and in the ABI versions */
-SDL_COMPILE_TIME_ASSERT(SDL_PATCHLEVEL_max, SDL_PATCHLEVEL <= 99);
+SDL_COMPILE_TIME_ASSERT(SDL_MINOR_VERSION_max, SDL_MINOR_VERSION <= 999);
+SDL_COMPILE_TIME_ASSERT(SDL_MICRO_VERSION_min, SDL_MICRO_VERSION >= 0);
+SDL_COMPILE_TIME_ASSERT(SDL_MICRO_VERSION_max, SDL_MICRO_VERSION <= 999);
 
 /* This is not declared in any header, although it is shared between some
     parts of SDL, because we don't want anything calling it without an
@@ -579,28 +575,9 @@ Uint32 SDL_GetNextObjectID(void)
 }
 
 /* Get the library version number */
-int SDL_GetVersion(SDL_Version *ver)
+int SDL_GetVersion(void)
 {
-    static SDL_bool check_hint = SDL_TRUE;
-    static SDL_bool legacy_version = SDL_FALSE;
-
-    if (!ver) {
-        return SDL_InvalidParamError("ver");
-    }
-
-    SDL_VERSION(ver);
-
-    if (check_hint) {
-        check_hint = SDL_FALSE;
-        legacy_version = SDL_GetHintBoolean("SDL_LEGACY_VERSION", SDL_FALSE);
-    }
-
-    if (legacy_version) {
-        /* Prior to SDL 2.24.0, the patch version was incremented with every release */
-        ver->patch = ver->minor;
-        ver->minor = 0;
-    }
-    return 0;
+    return SDL_VERSION;
 }
 
 /* Get the library source revision */

+ 1 - 1
src/core/android/SDL_android.c

@@ -567,7 +567,7 @@ JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetVersion)(JNIEnv *env, jcla
 {
     char version[128];
 
-    SDL_snprintf(version, sizeof(version), "%d.%d.%d", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
+    SDL_snprintf(version, sizeof(version), "%d.%d.%d", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
 
     return (*env)->NewStringUTF(env, version);
 }

+ 1 - 1
src/dynapi/SDL_dynapi_procs.h

@@ -511,7 +511,7 @@ SDL_DYNAPI_PROC(SDL_TouchDeviceType,SDL_GetTouchDeviceType,(SDL_TouchID a),(a),r
 SDL_DYNAPI_PROC(SDL_TouchID*,SDL_GetTouchDevices,(int *a),(a),return)
 SDL_DYNAPI_PROC(SDL_Finger**,SDL_GetTouchFingers,(SDL_TouchID a, int *b),(a,b),return)
 SDL_DYNAPI_PROC(char*,SDL_GetUserFolder,(SDL_Folder a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_GetVersion,(SDL_Version *a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_GetVersion,(void),(),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetVideoDriver,(int a),(a),return)
 SDL_DYNAPI_PROC(int,SDL_GetWindowBordersSize,(SDL_Window *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return)
 SDL_DYNAPI_PROC(float,SDL_GetWindowDisplayScale,(SDL_Window *a),(a),return)

+ 9 - 44
test/testautomation_platform.c

@@ -209,41 +209,11 @@ static int platform_testHasFunctions(void *arg)
  */
 static int platform_testGetVersion(void *arg)
 {
-    SDL_Version linked;
-    int major = SDL_MAJOR_VERSION;
-    int minor = SDL_MINOR_VERSION;
-
-    SDL_GetVersion(&linked);
-    SDLTest_AssertCheck(linked.major >= major,
-                        "SDL_GetVersion(): returned major %i (>= %i)",
-                        linked.major,
-                        major);
-    SDLTest_AssertCheck(linked.minor >= minor,
-                        "SDL_GetVersion(): returned minor %i (>= %i)",
-                        linked.minor,
-                        minor);
-
-    return TEST_COMPLETED;
-}
-
-/**
- * Tests SDL_VERSION macro
- */
-static int platform_testSDLVersion(void *arg)
-{
-    SDL_Version compiled;
-    int major = SDL_MAJOR_VERSION;
-    int minor = SDL_MINOR_VERSION;
-
-    SDL_VERSION(&compiled);
-    SDLTest_AssertCheck(compiled.major >= major,
-                        "SDL_VERSION() returned major %i (>= %i)",
-                        compiled.major,
-                        major);
-    SDLTest_AssertCheck(compiled.minor >= minor,
-                        "SDL_VERSION() returned minor %i (>= %i)",
-                        compiled.minor,
-                        minor);
+    int linked = SDL_GetVersion();
+    SDLTest_AssertCheck(linked >= SDL_VERSION,
+                        "SDL_GetVersion(): returned version %d (>= %d)",
+                        linked,
+                        SDL_VERSION);
 
     return TEST_COMPLETED;
 }
@@ -544,26 +514,22 @@ static const SDLTest_TestCaseReference platformTest5 = {
 };
 
 static const SDLTest_TestCaseReference platformTest6 = {
-    (SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED
-};
-
-static const SDLTest_TestCaseReference platformTest7 = {
     (SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED
 };
 
-static const SDLTest_TestCaseReference platformTest8 = {
+static const SDLTest_TestCaseReference platformTest7 = {
     (SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED
 };
 
-static const SDLTest_TestCaseReference platformTest9 = {
+static const SDLTest_TestCaseReference platformTest8 = {
     (SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED
 };
 
-static const SDLTest_TestCaseReference platformTest10 = {
+static const SDLTest_TestCaseReference platformTest9 = {
     (SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED
 };
 
-static const SDLTest_TestCaseReference platformTest11 = {
+static const SDLTest_TestCaseReference platformTest10 = {
     (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED
 };
 
@@ -579,7 +545,6 @@ static const SDLTest_TestCaseReference *platformTests[] = {
     &platformTest8,
     &platformTest9,
     &platformTest10,
-    &platformTest11,
     NULL
 };
 

+ 4 - 8
test/testver.c

@@ -19,9 +19,6 @@
 
 int main(int argc, char *argv[])
 {
-    SDL_Version compiled;
-    SDL_Version linked;
-
     /* Enable standard application logging */
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
@@ -35,13 +32,12 @@ int main(int argc, char *argv[])
 #else
     SDL_Log("Compiled with SDL older than 3.0\n");
 #endif
-    SDL_VERSION(&compiled);
     SDL_Log("Compiled version: %d.%d.%d (%s)\n",
-            compiled.major, compiled.minor, compiled.patch,
+            SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION,
             SDL_REVISION);
-    SDL_GetVersion(&linked);
-    SDL_Log("Linked version: %d.%d.%d (%s)\n",
-            linked.major, linked.minor, linked.patch,
+    int version = SDL_GetVersion();
+    SDL_Log("Runtime version: %d.%d.%d (%s)\n",
+            SDL_VERSIONNUM_MAJOR(version), SDL_VERSIONNUM_MINOR(version), SDL_VERSIONNUM_MICRO(version),
             SDL_GetRevision());
     SDL_Quit();
     return 0;