mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-10-26 12:27:44 +00:00 
			
		
		
		
	Removed the SDL_Version structure, moved SDL version to SDL.h
Inspired by https://github.com/libsdl-org/SDL/issues/9788
This commit is contained in:
		| @@ -5,10 +5,10 @@ wikisubdir = | |||||||
| readmesubdir = docs | readmesubdir = docs | ||||||
| apiprefixregex = (SDL_|SDLK_) | apiprefixregex = (SDL_|SDLK_) | ||||||
| mainincludefname = SDL3/SDL.h | 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 | versionmajorregex = \A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z | ||||||
| versionminorregex = \A\#define\s+SDL_MINOR_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 | selectheaderregex = \ASDL.*?\.h\Z | ||||||
| projecturl = https://libsdl.org/ | projecturl = https://libsdl.org/ | ||||||
| wikiurl = https://wiki.libsdl.org | wikiurl = https://wiki.libsdl.org | ||||||
|   | |||||||
| @@ -3,22 +3,22 @@ | |||||||
| # SDL CMake version configuration file: | # SDL CMake version configuration file: | ||||||
| # This file is meant to be placed in a cmake subfolder of SDL3-devel-3.x.y-VC | # 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") | if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../include/SDL3/SDL.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") |     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() |     return() | ||||||
| endif() | 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}") | string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re "${_sdl_version_h}") | ||||||
| set(_sdl_major "${CMAKE_MATCH_1}") | set(_sdl_major "${CMAKE_MATCH_1}") | ||||||
| string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}") | string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}") | ||||||
| set(_sdl_minor "${CMAKE_MATCH_1}") | set(_sdl_minor "${CMAKE_MATCH_1}") | ||||||
| string(REGEX MATCH "#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_version_h}") | string(REGEX MATCH "#define[ \t]+SDL_MICRO_VERSION[ \t]+([0-9]+)" _sdl_micro_re "${_sdl_version_h}") | ||||||
| set(_sdl_patch "${CMAKE_MATCH_1}") | set(_sdl_micro "${CMAKE_MATCH_1}") | ||||||
| if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re) | if(_sdl_major_re AND _sdl_minor_re AND _sdl_micro_re) | ||||||
|     set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}") |     set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_micro}") | ||||||
| else() | 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() |     return() | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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)           # / | 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_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_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}") | 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") |     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}") | set(_sdl_major "${CMAKE_MATCH_1}") | ||||||
| string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}") | string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}") | ||||||
| set(_sdl_minor "${CMAKE_MATCH_1}") | set(_sdl_minor "${CMAKE_MATCH_1}") | ||||||
| string(REGEX MATCH "#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_version_h}") | string(REGEX MATCH "#define[ \t]+SDL_MICRO_VERSION[ \t]+([0-9]+)" _sdl_micro_re "${_sdl_version_h}") | ||||||
| set(_sdl_patch "${CMAKE_MATCH_1}") | set(_sdl_micro "${CMAKE_MATCH_1}") | ||||||
| if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re) | if(_sdl_major_re AND _sdl_minor_re AND _sdl_micro_re) | ||||||
|     set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}") |     set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_micro}") | ||||||
| else() | else() | ||||||
|     message(AUTHOR_WARNING "Could not extract version from SDL_version.h.") |     message(AUTHOR_WARNING "Could not extract version from SDL.h.") | ||||||
|     return() |     return() | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
| @@ -43,8 +43,8 @@ unset(_sdl_major_re) | |||||||
| unset(_sdl_major) | unset(_sdl_major) | ||||||
| unset(_sdl_minor_re) | unset(_sdl_minor_re) | ||||||
| unset(_sdl_minor) | unset(_sdl_minor) | ||||||
| unset(_sdl_patch_re) | unset(_sdl_micro_re) | ||||||
| unset(_sdl_patch) | unset(_sdl_micro) | ||||||
|  |  | ||||||
| if(PACKAGE_FIND_VERSION_RANGE) | if(PACKAGE_FIND_VERSION_RANGE) | ||||||
|     # Package version must be in the requested version range |     # Package version must be in the requested version range | ||||||
|   | |||||||
| @@ -2985,11 +2985,6 @@ SDL_GamepadBinding *e1; | |||||||
| - e1->outputType | - e1->outputType | ||||||
| + e1->output_type | + e1->output_type | ||||||
| @@ | @@ | ||||||
| typedef SDL_version, SDL_Version; |  | ||||||
| @@ |  | ||||||
| - SDL_version |  | ||||||
| + SDL_Version |  | ||||||
| @@ |  | ||||||
| @@ | @@ | ||||||
| - SDL_HINT_ALLOW_TOPMOST | - SDL_HINT_ALLOW_TOPMOST | ||||||
| + SDL_HINT_WINDOW_ALLOW_TOPMOST | + SDL_HINT_WINDOW_ALLOW_TOPMOST | ||||||
| @@ -3137,15 +3132,23 @@ typedef SDL_Colour, SDL_Color; | |||||||
|   (...) |   (...) | ||||||
| @@ | @@ | ||||||
| @@ | @@ | ||||||
| - SDL_TABLESIZE |  | ||||||
| + SDL_arraysize |  | ||||||
| @@ |  | ||||||
| @@ |  | ||||||
| - SDL_iPhoneSetEventPump | - SDL_iPhoneSetEventPump | ||||||
| + SDL_iOSSetEventPump | + SDL_iOSSetEventPump | ||||||
|   (...) |   (...) | ||||||
| @@ | @@ | ||||||
| @@ | @@ | ||||||
|  | - SDL_COMPILEDVERSION | ||||||
|  | + SDL_VERSION | ||||||
|  | @@ | ||||||
|  | @@ | ||||||
|  | - SDL_PATCHLEVEL | ||||||
|  | + SDL_MICRO_VERSION | ||||||
|  | @@ | ||||||
|  | @@ | ||||||
|  | - SDL_TABLESIZE | ||||||
|  | + SDL_arraysize | ||||||
|  | @@ | ||||||
|  | @@ | ||||||
| - SDLK_QUOTE | - SDLK_QUOTE | ||||||
| + SDLK_APOSTROPHE | + SDLK_APOSTROPHE | ||||||
| @@ | @@ | ||||||
|   | |||||||
| @@ -40,10 +40,10 @@ android_api=19 | |||||||
| android_ndk=21 | android_ndk=21 | ||||||
| android_stl="c++_shared" | android_stl="c++_shared" | ||||||
|  |  | ||||||
| sdl_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION  *//p' "${sdl_root}/include/SDL3/SDL_version.h") | 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_version.h") | sdl_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION  *//p' "${sdl_root}/include/SDL3/SDL.h") | ||||||
| sdl_patch=$(sed -ne 's/^#define SDL_PATCHLEVEL  *//p' "${sdl_root}/include/SDL3/SDL_version.h") | sdl_micro=$(sed -ne 's/^#define SDL_MICRO_VERSION  *//p' "${sdl_root}/include/SDL3/SDL.h") | ||||||
| sdl_version="${sdl_major}.${sdl_minor}.${sdl_patch}" | sdl_version="${sdl_major}.${sdl_minor}.${sdl_micro}" | ||||||
| echo "Building Android prefab package for SDL version $sdl_version" | echo "Building Android prefab package for SDL version $sdl_version" | ||||||
|  |  | ||||||
| prefabhome="${build_root}/prefab-${sdl_version}" | prefabhome="${build_root}/prefab-${sdl_version}" | ||||||
|   | |||||||
| @@ -509,12 +509,12 @@ class Releaser: | |||||||
|  |  | ||||||
|     @classmethod |     @classmethod | ||||||
|     def extract_sdl_version(cls, root: Path, project: str): |     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() |             text = f.read() | ||||||
|         major = next(re.finditer(r"^#define SDL_MAJOR_VERSION\s+([0-9]+)$", text, flags=re.M)).group(1) |         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) |         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) |         micro = next(re.finditer(r"^#define SDL_MICRO_VERSION\s+([0-9]+)$", text, flags=re.M)).group(1) | ||||||
|         return f"{major}.{minor}.{patch}" |         return f"{major}.{minor}.{micro}" | ||||||
|  |  | ||||||
|  |  | ||||||
| def main(argv=None): | def main(argv=None): | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ def main(): | |||||||
|         exit(1) |         exit(1) | ||||||
|  |  | ||||||
|     # Check whether we can still modify the ABI |     # 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): |     if not re.search("SDL_MINOR_VERSION\s+[01]\s", version_header): | ||||||
|         raise Exception("ABI is frozen, symbols cannot be renamed") |         raise Exception("ABI is frozen, symbols cannot be renamed") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,9 +10,9 @@ if [ -e ./VERSION.txt ]; then | |||||||
|     exit 0 |     exit 0 | ||||||
| fi | fi | ||||||
|  |  | ||||||
| major=$(sed -ne 's/^#define SDL_MAJOR_VERSION  *//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_version.h) | minor=$(sed -ne 's/^#define SDL_MINOR_VERSION  *//p' include/SDL3/SDL.h) | ||||||
| micro=$(sed -ne 's/^#define SDL_PATCHLEVEL  *//p' include/SDL3/SDL_version.h) | micro=$(sed -ne 's/^#define SDL_MICRO_VERSION  *//p' include/SDL3/SDL.h) | ||||||
| version="${major}.${minor}.${micro}" | version="${major}.${minor}.${micro}" | ||||||
|  |  | ||||||
| if [ -x "$(command -v git)" ]; then | if [ -x "$(command -v git)" ]; then | ||||||
|   | |||||||
| @@ -6,9 +6,9 @@ set -eu | |||||||
|  |  | ||||||
| cd `dirname $0`/.. | cd `dirname $0`/.. | ||||||
|  |  | ||||||
| ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION  *//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_version.h) | ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION  *//p' include/SDL3/SDL.h) | ||||||
| ref_micro=$(sed -ne 's/^#define SDL_PATCHLEVEL  *//p' include/SDL3/SDL_version.h) | ref_micro=$(sed -ne 's/^#define SDL_MICRO_VERSION  *//p' include/SDL3/SDL.h) | ||||||
| ref_version="${ref_major}.${ref_minor}.${ref_micro}" | ref_version="${ref_major}.${ref_minor}.${ref_micro}" | ||||||
|  |  | ||||||
| tests=0 | 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 | if [ "$ref_version" = "$version" ]; then | ||||||
|     ok "CMakeLists.txt $version" |     ok "CMakeLists.txt $version" | ||||||
| else | 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 | fi | ||||||
|  |  | ||||||
| major=$(sed -ne 's/.*SDL_MAJOR_VERSION = \([0-9]*\);/\1/p' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java) | 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 | if [ "$ref_version" = "$version" ]; then | ||||||
|     ok "SDLActivity.java $version" |     ok "SDLActivity.java $version" | ||||||
| else | 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 | fi | ||||||
|  |  | ||||||
| tuple=$(sed -ne 's/^ *FILEVERSION *//p' src/core/windows/version.rc | tr -d '\r') | 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 | if [ "$ref_tuple" = "$tuple" ]; then | ||||||
|     ok "version.rc FILEVERSION $tuple" |     ok "version.rc FILEVERSION $tuple" | ||||||
| else | 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 | fi | ||||||
|  |  | ||||||
| tuple=$(sed -ne 's/^ *PRODUCTVERSION *//p' src/core/windows/version.rc | tr -d '\r') | 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 | if [ "$ref_tuple" = "$tuple" ]; then | ||||||
|     ok "version.rc PRODUCTVERSION $tuple" |     ok "version.rc PRODUCTVERSION $tuple" | ||||||
| else | 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 | fi | ||||||
|  |  | ||||||
| tuple=$(sed -Ene 's/^ *VALUE "FileVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/core/windows/version.rc | tr -d '\r') | 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 | if [ "$ref_tuple" = "$tuple" ]; then | ||||||
|     ok "version.rc FileVersion $tuple" |     ok "version.rc FileVersion $tuple" | ||||||
| else | 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 | fi | ||||||
|  |  | ||||||
| tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/core/windows/version.rc | tr -d '\r') | 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 | if [ "$ref_tuple" = "$tuple" ]; then | ||||||
|     ok "version.rc ProductVersion $tuple" |     ok "version.rc ProductVersion $tuple" | ||||||
| else | 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 | fi | ||||||
|  |  | ||||||
| version=$(sed -Ene '/CFBundleShortVersionString/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist) | 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 | if [ "$ref_version" = "$version" ]; then | ||||||
|     ok "Info-Framework.plist CFBundleShortVersionString $version" |     ok "Info-Framework.plist CFBundleShortVersionString $version" | ||||||
| else | 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 | fi | ||||||
|  |  | ||||||
| version=$(sed -Ene '/CFBundleVersion/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist) | 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 | if [ "$ref_version" = "$version" ]; then | ||||||
|     ok "Info-Framework.plist CFBundleVersion $version" |     ok "Info-Framework.plist CFBundleVersion $version" | ||||||
| else | 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 | fi | ||||||
|  |  | ||||||
| version=$(sed -Ene 's/Title SDL (.*)/\1/p' Xcode/SDL/pkg-support/SDL.info) | 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 | if [ "$ref_version" = "$version" ]; then | ||||||
|     ok "SDL.info Title $version" |     ok "SDL.info Title $version" | ||||||
| else | 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 | fi | ||||||
|  |  | ||||||
| marketing=$(sed -Ene 's/.*MARKETING_VERSION = (.*);/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj) | marketing=$(sed -Ene 's/.*MARKETING_VERSION = (.*);/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj) | ||||||
|   | |||||||
| @@ -22,8 +22,8 @@ fi | |||||||
|  |  | ||||||
| MAJOR="$1" | MAJOR="$1" | ||||||
| MINOR="$2" | MINOR="$2" | ||||||
| PATCH="$3" | MICRO="$3" | ||||||
| NEWVERSION="$MAJOR.$MINOR.$PATCH" | NEWVERSION="$MAJOR.$MINOR.$MICRO" | ||||||
|  |  | ||||||
| echo "Updating version to '$NEWVERSION' ..." | 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 | 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? | # non-zero patch? | ||||||
| if [ "x$PATCH" != "x0" ]; then | if [ "x$MICRO" != "x0" ]; then | ||||||
|     if [ `expr $MINOR % 2` = "0" ]; then |     if [ `expr $MINOR % 2` = "0" ]; then | ||||||
|         # If patch is not zero, but minor is even, it's a bugfix release. |         # 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 |     else | ||||||
|         # If patch is not zero, but minor is odd, it's a development prerelease. |         # 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_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 |         perl -w -pi -e 's/(DYLIB_COMPATIBILITY_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj | ||||||
|     fi |     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_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_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_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_version.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_PATCHLEVEL\s+)\d+/${1}'$PATCH'/;' include/SDL3/SDL_version.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/(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','$PATCH'/;' 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', '$PATCH'/;' 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', '$PATCH'/;' 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..." | echo "Running build-scripts/test-versioning.sh to verify changes..." | ||||||
| ./build-scripts/test-versioning.sh | ./build-scripts/test-versioning.sh | ||||||
|   | |||||||
| @@ -13,10 +13,10 @@ my $wikisubdir = ''; | |||||||
| my $incsubdir = 'include'; | my $incsubdir = 'include'; | ||||||
| my $readmesubdir = undef; | my $readmesubdir = undef; | ||||||
| my $apiprefixregex = 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 $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z'; | ||||||
| my $versionminorregex = '\A\#define\s+SDL_MINOR_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 $mainincludefname = 'SDL.h'; | ||||||
| my $selectheaderregex = '\ASDL.*?\.h\Z'; | my $selectheaderregex = '\ASDL.*?\.h\Z'; | ||||||
| my $projecturl = 'https://libsdl.org/'; | my $projecturl = 'https://libsdl.org/'; | ||||||
| @@ -92,7 +92,7 @@ if (defined $optionsfname) { | |||||||
|             $readmesubdir = $val, next if $key eq 'readmesubdir'; |             $readmesubdir = $val, next if $key eq 'readmesubdir'; | ||||||
|             $versionmajorregex = $val, next if $key eq 'versionmajorregex'; |             $versionmajorregex = $val, next if $key eq 'versionmajorregex'; | ||||||
|             $versionminorregex = $val, next if $key eq 'versionminorregex'; |             $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'; |             $versionfname = $val, next if $key eq 'versionfname'; | ||||||
|             $mainincludefname = $val, next if $key eq 'mainincludefname'; |             $mainincludefname = $val, next if $key eq 'mainincludefname'; | ||||||
|             $selectheaderregex = $val, next if $key eq 'selectheaderregex'; |             $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"); |     open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n"); | ||||||
|     my $majorver = 0; |     my $majorver = 0; | ||||||
|     my $minorver = 0; |     my $minorver = 0; | ||||||
|     my $patchver = 0; |     my $microver = 0; | ||||||
|     while (<FH>) { |     while (<FH>) { | ||||||
|         chomp; |         chomp; | ||||||
|         if (/$versionmajorregex/) { |         if (/$versionmajorregex/) { | ||||||
|             $majorver = int($1); |             $majorver = int($1); | ||||||
|         } elsif (/$versionminorregex/) { |         } elsif (/$versionminorregex/) { | ||||||
|             $minorver = int($1); |             $minorver = int($1); | ||||||
|         } elsif (/$versionpatchregex/) { |         } elsif (/$versionmicroregex/) { | ||||||
|             $patchver = int($1); |             $microver = int($1); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     close(FH); |     close(FH); | ||||||
|     my $fullversion = "$majorver.$minorver.$patchver"; |     my $fullversion = "$majorver.$minorver.$microver"; | ||||||
|  |  | ||||||
|     foreach (keys %headersyms) { |     foreach (keys %headersyms) { | ||||||
|         my $sym = $_; |         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"); |     open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n"); | ||||||
|     my $majorver = 0; |     my $majorver = 0; | ||||||
|     my $minorver = 0; |     my $minorver = 0; | ||||||
|     my $patchver = 0; |     my $microver = 0; | ||||||
|     while (<FH>) { |     while (<FH>) { | ||||||
|         chomp; |         chomp; | ||||||
|         if (/$versionmajorregex/) { |         if (/$versionmajorregex/) { | ||||||
|             $majorver = int($1); |             $majorver = int($1); | ||||||
|         } elsif (/$versionminorregex/) { |         } elsif (/$versionminorregex/) { | ||||||
|             $minorver = int($1); |             $minorver = int($1); | ||||||
|         } elsif (/$versionpatchregex/) { |         } elsif (/$versionmicroregex/) { | ||||||
|             $patchver = int($1); |             $microver = int($1); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     close(FH); |     close(FH); | ||||||
|     my $fullversion = "$majorver.$minorver.$patchver"; |     my $fullversion = "$majorver.$minorver.$microver"; | ||||||
|  |  | ||||||
|     my $latex_fname = "$srcpath/$projectshortname.tex"; |     my $latex_fname = "$srcpath/$projectshortname.tex"; | ||||||
|     my $latex_tmpfname = "$latex_fname.tmp"; |     my $latex_tmpfname = "$latex_fname.tmp"; | ||||||
| @@ -2369,7 +2369,7 @@ if ($copy_direction == 1) {  # --copy-to-headers | |||||||
| \\begin{document} | \\begin{document} | ||||||
| \\frontmatter | \\frontmatter | ||||||
|  |  | ||||||
| \\title{$projectfullname $majorver.$minorver.$patchver Reference Manual} | \\title{$projectfullname $majorver.$minorver.$microver Reference Manual} | ||||||
| \\author{The $projectshortname Developers} | \\author{The $projectshortname Developers} | ||||||
| \\maketitle | \\maketitle | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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_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: | The following structures have been removed: | ||||||
| * SDL_version => SDL_Version | * SDL_version | ||||||
|  |  | ||||||
|  | The following symbols have been renamed: | ||||||
|  | * SDL_COMPILEDVERSION => SDL_VERSION | ||||||
|  | * SDL_PATCHLEVEL => SDL_MICRO_VERSION | ||||||
|  |  | ||||||
| ## SDL_video.h | ## SDL_video.h | ||||||
|  |  | ||||||
|   | |||||||
| @@ -28,6 +28,14 @@ | |||||||
| #ifndef SDL_h_ | #ifndef SDL_h_ | ||||||
| #define 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_stdinc.h> | ||||||
| #include <SDL3/SDL_assert.h> | #include <SDL3/SDL_assert.h> | ||||||
| #include <SDL3/SDL_atomic.h> | #include <SDL3/SDL_atomic.h> | ||||||
|   | |||||||
| @@ -529,7 +529,8 @@ | |||||||
| #define SDL_GetTicks64 SDL_GetTicks | #define SDL_GetTicks64 SDL_GetTicks | ||||||
|  |  | ||||||
| /* ##SDL_version.h */ | /* ##SDL_version.h */ | ||||||
| #define SDL_version SDL_Version | #define SDL_COMPILEDVERSION SDL_VERSION | ||||||
|  | #define SDL_PATCHLEVEL SDL_MICRO_VERSION | ||||||
|  |  | ||||||
| /* ##SDL_video.h */ | /* ##SDL_video.h */ | ||||||
| #define SDL_GetClosestDisplayMode SDL_GetClosestFullscreenDisplayMode | #define SDL_GetClosestDisplayMode SDL_GetClosestFullscreenDisplayMode | ||||||
| @@ -1038,7 +1039,8 @@ | |||||||
| #define SDL_GetTicks64 SDL_GetTicks64_renamed_SDL_GetTicks | #define SDL_GetTicks64 SDL_GetTicks64_renamed_SDL_GetTicks | ||||||
|  |  | ||||||
| /* ##SDL_version.h */ | /* ##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 */ | /* ##SDL_video.h */ | ||||||
| #define SDL_GetClosestDisplayMode SDL_GetClosestDisplayMode_renamed_SDL_GetClosestFullscreenDisplayMode | #define SDL_GetClosestDisplayMode SDL_GetClosestDisplayMode_renamed_SDL_GetClosestFullscreenDisplayMode | ||||||
|   | |||||||
| @@ -37,59 +37,10 @@ | |||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Information about the version of SDL in use. |  | ||||||
|  * |  | ||||||
|  * 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). |  | ||||||
|  * |  | ||||||
|  * \since This struct is available since SDL 3.0.0. |  | ||||||
|  * |  | ||||||
|  * \sa SDL_VERSION |  | ||||||
|  * \sa SDL_GetVersion |  | ||||||
|  */ |  | ||||||
| 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 |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Macro to determine SDL version program was compiled against. |  | ||||||
|  * |  | ||||||
|  * 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. |  | ||||||
|  * |  | ||||||
|  * \param x A pointer to an SDL_Version struct to initialize. |  | ||||||
|  * |  | ||||||
|  * \since This macro is available since SDL 3.0.0. |  | ||||||
|  * |  | ||||||
|  * \sa SDL_Version |  | ||||||
|  * \sa SDL_GetVersion |  | ||||||
|  */ |  | ||||||
| #define SDL_VERSION(x)                \ |  | ||||||
| {                                     \ |  | ||||||
|     (x)->major = SDL_MAJOR_VERSION;   \ |  | ||||||
|     (x)->minor = SDL_MINOR_VERSION;   \ |  | ||||||
|     (x)->patch = SDL_PATCHLEVEL;      \ |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * This macro turns the version numbers into a numeric value. |  * This macro turns the version numbers into a numeric value. | ||||||
|  * |  * | ||||||
|  * (1,2,3) becomes 0x1000203. |  * (1,2,3) becomes 1002003. | ||||||
|  * |  * | ||||||
|  * \param major the major version number. |  * \param major the major version number. | ||||||
|  * \param minor the minorversion number. |  * \param minor the minorversion number. | ||||||
| @@ -98,15 +49,48 @@ typedef struct SDL_Version | |||||||
|  * \since This macro is available since SDL 3.0.0. |  * \since This macro is available since SDL 3.0.0. | ||||||
|  */ |  */ | ||||||
| #define SDL_VERSIONNUM(major, minor, patch) \ | #define SDL_VERSIONNUM(major, minor, patch) \ | ||||||
|     ((major) << 24 | (minor) << 8 | (patch) << 0) |     ((major) * 1000000 + (minor) * 1000 + (patch)) | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * This macro extracts the major version from a version number | ||||||
|  |  * | ||||||
|  |  * 1002003 becomes 1. | ||||||
|  |  * | ||||||
|  |  * \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 | ||||||
|  |  * | ||||||
|  |  * 1002003 becomes 2. | ||||||
|  |  * | ||||||
|  |  * \param version the version number. | ||||||
|  |  * | ||||||
|  |  * \since This macro is available since SDL 3.0.0. | ||||||
|  |  */ | ||||||
|  | #define SDL_VERSIONNUM_MINOR(version) (((version) / 1000) % 1000) | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * This macro extracts the micro version from a version number | ||||||
|  |  * | ||||||
|  |  * 1002003 becomes 3. | ||||||
|  |  * | ||||||
|  |  * \param version the version number. | ||||||
|  |  * | ||||||
|  |  * \since This macro is available since SDL 3.0.0. | ||||||
|  |  */ | ||||||
|  | #define SDL_VERSIONNUM_MICRO(version) ((version) % 1000) | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * This is the version number macro for the current SDL version. |  * This is the version number macro for the current SDL version. | ||||||
|  * |  * | ||||||
|  * \since This macro is available since SDL 3.0.0. |  * \since This macro is available since SDL 3.0.0. | ||||||
|  */ |  */ | ||||||
| #define SDL_COMPILEDVERSION \ | #define SDL_VERSION \ | ||||||
|     SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) |     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. |  * 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. |  * \since This macro is available since SDL 3.0.0. | ||||||
|  */ |  */ | ||||||
| #define SDL_VERSION_ATLEAST(X, Y, Z) \ | #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. |  * 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 |  * 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 |  * version will be different than the version you compiled against. This | ||||||
|  * function returns the current version, while SDL_VERSION() is a macro that |  * function returns the current version, while SDL_VERSION is the version you | ||||||
|  * tells you what version you compiled with. |  * compiled with. | ||||||
|  * |  * | ||||||
|  * This function may be called safely at any time, even before SDL_Init(). |  * 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 the version of the linked library. | ||||||
|  * \returns 0 on success or a negative error code on failure; call |  | ||||||
|  *          SDL_GetError() for more information. |  | ||||||
|  * |  * | ||||||
|  * \since This function is available since SDL 3.0.0. |  * \since This function is available since SDL 3.0.0. | ||||||
|  * |  * | ||||||
|  * \sa SDL_GetRevision |  * \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. |  * Get the code revision of SDL that is linked against your program. | ||||||
|   | |||||||
							
								
								
									
										39
									
								
								src/SDL.c
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								src/SDL.c
									
									
									
									
									
								
							| @@ -65,20 +65,16 @@ SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MAJOR_VERSION, | |||||||
| SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MINOR_VERSION, | SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MINOR_VERSION, | ||||||
|                         SDL_MINOR_VERSION == SDL_BUILD_MINOR_VERSION); |                         SDL_MINOR_VERSION == SDL_BUILD_MINOR_VERSION); | ||||||
| SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MICRO_VERSION, | SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MICRO_VERSION, | ||||||
|                         SDL_PATCHLEVEL == SDL_BUILD_MICRO_VERSION); |                         SDL_MICRO_VERSION == SDL_BUILD_MICRO_VERSION); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | /* Limited by its encoding in SDL_VERSIONNUM */ | ||||||
| SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_min, SDL_MAJOR_VERSION >= 0); | 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 <= 10); | ||||||
| SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_max, SDL_MAJOR_VERSION <= 255); |  | ||||||
|  |  | ||||||
| SDL_COMPILE_TIME_ASSERT(SDL_MINOR_VERSION_min, SDL_MINOR_VERSION >= 0); | 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 <= 999); | ||||||
| SDL_COMPILE_TIME_ASSERT(SDL_MINOR_VERSION_max, SDL_MINOR_VERSION <= 255); | SDL_COMPILE_TIME_ASSERT(SDL_MICRO_VERSION_min, SDL_MICRO_VERSION >= 0); | ||||||
|  | SDL_COMPILE_TIME_ASSERT(SDL_MICRO_VERSION_max, SDL_MICRO_VERSION <= 999); | ||||||
| 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); |  | ||||||
|  |  | ||||||
| /* This is not declared in any header, although it is shared between some | /* 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 |     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 */ | /* Get the library version number */ | ||||||
| int SDL_GetVersion(SDL_Version *ver) | int SDL_GetVersion(void) | ||||||
| { | { | ||||||
|     static SDL_bool check_hint = SDL_TRUE; |     return SDL_VERSION; | ||||||
|     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; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Get the library source revision */ | /* Get the library source revision */ | ||||||
|   | |||||||
| @@ -567,7 +567,7 @@ JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetVersion)(JNIEnv *env, jcla | |||||||
| { | { | ||||||
|     char version[128]; |     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); |     return (*env)->NewStringUTF(env, version); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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_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(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(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(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(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) | SDL_DYNAPI_PROC(float,SDL_GetWindowDisplayScale,(SDL_Window *a),(a),return) | ||||||
|   | |||||||
| @@ -209,41 +209,11 @@ static int platform_testHasFunctions(void *arg) | |||||||
|  */ |  */ | ||||||
| static int platform_testGetVersion(void *arg) | static int platform_testGetVersion(void *arg) | ||||||
| { | { | ||||||
|     SDL_Version linked; |     int linked = SDL_GetVersion(); | ||||||
|     int major = SDL_MAJOR_VERSION; |     SDLTest_AssertCheck(linked >= SDL_VERSION, | ||||||
|     int minor = SDL_MINOR_VERSION; |                         "SDL_GetVersion(): returned version %d (>= %d)", | ||||||
|  |                         linked, | ||||||
|     SDL_GetVersion(&linked); |                         SDL_VERSION); | ||||||
|     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); |  | ||||||
|  |  | ||||||
|     return TEST_COMPLETED; |     return TEST_COMPLETED; | ||||||
| } | } | ||||||
| @@ -544,26 +514,22 @@ static const SDLTest_TestCaseReference platformTest5 = { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| static const SDLTest_TestCaseReference platformTest6 = { | 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 |     (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 |     (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 |     (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 |     (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 |     (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -579,7 +545,6 @@ static const SDLTest_TestCaseReference *platformTests[] = { | |||||||
|     &platformTest8, |     &platformTest8, | ||||||
|     &platformTest9, |     &platformTest9, | ||||||
|     &platformTest10, |     &platformTest10, | ||||||
|     &platformTest11, |  | ||||||
|     NULL |     NULL | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,9 +19,6 @@ | |||||||
|  |  | ||||||
| int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||||||
| { | { | ||||||
|     SDL_Version compiled; |  | ||||||
|     SDL_Version linked; |  | ||||||
|  |  | ||||||
|     /* Enable standard application logging */ |     /* Enable standard application logging */ | ||||||
|     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); |     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); | ||||||
|  |  | ||||||
| @@ -35,13 +32,12 @@ int main(int argc, char *argv[]) | |||||||
| #else | #else | ||||||
|     SDL_Log("Compiled with SDL older than 3.0\n"); |     SDL_Log("Compiled with SDL older than 3.0\n"); | ||||||
| #endif | #endif | ||||||
|     SDL_VERSION(&compiled); |  | ||||||
|     SDL_Log("Compiled version: %d.%d.%d (%s)\n", |     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_REVISION); | ||||||
|     SDL_GetVersion(&linked); |     int version = SDL_GetVersion(); | ||||||
|     SDL_Log("Linked version: %d.%d.%d (%s)\n", |     SDL_Log("Runtime version: %d.%d.%d (%s)\n", | ||||||
|             linked.major, linked.minor, linked.patch, |             SDL_VERSIONNUM_MAJOR(version), SDL_VERSIONNUM_MINOR(version), SDL_VERSIONNUM_MICRO(version), | ||||||
|             SDL_GetRevision()); |             SDL_GetRevision()); | ||||||
|     SDL_Quit(); |     SDL_Quit(); | ||||||
|     return 0; |     return 0; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sam Lantinga
					Sam Lantinga