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:
Sam Lantinga 2024-05-14 07:47:13 -07:00
parent 5a0879b7dd
commit 661f2fc1fc
20 changed files with 162 additions and 224 deletions

View file

@ -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
@@

View file

@ -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}"

View file

@ -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):

View file

@ -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")

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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