Skip to content

Commit

Permalink
Updated for SDL3 version changes
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed May 15, 2024
1 parent a34ccf1 commit c6aac65
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .wikiheaders-options
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mainincludefname = SDL3_image/SDL_image.h
versionfname = include/SDL3_image/SDL_image.h
versionmajorregex = \A\#define\s+SDL_IMAGE_MAJOR_VERSION\s+(\d+)\Z
versionminorregex = \A\#define\s+SDL_IMAGE_MINOR_VERSION\s+(\d+)\Z
versionpatchregex = \A\#define\s+SDL_IMAGE_PATCHLEVEL\s+(\d+)\Z
versionmicroregex = \A\#define\s+SDL_IMAGE_MICRO_VERSION\s+(\d+)\Z
selectheaderregex = \ASDL_image\.h\Z
projecturl = https://libsdl.org/projects/SDL_image
wikiurl = https://wiki.libsdl.org/SDL_image
Expand Down
8 changes: 4 additions & 4 deletions VisualC/pkg-support/cmake/sdl3_image-config-version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ string(REGEX MATCH "#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_maj
set(_sdl_major "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_image_h}")
set(_sdl_minor "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_image_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_IMAGE_MICRO_VERSION[ \t]+([0-9]+)" _sdl_micro_re "${_sdl_image_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_image.h.")
return()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ string(REGEX MATCH "#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_maj
set(_sdl_major "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_image_h}")
set(_sdl_minor "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_image_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_IMAGE_MICRO_VERSION[ \t]+([0-9]+)" _sdl_micro_re "${_sdl_image_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_image.h.")
return()
Expand Down
4 changes: 2 additions & 2 deletions build-scripts/android-prefab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ android_stl="c++_shared"

sdlimage_major=$(sed -ne 's/^#define SDL_IMAGE_MAJOR_VERSION *//p' "${sdlimage_root}/include/SDL3_image/SDL_image.h")
sdlimage_minor=$(sed -ne 's/^#define SDL_IMAGE_MINOR_VERSION *//p' "${sdlimage_root}/include/SDL3_image/SDL_image.h")
sdlimage_patch=$(sed -ne 's/^#define SDL_IMAGE_PATCHLEVEL *//p' "${sdlimage_root}/include/SDL3_image/SDL_image.h")
sdlimage_version="${sdlimage_major}.${sdlimage_minor}.${sdlimage_patch}"
sdlimage_micro=$(sed -ne 's/^#define SDL_IMAGE_MICRO_VERSION *//p' "${sdlimage_root}/include/SDL3_image/SDL_image.h")
sdlimage_version="${sdlimage_major}.${sdlimage_minor}.${sdlimage_micro}"
echo "Building Android prefab package for SDL_image version $sdlimage_version"

if test ! -d "${sdl_build_root}"; then
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/test-versioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export LC_CTYPE=C
header=include/SDL3_image/SDL_image.h
ref_major=$(sed -ne 's/^#define SDL_IMAGE_MAJOR_VERSION *//p' $header)
ref_minor=$(sed -ne 's/^#define SDL_IMAGE_MINOR_VERSION *//p' $header)
ref_micro=$(sed -ne 's/^#define SDL_IMAGE_PATCHLEVEL *//p' $header)
ref_micro=$(sed -ne 's/^#define SDL_IMAGE_MICRO_VERSION *//p' $header)
ref_version="${ref_major}.${ref_minor}.${ref_micro}"

tests=0
Expand Down
12 changes: 6 additions & 6 deletions build-scripts/wikiheaders.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
my $versionfname = 'include/SDL_version.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/';
Expand Down Expand Up @@ -92,7 +92,7 @@
$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';
Expand Down Expand Up @@ -2036,19 +2036,19 @@ sub print_undocumented_section {
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 = $_;
Expand Down
2 changes: 1 addition & 1 deletion docs/release_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Bump version number to 3.EVEN.0 in all these locations:

* `include/SDL3_image/SDL_image.h`:
`SDL_IMAGE_MAJOR_VERSION`, `SDL_IMAGE_MINOR_VERSION`, `SDL_IMAGE_PATCHLEVEL`
`SDL_IMAGE_MAJOR_VERSION`, `SDL_IMAGE_MINOR_VERSION`, `SDL_IMAGE_MICRO_VERSION`
* `CMakeLists.txt`:
`MAJOR_VERSION`, `MINOR_VERSION`, `MICRO_VERSION`
* `src/version.rc`:
Expand Down
35 changes: 6 additions & 29 deletions include/SDL3_image/SDL_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,55 +38,32 @@ extern "C" {
#endif

/**
* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
* Printable format: "%d.%d.%d", MAJOR, MINOR, MICRO
*/
#define SDL_IMAGE_MAJOR_VERSION 3
#define SDL_IMAGE_MINOR_VERSION 0
#define SDL_IMAGE_PATCHLEVEL 0

/**
* This macro can be used to fill a version structure with the compile-time
* version of the SDL_image library.
*/
#define SDL_IMAGE_VERSION(X) \
{ \
(X)->major = SDL_IMAGE_MAJOR_VERSION; \
(X)->minor = SDL_IMAGE_MINOR_VERSION; \
(X)->patch = SDL_IMAGE_PATCHLEVEL; \
}

#if SDL_IMAGE_MAJOR_VERSION < 3 && SDL_MAJOR_VERSION < 3
#define SDL_IMAGE_MICRO_VERSION 0

/**
* This is the version number macro for the current SDL_image version.
*
* In versions higher than 2.9.0, the minor version overflows into the
* thousands digit: for example, 2.23.0 is encoded as 4300. This macro will
* not be available in SDL 3.x or SDL_image 3.x.
*
* Deprecated, use SDL_IMAGE_VERSION_ATLEAST or SDL_IMAGE_VERSION instead.
*/
#define SDL_IMAGE_COMPILEDVERSION \
SDL_VERSIONNUM(SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_PATCHLEVEL)
#endif /* SDL_IMAGE_MAJOR_VERSION < 3 && SDL_MAJOR_VERSION < 3 */
#define SDL_IMAGE_VERSION \
SDL_VERSIONNUM(SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_MICRO_VERSION)

/**
* This macro will evaluate to true if compiled with SDL_image at least X.Y.Z.
*/
#define SDL_IMAGE_VERSION_ATLEAST(X, Y, Z) \
((SDL_IMAGE_MAJOR_VERSION >= X) && \
(SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION >= Y) && \
(SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION > Y || SDL_IMAGE_PATCHLEVEL >= Z))
(SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION > Y || SDL_IMAGE_MICRO_VERSION >= Z))

/**
* This function gets the version of the dynamically linked SDL_image library.
*
* it should NOT be used to fill a version structure, instead you should use
* the SDL_IMAGE_VERSION() macro.
*
* \returns SDL_image version
*/
extern DECLSPEC const SDL_Version * SDLCALL IMG_Linked_Version(void);
extern DECLSPEC int SDLCALL IMG_Version(void);

/**
* Initialization flags
Expand Down
26 changes: 9 additions & 17 deletions src/IMG.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,22 @@
#include <emscripten/emscripten.h>
#endif

#if defined(SDL_BUILD_MAJOR_VERSION) && defined(SDL_COMPILE_TIME_ASSERT)
#if defined(SDL_BUILD_MAJOR_VERSION)
SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MAJOR_VERSION,
SDL_IMAGE_MAJOR_VERSION == SDL_BUILD_MAJOR_VERSION);
SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MINOR_VERSION,
SDL_IMAGE_MINOR_VERSION == SDL_BUILD_MINOR_VERSION);
SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MICRO_VERSION,
SDL_IMAGE_PATCHLEVEL == SDL_BUILD_MICRO_VERSION);
SDL_IMAGE_MICRO_VERSION == SDL_BUILD_MICRO_VERSION);
#endif

#if defined(SDL_COMPILE_TIME_ASSERT)
/* Limited by its encoding in SDL_VERSIONNUM */
SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_MAJOR_VERSION_min, SDL_IMAGE_MAJOR_VERSION >= 0);
/* Limited only by the need to fit in SDL_Version */
SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_MAJOR_VERSION_max, SDL_IMAGE_MAJOR_VERSION <= 255);

SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_MAJOR_VERSION_max, SDL_IMAGE_MAJOR_VERSION <= 10);
SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_MINOR_VERSION_min, SDL_IMAGE_MINOR_VERSION >= 0);
/* Limited only by the need to fit in SDL_Version */
SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_MINOR_VERSION_max, SDL_IMAGE_MINOR_VERSION <= 255);

SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_PATCHLEVEL_min, SDL_IMAGE_PATCHLEVEL >= 0);
/* Limited by its encoding in SDL_VERSIONNUM and in the ABI versions */
SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_PATCHLEVEL_max, SDL_IMAGE_PATCHLEVEL <= 99);
#endif
SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_MINOR_VERSION_max, SDL_IMAGE_MINOR_VERSION <= 999);
SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_MICRO_VERSION_min, SDL_IMAGE_MICRO_VERSION >= 0);
SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_MICRO_VERSION_max, SDL_IMAGE_MICRO_VERSION <= 999);

/* Table of image detection and loading functions */
static struct {
Expand Down Expand Up @@ -90,11 +84,9 @@ static struct {
{ "WEBP", IMG_isWEBP, IMG_LoadWEBPAnimation_IO },
};

const SDL_Version *IMG_Linked_Version(void)
int IMG_Version(void)
{
static SDL_Version linked_version;
SDL_IMAGE_VERSION(&linked_version)
return(&linked_version);
return SDL_IMAGE_VERSION;
}

static int initialized = 0;
Expand Down

0 comments on commit c6aac65

Please sign in to comment.