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 5af466a commit ffd34fa
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 68 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_ttf/SDL_ttf.h
versionfname = include/SDL3_ttf/SDL_ttf.h
versionmajorregex = \A\#define\s+SDL_TTF_MAJOR_VERSION\s+(\d+)\Z
versionminorregex = \A\#define\s+SDL_TTF_MINOR_VERSION\s+(\d+)\Z
versionpatchregex = \A\#define\s+SDL_TTF_PATCHLEVEL\s+(\d+)\Z
versionmicroregex = \A\#define\s+SDL_TTF_MICRO_VERSION\s+(\d+)\Z
selectheaderregex = \ASDL_ttf\.h\Z
projecturl = https://libsdl.org/projects/SDL_ttf
wikiurl = https://wiki.libsdl.org/SDL_ttf
Expand Down
8 changes: 4 additions & 4 deletions VisualC/pkg-support/cmake/sdl3_ttf-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_TTF_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major
set(_sdl_major "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_ttf_h}")
set(_sdl_minor "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_ttf_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_TTF_MICRO_VERSION[ \t]+([0-9]+)" _sdl_micro_re "${_sdl_ttf_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_ttf.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_TTF_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major
set(_sdl_major "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_ttf_h}")
set(_sdl_minor "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_ttf_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_TTF_MICRO_VERSION[ \t]+([0-9]+)" _sdl_micro_re "${_sdl_ttf_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_ttf.h.")
return()
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_ttf/SDL_ttf.h
ref_major=$(sed -ne 's/^#define SDL_TTF_MAJOR_VERSION *//p' $header)
ref_minor=$(sed -ne 's/^#define SDL_TTF_MINOR_VERSION *//p' $header)
ref_micro=$(sed -ne 's/^#define SDL_TTF_PATCHLEVEL *//p' $header)
ref_micro=$(sed -ne 's/^#define SDL_TTF_MICRO_VERSION *//p' $header)
ref_version="${ref_major}.${ref_minor}.${ref_micro}"

tests=0
Expand Down
22 changes: 11 additions & 11 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 Expand Up @@ -2318,19 +2318,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";

my $latex_fname = "$srcpath/$projectshortname.tex";
my $latex_tmpfname = "$latex_fname.tmp";
Expand Down Expand Up @@ -2369,7 +2369,7 @@ sub print_undocumented_section {
\\begin{document}
\\frontmatter
\\title{$projectfullname $majorver.$minorver.$patchver Reference Manual}
\\title{$projectfullname $majorver.$minorver.$microver Reference Manual}
\\author{The $projectshortname Developers}
\\maketitle
Expand Down
35 changes: 8 additions & 27 deletions include/SDL3_ttf/SDL_ttf.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,53 +45,34 @@ extern "C" {
#endif

/**
* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
* Printable format: "%d.%d.%d", MAJOR, MINOR, MICRO
*/
#define SDL_TTF_MAJOR_VERSION 3
#define SDL_TTF_MINOR_VERSION 0
#define SDL_TTF_PATCHLEVEL 0
#define SDL_TTF_MICRO_VERSION 0

/**
* This macro can be used to fill a version structure with the compile-time
* version of the SDL_ttf library.
* This is the version number macro for the current SDL_ttf version.
*/
#define SDL_TTF_VERSION(X) \
{ \
(X)->major = SDL_TTF_MAJOR_VERSION; \
(X)->minor = SDL_TTF_MINOR_VERSION; \
(X)->patch = SDL_TTF_PATCHLEVEL; \
}

/**
* Backwards compatibility
*/
#define TTF_MAJOR_VERSION SDL_TTF_MAJOR_VERSION
#define TTF_MINOR_VERSION SDL_TTF_MINOR_VERSION
#define TTF_PATCHLEVEL SDL_TTF_PATCHLEVEL
#define TTF_VERSION(X) SDL_TTF_VERSION(X)
#define SDL_TTF_VERSION \
SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_MICRO_VERSION)

/**
* This macro will evaluate to true if compiled with SDL_ttf at least X.Y.Z.
*/
#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
((SDL_TTF_MAJOR_VERSION >= X) && \
(SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION >= Y) && \
(SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION > Y || SDL_TTF_PATCHLEVEL >= Z))
(SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION > Y || SDL_TTF_MICRO_VERSION >= Z))

/**
* Query the version of SDL_ttf that the program is linked against.
*
* This function gets the version of the dynamically linked SDL_ttf library.
* This is separate from the SDL_TTF_VERSION() macro, which tells you what
* version of the SDL_ttf headers you compiled against.
*
* This returns static internal data; do not free or modify it!
*
* \returns a pointer to the version information.
* \returns SDL_ttf version
*
* \since This function is available since SDL_ttf 3.0.0.
*/
extern DECLSPEC const SDL_Version * SDLCALL TTF_Linked_Version(void);
extern DECLSPEC int SDLCALL IMG_Version(void);

/**
* Query the version of the FreeType library in use.
Expand Down
6 changes: 3 additions & 3 deletions 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/SDL_ttf.h`:
`SDL_TTF_MAJOR_VERSION`, `SDL_TTF_MINOR_VERSION`, `SDL_TTF_PATCHLEVEL`
`SDL_TTF_MAJOR_VERSION`, `SDL_TTF_MINOR_VERSION`, `SDL_TTF_MICRO_VERSION`
* `CMakeLists.txt`:
`MAJOR_VERSION`, `MINOR_VERSION`, `MICRO_VERSION`
* `version.rc`:
Expand Down Expand Up @@ -46,7 +46,7 @@

* `Xcode/SDL_ttf.xcodeproj/project.pbxproj`:
`DYLIB_CURRENT_VERSION`, `DYLIB_COMPATIBILITY_VERSION`
* set second number in `DYLIB_CURRENT_VERSION` to *patchlevel*
* set second number in `DYLIB_CURRENT_VERSION` to *micro*
* Leave `DYLIB_COMPATIBILITY_VERSION` unchanged

* Regenerate `configure`
Expand Down Expand Up @@ -83,7 +83,7 @@
* `Xcode/SDL_ttf.xcodeproj/project.pbxproj`:
`DYLIB_CURRENT_VERSION`, `DYLIB_COMPATIBILITY_VERSION`
* set first number in `DYLIB_CURRENT_VERSION` to
(100 * *minor*) + *patchlevel* + 1
(100 * *minor*) + *micro* + 1
* set second number in `DYLIB_CURRENT_VERSION` to 0
* set `DYLIB_COMPATIBILITY_VERSION` to the same value

Expand Down
26 changes: 9 additions & 17 deletions src/SDL_ttf.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,22 @@
# define TTF_USE_HARFBUZZ 0
#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_TTF_MAJOR_VERSION == SDL_BUILD_MAJOR_VERSION);
SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MINOR_VERSION,
SDL_TTF_MINOR_VERSION == SDL_BUILD_MINOR_VERSION);
SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MICRO_VERSION,
SDL_TTF_PATCHLEVEL == SDL_BUILD_MICRO_VERSION);
SDL_TTF_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_TTF_MAJOR_VERSION_min, SDL_TTF_MAJOR_VERSION >= 0);
/* Limited only by the need to fit in SDL_Version */
SDL_COMPILE_TIME_ASSERT(SDL_TTF_MAJOR_VERSION_max, SDL_TTF_MAJOR_VERSION <= 255);

SDL_COMPILE_TIME_ASSERT(SDL_TTF_MAJOR_VERSION_max, SDL_TTF_MAJOR_VERSION <= 10);
SDL_COMPILE_TIME_ASSERT(SDL_TTF_MINOR_VERSION_min, SDL_TTF_MINOR_VERSION >= 0);
/* Limited only by the need to fit in SDL_Version */
SDL_COMPILE_TIME_ASSERT(SDL_TTF_MINOR_VERSION_max, SDL_TTF_MINOR_VERSION <= 255);

SDL_COMPILE_TIME_ASSERT(SDL_TTF_PATCHLEVEL_min, SDL_TTF_PATCHLEVEL >= 0);
/* Limited by its encoding in SDL_VERSIONNUM and in the ABI versions */
SDL_COMPILE_TIME_ASSERT(SDL_TTF_PATCHLEVEL_max, SDL_TTF_PATCHLEVEL <= 99);
#endif
SDL_COMPILE_TIME_ASSERT(SDL_TTF_MINOR_VERSION_max, SDL_TTF_MINOR_VERSION <= 999);
SDL_COMPILE_TIME_ASSERT(SDL_TTF_MICRO_VERSION_min, SDL_TTF_MICRO_VERSION >= 0);
SDL_COMPILE_TIME_ASSERT(SDL_TTF_MICRO_VERSION_max, SDL_TTF_MICRO_VERSION <= 999);

#if TTF_USE_HARFBUZZ
#include <hb.h>
Expand Down Expand Up @@ -1601,11 +1595,9 @@ static SDL_Surface* Create_Surface_LCD(int width, int height, SDL_Color fg, SDL_


/* rcg06192001 get linked library's version. */
const SDL_Version* TTF_Linked_Version(void)
int TTF_Version(void)
{
static SDL_Version linked_version;
SDL_TTF_VERSION(&linked_version);
return &linked_version;
return SDL_TTF_VERSION;
}

/* This function tells the library whether UNICODE text is generally
Expand Down

0 comments on commit ffd34fa

Please sign in to comment.