chore(build): use SDL3

This commit is contained in:
phaneron 2025-04-12 04:38:19 -04:00
parent 9d04a35d87
commit b3c0734a9e
3286 changed files with 866354 additions and 554996 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,599 @@
#!/usr/bin/perl -w
# Add source files and headers to Xcode and Visual Studio projects.
# THIS IS NOT ROBUST, THIS IS JUST RYAN AVOIDING RUNNING BETWEEN
# THREE COMPUTERS AND A BUNCH OF DEVELOPMENT ENVIRONMENTS TO ADD
# A STUPID FILE TO THE BUILD.
use warnings;
use strict;
use File::Basename;
my %xcode_references = ();
sub generate_xcode_id {
my @chars = ('0'..'9', 'A'..'F');
my $str;
do {
my $len = 16;
$str = '0000'; # start and end with '0000' so we know we added it.
while ($len--) {
$str .= $chars[rand @chars]
};
$str .= '0000'; # start and end with '0000' so we know we added it.
} while (defined($xcode_references{$str}));
$xcode_references{$str} = 1; # so future calls can't generate this one.
return $str;
}
sub process_xcode {
my $addpath = shift;
my $pbxprojfname = shift;
my $lineno;
%xcode_references = ();
my $addfname = basename($addpath);
my $addext = '';
if ($addfname =~ /\.(.*?)\Z/) {
$addext = $1;
}
my $is_public_header = ($addpath =~ /\Ainclude\/SDL3\//) ? 1 : 0;
my $filerefpath = $is_public_header ? "SDL3/$addfname" : $addfname;
my $srcs_or_headers = '';
my $addfiletype = '';
if ($addext eq 'c') {
$srcs_or_headers = 'Sources';
$addfiletype = 'sourcecode.c.c';
} elsif ($addext eq 'm') {
$srcs_or_headers = 'Sources';
$addfiletype = 'sourcecode.c.objc';
} elsif ($addext eq 'h') {
$srcs_or_headers = 'Headers';
$addfiletype = 'sourcecode.c.h';
} else {
die("Unexpected file extension '$addext'\n");
}
my $fh;
open $fh, '<', $pbxprojfname or die("Failed to open '$pbxprojfname': $!\n");
chomp(my @pbxproj = <$fh>);
close($fh);
# build a table of all ids, in case we duplicate one by some miracle.
$lineno = 0;
foreach (@pbxproj) {
$lineno++;
# like "F3676F582A7885080091160D /* SDL3.dmg */ = {"
if (/\A\t\t([A-F0-9]{24}) \/\* (.*?) \*\/ \= \{\Z/) {
$xcode_references{$1} = $2;
}
}
# build out of a tree of PBXGroup items.
my %pbxgroups = ();
my $thispbxgroup;
my $pbxgroup_children;
my $pbxgroup_state = 0;
my $pubheaders_group_hash = '';
my $libsrc_group_hash = '';
$lineno = 0;
foreach (@pbxproj) {
$lineno++;
if ($pbxgroup_state == 0) {
$pbxgroup_state++ if /\A\/\* Begin PBXGroup section \*\/\Z/;
} elsif ($pbxgroup_state == 1) {
# like "F3676F582A7885080091160D /* SDL3.dmg */ = {"
if (/\A\t\t([A-F0-9]{24}) \/\* (.*?) \*\/ \= \{\Z/) {
my %newhash = ();
$pbxgroups{$1} = \%newhash;
$thispbxgroup = \%newhash;
$pubheaders_group_hash = $1 if $2 eq 'Public Headers';
$libsrc_group_hash = $1 if $2 eq 'Library Source';
$pbxgroup_state++;
} elsif (/\A\/\* End PBXGroup section \*\/\Z/) {
last;
} else {
die("Expected pbxgroup obj on '$pbxprojfname' line $lineno\n");
}
} elsif ($pbxgroup_state == 2) {
if (/\A\t\t\tisa \= PBXGroup;\Z/) {
$pbxgroup_state++;
} else {
die("Expected pbxgroup obj's isa field on '$pbxprojfname' line $lineno\n");
}
} elsif ($pbxgroup_state == 3) {
if (/\A\t\t\tchildren \= \(\Z/) {
my %newhash = ();
$$thispbxgroup{'children'} = \%newhash;
$pbxgroup_children = \%newhash;
$pbxgroup_state++;
} else {
die("Expected pbxgroup obj's children field on '$pbxprojfname' line $lineno\n");
}
} elsif ($pbxgroup_state == 4) {
if (/\A\t\t\t\t([A-F0-9]{24}) \/\* (.*?) \*\/,\Z/) {
$$pbxgroup_children{$1} = $2;
} elsif (/\A\t\t\t\);\Z/) {
$pbxgroup_state++;
} else {
die("Expected pbxgroup obj's children element on '$pbxprojfname' line $lineno\n");
}
} elsif ($pbxgroup_state == 5) {
if (/\A\t\t\t(.*?) \= (.*?);\Z/) {
$$thispbxgroup{$1} = $2;
} elsif (/\A\t\t\};\Z/) {
$pbxgroup_state = 1;
} else {
die("Expected pbxgroup obj field on '$pbxprojfname' line $lineno\n");
}
} else {
die("bug in this script.");
}
}
die("Didn't see PBXGroup section in '$pbxprojfname'. Bug?\n") if $pbxgroup_state == 0;
die("Didn't see Public Headers PBXGroup in '$pbxprojfname'. Bug?\n") if $pubheaders_group_hash eq '';
die("Didn't see Library Source PBXGroup in '$pbxprojfname'. Bug?\n") if $libsrc_group_hash eq '';
# Some debug log dumping...
if (0) {
foreach (keys %pbxgroups) {
my $k = $_;
my $g = $pbxgroups{$k};
print("$_:\n");
foreach (keys %$g) {
print(" $_:\n");
if ($_ eq 'children') {
my $kids = $$g{$_};
foreach (keys %$kids) {
print(" $_ -> " . $$kids{$_} . "\n");
}
} else {
print(' ' . $$g{$_} . "\n");
}
}
print("\n");
}
}
# Get some unique IDs for our new thing.
my $fileref = generate_xcode_id();
my $buildfileref = generate_xcode_id();
# Figure out what group to insert this into (or what groups to make)
my $add_to_group_fileref = $fileref;
my $add_to_group_addfname = $addfname;
my $newgrptext = '';
my $grphash = '';
if ($is_public_header) {
$grphash = $pubheaders_group_hash; # done!
} else {
$grphash = $libsrc_group_hash;
my @splitpath = split(/\//, dirname($addpath));
if ($splitpath[0] eq 'src') {
shift @splitpath;
}
while (my $elem = shift(@splitpath)) {
my $g = $pbxgroups{$grphash};
my $kids = $$g{'children'};
my $found = 0;
foreach (keys %$kids) {
my $hash = $_;
my $fname = $$kids{$hash};
if (uc($fname) eq uc($elem)) {
$grphash = $hash;
$found = 1;
last;
}
}
unshift(@splitpath, $elem), last if (not $found);
}
if (@splitpath) { # still elements? We need to build groups.
my $newgroupref = generate_xcode_id();
$add_to_group_fileref = $newgroupref;
$add_to_group_addfname = $splitpath[0];
while (my $elem = shift(@splitpath)) {
my $lastelem = @splitpath ? 0 : 1;
my $childhash = $lastelem ? $fileref : generate_xcode_id();
my $childpath = $lastelem ? $addfname : $splitpath[0];
$newgrptext .= "\t\t$newgroupref /* $elem */ = {\n";
$newgrptext .= "\t\t\tisa = PBXGroup;\n";
$newgrptext .= "\t\t\tchildren = (\n";
$newgrptext .= "\t\t\t\t$childhash /* $childpath */,\n";
$newgrptext .= "\t\t\t);\n";
$newgrptext .= "\t\t\tpath = $elem;\n";
$newgrptext .= "\t\t\tsourceTree = \"<group>\";\n";
$newgrptext .= "\t\t};\n";
$newgroupref = $childhash;
}
}
}
my $tmpfname = "$pbxprojfname.tmp";
open $fh, '>', $tmpfname or die("Failed to open '$tmpfname': $!\n");
my $add_to_this_group = 0;
$pbxgroup_state = 0;
$lineno = 0;
foreach (@pbxproj) {
$lineno++;
if ($pbxgroup_state == 0) {
# Drop in new references at the end of their sections...
if (/\A\/\* End PBXBuildFile section \*\/\Z/) {
print $fh "\t\t$buildfileref /* $addfname in $srcs_or_headers */ = {isa = PBXBuildFile; fileRef = $fileref /* $addfname */;";
if ($is_public_header) {
print $fh " settings = {ATTRIBUTES = (Public, ); };";
}
print $fh " };\n";
} elsif (/\A\/\* End PBXFileReference section \*\/\Z/) {
print $fh "\t\t$fileref /* $addfname */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = $addfiletype; name = $addfname; path = $filerefpath; sourceTree = \"<group>\"; };\n";
} elsif (/\A\/\* Begin PBXGroup section \*\/\Z/) {
$pbxgroup_state = 1;
} elsif (/\A\/\* Begin PBXSourcesBuildPhase section \*\/\Z/) {
$pbxgroup_state = 5;
}
} elsif ($pbxgroup_state == 1) {
if (/\A\t\t([A-F0-9]{24}) \/\* (.*?) \*\/ \= \{\Z/) {
$pbxgroup_state++;
$add_to_this_group = $1 eq $grphash;
} elsif (/\A\/\* End PBXGroup section \*\/\Z/) {
print $fh $newgrptext;
$pbxgroup_state = 0;
}
} elsif ($pbxgroup_state == 2) {
if (/\A\t\t\tchildren \= \(\Z/) {
$pbxgroup_state++;
}
} elsif ($pbxgroup_state == 3) {
if (/\A\t\t\t\);\Z/) {
if ($add_to_this_group) {
print $fh "\t\t\t\t$add_to_group_fileref /* $add_to_group_addfname */,\n";
}
$pbxgroup_state++;
}
} elsif ($pbxgroup_state == 4) {
if (/\A\t\t\};\Z/) {
$add_to_this_group = 0;
}
$pbxgroup_state = 1;
} elsif ($pbxgroup_state == 5) {
if (/\A\t\t\t\);\Z/) {
if ($srcs_or_headers eq 'Sources') {
print $fh "\t\t\t\t$buildfileref /* $addfname in $srcs_or_headers */,\n";
}
$pbxgroup_state = 0;
}
}
print $fh "$_\n";
}
close($fh);
rename($tmpfname, $pbxprojfname);
}
my %visualc_references = ();
sub generate_visualc_id { # these are just standard Windows GUIDs.
my @chars = ('0'..'9', 'a'..'f');
my $str;
do {
my $len = 24;
$str = '0000'; # start and end with '0000' so we know we added it.
while ($len--) {
$str .= $chars[rand @chars]
};
$str .= '0000'; # start and end with '0000' so we know we added it.
$str =~ s/\A(........)(....)(....)(............)\Z/$1-$2-$3-$4/; # add dashes in the appropriate places.
} while (defined($visualc_references{$str}));
$visualc_references{$str} = 1; # so future calls can't generate this one.
return $str;
}
sub process_visualstudio {
my $addpath = shift;
my $vcxprojfname = shift;
my $lineno;
%visualc_references = ();
my $is_public_header = ($addpath =~ /\Ainclude\/SDL3\//) ? 1 : 0;
my $addfname = basename($addpath);
my $addext = '';
if ($addfname =~ /\.(.*?)\Z/) {
$addext = $1;
}
my $isheader = 0;
if ($addext eq 'c') {
$isheader = 0;
} elsif ($addext eq 'm') {
return; # don't add Objective-C files to Visual Studio projects!
} elsif ($addext eq 'h') {
$isheader = 1;
} else {
die("Unexpected file extension '$addext'\n");
}
my $fh;
open $fh, '<', $vcxprojfname or die("Failed to open '$vcxprojfname': $!\n");
chomp(my @vcxproj = <$fh>);
close($fh);
my $vcxgroup_state;
my $rawaddvcxpath = "$addpath";
$rawaddvcxpath =~ s/\//\\/g;
# Figure out relative path from vcxproj file...
my $addvcxpath = '';
my @subdirs = split(/\//, $vcxprojfname);
pop @subdirs;
foreach (@subdirs) {
$addvcxpath .= "..\\";
}
$addvcxpath .= $rawaddvcxpath;
my $prevname = undef;
my $tmpfname;
$tmpfname = "$vcxprojfname.tmp";
open $fh, '>', $tmpfname or die("Failed to open '$tmpfname': $!\n");
my $added = 0;
$added = 0;
$vcxgroup_state = 0;
$prevname = undef;
$lineno = 0;
foreach (@vcxproj) {
$lineno++;
if ($vcxgroup_state == 0) {
if (/\A \<ItemGroup\>\Z/) {
$vcxgroup_state = 1;
$prevname = undef;
}
} elsif ($vcxgroup_state == 1) {
if (/\A \<ClInclude .*\Z/) {
$vcxgroup_state = 2 if $isheader;
} elsif (/\A \<ClCompile .*\Z/) {
$vcxgroup_state = 3 if not $isheader;
} elsif (/\A \<\/ItemGroup\>\Z/) {
$vcxgroup_state = 0;
$prevname = undef;
}
}
# Don't do elsif, we need to check this line again.
if ($vcxgroup_state == 2) {
if (/\A <ClInclude Include="(.*?)" \/\>\Z/) {
my $nextname = $1;
if ((not $added) && (((not defined $prevname) || (uc($prevname) lt uc($addvcxpath))) && (uc($nextname) gt uc($addvcxpath)))) {
print $fh " <ClInclude Include=\"$addvcxpath\" />\n";
$vcxgroup_state = 0;
$added = 1;
}
$prevname = $nextname;
} elsif (/\A \<\/ItemGroup\>\Z/) {
if ((not $added) && ((not defined $prevname) || (uc($prevname) lt uc($addvcxpath)))) {
print $fh " <ClInclude Include=\"$addvcxpath\" />\n";
$vcxgroup_state = 0;
$added = 1;
}
}
} elsif ($vcxgroup_state == 3) {
if (/\A <ClCompile Include="(.*?)" \/\>\Z/) {
my $nextname = $1;
if ((not $added) && (((not defined $prevname) || (uc($prevname) lt uc($addvcxpath))) && (uc($nextname) gt uc($addvcxpath)))) {
print $fh " <ClCompile Include=\"$addvcxpath\" />\n";
$vcxgroup_state = 0;
$added = 1;
}
$prevname = $nextname;
} elsif (/\A \<\/ItemGroup\>\Z/) {
if ((not $added) && ((not defined $prevname) || (uc($prevname) lt uc($addvcxpath)))) {
print $fh " <ClCompile Include=\"$addvcxpath\" />\n";
$vcxgroup_state = 0;
$added = 1;
}
}
}
print $fh "$_\n";
}
close($fh);
rename($tmpfname, $vcxprojfname);
my $vcxfiltersfname = "$vcxprojfname.filters";
open $fh, '<', $vcxfiltersfname or die("Failed to open '$vcxfiltersfname': $!\n");
chomp(my @vcxfilters = <$fh>);
close($fh);
my $newgrptext = '';
my $filter = '';
if ($is_public_header) {
$filter = 'API Headers';
} else {
$filter = lc(dirname($addpath));
$filter =~ s/\Asrc\///; # there's no filter for the base "src/" dir, where SDL.c and friends live.
$filter =~ s/\//\\/g;
$filter = '' if $filter eq 'src';
if ($filter ne '') {
# see if the filter already exists, otherwise add it.
my %existing_filters = ();
my $current_filter = '';
my $found = 0;
foreach (@vcxfilters) {
# These lines happen to be unique, so we don't have to parse down to find this section.
if (/\A \<Filter Include\="(.*?)"\>\Z/) {
$current_filter = lc($1);
if ($current_filter eq $filter) {
$found = 1;
}
} elsif (/\A \<UniqueIdentifier\>\{(.*?)\}\<\/UniqueIdentifier\>\Z/) {
$visualc_references{$1} = $current_filter; # gather up existing GUIDs to avoid duplicates.
$existing_filters{$current_filter} = $1;
}
}
if (not $found) { # didn't find it? We need to build filters.
my $subpath = '';
my @splitpath = split(/\\/, $filter);
while (my $elem = shift(@splitpath)) {
$subpath .= "\\" if ($subpath ne '');
$subpath .= $elem;
if (not $existing_filters{$subpath}) {
my $newgroupref = generate_visualc_id();
$newgrptext .= " <Filter Include=\"$subpath\">\n";
$newgrptext .= " <UniqueIdentifier>{$newgroupref}</UniqueIdentifier>\n";
$newgrptext .= " </Filter>\n"
}
}
}
}
}
$tmpfname = "$vcxfiltersfname.tmp";
open $fh, '>', $tmpfname or die("Failed to open '$tmpfname': $!\n");
$added = 0;
$vcxgroup_state = 0;
$prevname = undef;
$lineno = 0;
foreach (@vcxfilters) {
$lineno++;
# We cheat here, because these lines are unique, we don't have to fully parse this file.
if ($vcxgroup_state == 0) {
if (/\A \<Filter Include\="(.*?)"\>\Z/) {
if ($newgrptext ne '') {
$vcxgroup_state = 1;
$prevname = undef;
}
} elsif (/\A \<ClInclude .*\Z/) {
if ($isheader) {
$vcxgroup_state = 2;
$prevname = undef;
}
} elsif (/\A \<ClCompile .*\Z/) {
if (not $isheader) {
$vcxgroup_state = 3;
$prevname = undef;
}
}
}
# Don't do elsif, we need to check this line again.
if ($vcxgroup_state == 1) {
if (/\A \<\/ItemGroup\>\Z/) {
print $fh $newgrptext;
$newgrptext = '';
$vcxgroup_state = 0;
}
} elsif ($vcxgroup_state == 2) {
if (/\A <ClInclude Include="(.*?)"/) {
my $nextname = $1;
if ((not $added) && (((not defined $prevname) || (uc($prevname) lt uc($addvcxpath))) && (uc($nextname) gt uc($addvcxpath)))) {
print $fh " <ClInclude Include=\"$addvcxpath\"";
if ($filter ne '') {
print $fh ">\n";
print $fh " <Filter>$filter</Filter>\n";
print $fh " </ClInclude>\n";
} else {
print $fh " />\n";
}
$added = 1;
}
$prevname = $nextname;
} elsif (/\A \<\/ItemGroup\>\Z/) {
if ((not $added) && ((not defined $prevname) || (uc($prevname) lt uc($addvcxpath)))) {
print $fh " <ClInclude Include=\"$addvcxpath\"";
if ($filter ne '') {
print $fh ">\n";
print $fh " <Filter>$filter</Filter>\n";
print $fh " </ClInclude>\n";
} else {
print $fh " />\n";
}
$added = 1;
}
$vcxgroup_state = 0;
}
} elsif ($vcxgroup_state == 3) {
if (/\A <ClCompile Include="(.*?)"/) {
my $nextname = $1;
if ((not $added) && (((not defined $prevname) || (uc($prevname) lt uc($addvcxpath))) && (uc($nextname) gt uc($addvcxpath)))) {
print $fh " <ClCompile Include=\"$addvcxpath\"";
if ($filter ne '') {
print $fh ">\n";
print $fh " <Filter>$filter</Filter>\n";
print $fh " </ClCompile>\n";
} else {
print $fh " />\n";
}
$added = 1;
}
$prevname = $nextname;
} elsif (/\A \<\/ItemGroup\>\Z/) {
if ((not $added) && ((not defined $prevname) || (uc($prevname) lt uc($addvcxpath)))) {
print $fh " <ClCompile Include=\"$addvcxpath\"";
if ($filter ne '') {
print $fh ">\n";
print $fh " <Filter>$filter</Filter>\n";
print $fh " </ClCompile>\n";
} else {
print $fh " />\n";
}
$added = 1;
}
$vcxgroup_state = 0;
}
}
print $fh "$_\n";
}
close($fh);
rename($tmpfname, $vcxfiltersfname);
}
# Mainline!
chdir(dirname($0)); # assumed to be in build-scripts
chdir('..'); # head to root of source tree.
foreach (@ARGV) {
s/\A\.\///; # Turn "./path/to/file.txt" into "path/to/file.txt"
my $arg = $_;
process_xcode($arg, 'Xcode/SDL/SDL.xcodeproj/project.pbxproj');
process_visualstudio($arg, 'VisualC/SDL/SDL.vcxproj');
process_visualstudio($arg, 'VisualC-GDK/SDL/SDL.vcxproj');
}
print("Done. Please run `git diff` and make sure this looks okay!\n");
exit(0);

View file

@ -0,0 +1,78 @@
#!/bin/bash
#
# Build the Android libraries without needing a project
# (AndroidManifest.xml, jni/{Application,Android}.mk, etc.)
#
# Usage: androidbuildlibs.sh [arg for ndk-build ...]"
#
# Useful NDK arguments:
#
# NDK_DEBUG=1 - build debug version
# NDK_LIBS_OUT=<dest> - specify alternate destination for installable
# modules.
#
# Android.mk is in srcdir
srcdir=`dirname $0`/..
srcdir=`cd $srcdir && pwd`
cd $srcdir
#
# Create the build directories
#
build=build
buildandroid=$build/android
platform=android-21
abi="arm64-v8a" # "armeabi-v7a arm64-v8a x86 x86_64"
obj=
lib=
ndk_args=
# Allow an external caller to specify locations and platform.
while [ $# -gt 0 ]; do
arg=$1
if [ "${arg:0:8}" == "NDK_OUT=" ]; then
obj=${arg#NDK_OUT=}
elif [ "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then
lib=${arg#NDK_LIBS_OUT=}
elif [ "${arg:0:13}" == "APP_PLATFORM=" ]; then
platform=${arg#APP_PLATFORM=}
elif [ "${arg:0:8}" == "APP_ABI=" ]; then
abi=${arg#APP_ABI=}
else
ndk_args="$ndk_args $arg"
fi
shift
done
if [ -z $obj ]; then
obj=$buildandroid/obj
fi
if [ -z $lib ]; then
lib=$buildandroid/lib
fi
for dir in $build $buildandroid $obj $lib; do
if test -d $dir; then
:
else
mkdir $dir || exit 1
fi
done
# APP_* variables set in the environment here will not be seen by the
# ndk-build makefile segments that use them, e.g., default-application.mk.
# For consistency, pass all values on the command line.
ndk-build \
NDK_PROJECT_PATH=null \
NDK_OUT=$obj \
NDK_LIBS_OUT=$lib \
APP_BUILD_SCRIPT=Android.mk \
APP_ABI="$abi" \
APP_PLATFORM="$platform" \
APP_MODULES="SDL3" \
$ndk_args

1556
vendor/sdl-3.2.10/build-scripts/build-release.py vendored Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,420 @@
#!/usr/bin/perl -w
# Simple DirectMedia Layer
# Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
use warnings;
use strict;
use File::Basename;
use File::Copy;
use Cwd qw(abs_path);
use IPC::Open2;
my $examples_dir = abs_path(dirname(__FILE__) . "/../examples");
my $project = undef;
my $emsdk_dir = undef;
my $compile_dir = undef;
my $cmake_flags = undef;
my $output_dir = undef;
sub usage {
die("USAGE: $0 <project_name> <emsdk_dir> <compiler_output_directory> <cmake_flags> <html_output_directory>\n\n");
}
sub do_system {
my $cmd = shift;
$cmd = "exec /bin/bash -c \"$cmd\"";
print("$cmd\n");
return system($cmd);
}
sub do_mkdir {
my $d = shift;
if ( ! -d $d ) {
print("mkdir '$d'\n");
mkdir($d) or die("Couldn't mkdir('$d'): $!\n");
}
}
sub do_copy {
my $src = shift;
my $dst = shift;
print("cp '$src' '$dst'\n");
copy($src, $dst) or die("Failed to copy '$src' to '$dst': $!\n");
}
sub build_latest {
# Try to build just the latest without re-running cmake, since that is SLOW.
print("Building latest version of $project ...\n");
if (do_system("EMSDK_QUIET=1 source '$emsdk_dir/emsdk_env.sh' && cd '$compile_dir' && ninja") != 0) {
# Build failed? Try nuking the build dir and running CMake from scratch.
print("\n\nBuilding latest version of $project FROM SCRATCH ...\n");
if (do_system("EMSDK_QUIET=1 source '$emsdk_dir/emsdk_env.sh' && rm -rf '$compile_dir' && mkdir '$compile_dir' && cd '$compile_dir' && emcmake cmake -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel $cmake_flags '$examples_dir/..' && ninja") != 0) {
die("Failed to build latest version of $project!\n"); # oh well.
}
}
}
sub get_category_description {
my $category = shift;
my $retval = ucfirst($category);
if (open(my $fh, '<', "$examples_dir/$category/description.txt")) {
$retval = <$fh>;
chomp($retval);
close($fh);
}
return $retval;
}
sub get_categories {
my @categories = ();
if (open(my $fh, '<', "$examples_dir/categories.txt")) {
while (<$fh>) {
chomp;
s/\A\s+//;
s/\s+\Z//;
next if $_ eq '';
next if /\A\#/;
push @categories, $_;
}
close($fh);
} else {
opendir(my $dh, $examples_dir) or die("Couldn't opendir '$examples_dir': $!\n");
foreach my $dir (sort readdir $dh) {
next if ($dir eq '.') || ($dir eq '..'); # obviously skip current and parent entries.
next if not -d "$examples_dir/$dir"; # only care about subdirectories.
push @categories, $dir;
}
closedir($dh);
}
return @categories;
}
sub get_examples_for_category {
my $category = shift;
my @examples = ();
opendir(my $dh, "$examples_dir/$category") or die("Couldn't opendir '$examples_dir/$category': $!\n");
foreach my $dir (sort readdir $dh) {
next if ($dir eq '.') || ($dir eq '..'); # obviously skip current and parent entries.
next if not -d "$examples_dir/$category/$dir"; # only care about subdirectories.
push @examples, $dir;
}
closedir($dh);
return @examples;
}
sub handle_example_dir {
my $category = shift;
my $example = shift;
my @files = ();
my $files_str = '';
opendir(my $dh, "$examples_dir/$category/$example") or die("Couldn't opendir '$examples_dir/$category/$example': $!\n");
my $spc = '';
while (readdir($dh)) {
my $path = "$examples_dir/$category/$example/$_";
next if not -f $path; # only care about files.
push @files, $path if /\.[ch]\Z/; # add .c and .h files to source code.
if (/\.c\Z/) { # only care about .c files for compiling.
$files_str .= "$spc$path";
$spc = ' ';
}
}
closedir($dh);
my $dst = "$output_dir/$category/$example";
print("Building $category/$example ...\n");
my $basefname = "$example";
$basefname =~ s/\A\d+\-//;
$basefname = "$category-$basefname";
my $jsfname = "$basefname.js";
my $wasmfname = "$basefname.wasm";
my $thumbnailfname = 'thumbnail.png';
my $onmouseoverfname = 'onmouseover.webp';
my $jssrc = "$compile_dir/examples/$jsfname";
my $wasmsrc = "$compile_dir/examples/$wasmfname";
my $thumbnailsrc = "$examples_dir/$category/$example/$thumbnailfname";
my $onmouseoversrc = "$examples_dir/$category/$example/$onmouseoverfname";
my $jsdst = "$dst/$jsfname";
my $wasmdst = "$dst/$wasmfname";
my $thumbnaildst = "$dst/$thumbnailfname";
my $onmouseoverdst = "$dst/$onmouseoverfname";
my $description = '';
my $has_paragraph = 0;
if (open(my $readmetxth, '<', "$examples_dir/$category/$example/README.txt")) {
while (<$readmetxth>) {
chomp;
s/\A\s+//;
s/\s+\Z//;
if (($_ eq '') && ($description ne '')) {
$has_paragraph = 1;
} else {
if ($has_paragraph) {
$description .= "\n<br/>\n<br/>\n";
$has_paragraph = 0;
}
$description .= "$_ ";
}
}
close($readmetxth);
$description =~ s/\s+\Z//;
}
do_mkdir($dst);
do_copy($jssrc, $jsdst);
do_copy($wasmsrc, $wasmdst);
do_copy($thumbnailsrc, $thumbnaildst) if ( -f $thumbnailsrc );
do_copy($onmouseoversrc, $onmouseoverdst) if ( -f $onmouseoversrc );
my $highlight_cmd = "highlight '--outdir=$dst' --style-outfile=highlight.css --fragment --enclose-pre --stdout --syntax=c '--plug-in=$examples_dir/highlight-plugin.lua'";
print("$highlight_cmd\n");
my $pid = open2(my $child_out, my $child_in, $highlight_cmd);
my $htmlified_source_code = '';
foreach (sort(@files)) {
my $path = $_;
open my $srccode, '<', $path or die("Couldn't open '$path': $!\n");
my $fname = "$path";
$fname =~ s/\A.*\///;
print $child_in "/* $fname ... */\n\n";
while (<$srccode>) {
print $child_in $_;
}
print $child_in "\n\n\n";
close($srccode);
}
close($child_in);
while (<$child_out>) {
$htmlified_source_code .= $_;
}
close($child_out);
waitpid($pid, 0);
my $other_examples_html = "<ul>";
foreach my $example (get_examples_for_category($category)) {
$other_examples_html .= "<li><a href='/$project/$category/$example'>$category/$example</a></li>";
}
$other_examples_html .= "</ul>";
my $category_description = get_category_description($category);
my $preview_image = get_example_thumbnail($project, $category, $example);
my $html = '';
open my $htmltemplate, '<', "$examples_dir/template.html" or die("Couldn't open '$examples_dir/template.html': $!\n");
while (<$htmltemplate>) {
s/\@project_name\@/$project/g;
s/\@category_name\@/$category/g;
s/\@category_description\@/$category_description/g;
s/\@example_name\@/$example/g;
s/\@javascript_file\@/$jsfname/g;
s/\@htmlified_source_code\@/$htmlified_source_code/g;
s/\@description\@/$description/g;
s/\@preview_image\@/$preview_image/g;
s/\@other_examples_html\@/$other_examples_html/g;
$html .= $_;
}
close($htmltemplate);
open my $htmloutput, '>', "$dst/index.html" or die("Couldn't open '$dst/index.html': $!\n");
print $htmloutput $html;
close($htmloutput);
}
sub get_example_thumbnail {
my $project = shift;
my $category = shift;
my $example = shift;
if ( -f "$examples_dir/$category/$example/thumbnail.png" ) {
return "/$project/$category/$example/thumbnail.png";
} elsif ( -f "$examples_dir/$category/thumbnail.png" ) {
return "/$project/$category/thumbnail.png";
}
return "/$project/thumbnail.png";
}
sub generate_example_thumbnail {
my $project = shift;
my $category = shift;
my $example = shift;
my $example_no_num = "$example";
$example_no_num =~ s/\A\d+\-//;
my $example_image_url = get_example_thumbnail($project, $category, $example);
my $example_mouseover_html = '';
if ( -f "$examples_dir/$category/$example/onmouseover.webp" ) {
$example_mouseover_html = "onmouseover=\"this.src='/$project/$category/$example/onmouseover.webp'\" onmouseout=\"this.src='$example_image_url';\"";
} elsif ( -f "$examples_dir/$category/onmouseover.webp" ) {
$example_mouseover_html = "onmouseover=\"this.src='/$project/$category/onmouseover.webp'\" onmouseout=\"this.src='$example_image_url';\"";
}
return "
<a href='/$project/$category/$example'>
<div>
<img src='$example_image_url' $example_mouseover_html />
<div>$example_no_num</div>
</div>
</a>"
;
}
sub generate_example_thumbnails_for_category {
my $project = shift;
my $category = shift;
my @examples = get_examples_for_category($category);
my $retval = '';
foreach my $example (@examples) {
$retval .= generate_example_thumbnail($project, $category, $example);
}
return $retval;
}
sub handle_category_dir {
my $category = shift;
print("Category $category ...\n");
do_mkdir("$output_dir/$category");
opendir(my $dh, "$examples_dir/$category") or die("Couldn't opendir '$examples_dir/$category': $!\n");
while (readdir($dh)) {
next if ($_ eq '.') || ($_ eq '..'); # obviously skip current and parent entries.
next if not -d "$examples_dir/$category/$_"; # only care about subdirectories.
handle_example_dir($category, $_);
}
closedir($dh);
my $examples_list_html = generate_example_thumbnails_for_category($project, $category);
my $dst = "$output_dir/$category";
do_copy("$examples_dir/$category/thumbnail.png", "$dst/thumbnail.png") if ( -f "$examples_dir/$category/thumbnail.png" );
do_copy("$examples_dir/$category/onmouseover.webp", "$dst/onmouseover.webp") if ( -f "$examples_dir/$category/onmouseover.webp" );
my $category_description = get_category_description($category);
my $preview_image = "/$project/thumbnail.png";
if ( -f "$examples_dir/$category/thumbnail.png" ) {
$preview_image = "/$project/$category/thumbnail.png";
}
# write category page
my $html = '';
open my $htmltemplate, '<', "$examples_dir/template-category.html" or die("Couldn't open '$examples_dir/template-category.html': $!\n");
while (<$htmltemplate>) {
s/\@project_name\@/$project/g;
s/\@category_name\@/$category/g;
s/\@category_description\@/$category_description/g;
s/\@examples_list_html\@/$examples_list_html/g;
s/\@preview_image\@/$preview_image/g;
$html .= $_;
}
close($htmltemplate);
open my $htmloutput, '>', "$dst/index.html" or die("Couldn't open '$dst/index.html': $!\n");
print $htmloutput $html;
close($htmloutput);
}
# Mainline!
foreach (@ARGV) {
$project = $_, next if not defined $project;
$emsdk_dir = $_, next if not defined $emsdk_dir;
$compile_dir = $_, next if not defined $compile_dir;
$cmake_flags = $_, next if not defined $cmake_flags;
$output_dir = $_, next if not defined $output_dir;
usage(); # too many arguments.
}
usage() if not defined $output_dir;
print("Examples dir: $examples_dir\n");
print("emsdk dir: $emsdk_dir\n");
print("Compile dir: $compile_dir\n");
print("CMake flags: $cmake_flags\n");
print("Output dir: $output_dir\n");
do_system("rm -rf '$output_dir'");
do_mkdir($output_dir);
build_latest();
do_copy("$examples_dir/template.css", "$output_dir/examples.css");
do_copy("$examples_dir/template-placeholder.png", "$output_dir/thumbnail.png");
opendir(my $dh, $examples_dir) or die("Couldn't opendir '$examples_dir': $!\n");
while (readdir($dh)) {
next if ($_ eq '.') || ($_ eq '..'); # obviously skip current and parent entries.
next if not -d "$examples_dir/$_"; # only care about subdirectories.
# !!! FIXME: this needs to generate a preview page for all the categories.
handle_category_dir($_);
}
closedir($dh);
# write homepage
my $homepage_list_html = "";
foreach my $category (get_categories()) {
my $category_description = get_category_description($category);
$homepage_list_html .= "<h2>$category_description</h2>";
$homepage_list_html .= "<div class='list'>";
$homepage_list_html .= generate_example_thumbnails_for_category($project, $category);
$homepage_list_html .= "</div>";
}
my $preview_image = "/$project/thumbnail.png";
my $dst = "$output_dir/";
my $html = '';
open my $htmltemplate, '<', "$examples_dir/template-homepage.html" or die("Couldn't open '$examples_dir/template-category.html': $!\n");
while (<$htmltemplate>) {
s/\@project_name\@/$project/g;
s/\@homepage_list_html\@/$homepage_list_html/g;
s/\@preview_image\@/$preview_image/g;
$html .= $_;
}
close($htmltemplate);
open my $htmloutput, '>', "$dst/index.html" or die("Couldn't open '$dst/index.html': $!\n");
print $htmloutput $html;
close($htmloutput);
print("All examples built successfully!\n");
exit(0); # success!

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,172 @@
#!/usr/bin/env python
import argparse
import dataclasses
import os
import pathlib
import re
ROOT = pathlib.Path(__file__).resolve().parents[1]
SDL_ANDROID_C = ROOT / "src/core/android/SDL_android.c"
METHOD_SOURCE_PATHS = (
SDL_ANDROID_C,
ROOT / "src/hidapi/android/hid.cpp",
)
JAVA_ROOT = ROOT / "android-project/app/src/main/java"
BASIC_TYPE_SPEC_LUT = {
"char": "C",
"byte": "B",
"short": "S",
"int": "I",
"long": "J",
"float": "F",
"double": "D",
"void": "V",
"boolean": "Z",
"Object": "Ljava/lang/Object;",
"String": "Ljava/lang/String;",
}
@dataclasses.dataclass(frozen=True)
class JniType:
typ: str
array: int
def java_type_to_jni_spec_internal(type_str: str) -> tuple[int, str]:
for basic_type_str, basic_type_spec in BASIC_TYPE_SPEC_LUT.items():
if type_str.startswith(basic_type_str):
return len(basic_type_str), basic_type_spec
raise ValueError(f"Don't know how to convert {repr(type_str)} to its equivalent jni spec")
def java_type_to_jni_spec(type_str: str) -> str:
end, type_spec = java_type_to_jni_spec_internal(type_str)
suffix_str = type_str[end:]
assert(all(c in "[] \t" for c in suffix_str))
suffix_str = "".join(filter(lambda v: v in "[]", suffix_str))
assert len(suffix_str) % 2 == 0
array_spec = "[" * (len(suffix_str) // 2)
return array_spec + type_spec
def java_method_to_jni_spec(ret: str, args: list[str]) -> str:
return "(" + "".join(java_type_to_jni_spec(a) for a in args) +")" + java_type_to_jni_spec(ret)
@dataclasses.dataclass(frozen=True)
class JniMethodBinding:
name: str
spec: str
def collect_jni_bindings_from_c() -> dict[str, set[JniMethodBinding]]:
bindings = {}
sdl_android_text = SDL_ANDROID_C.read_text()
for m in re.finditer(r"""register_methods\((?:[A-Za-z0-9]+),\s*"(?P<class>[a-zA-Z0-9_/]+)",\s*(?P<table>[a-zA-Z0-9_]+),\s*SDL_arraysize\((?P=table)\)\)""", sdl_android_text):
kls = m["class"]
table = m["table"]
methods = set()
in_struct = False
for method_source_path in METHOD_SOURCE_PATHS:
method_source = method_source_path.read_text()
for line in method_source.splitlines(keepends=False):
if re.match(f"(static )?JNINativeMethod {table}" + r"\[([0-9]+)?\] = \{", line):
in_struct = True
continue
if in_struct:
if re.match(r"\};", line):
in_struct = False
break
n = re.match(r"""\s*\{\s*"(?P<method>[a-zA-Z0-9_]+)"\s*,\s*"(?P<spec>[()A-Za-z0-9_/;[]+)"\s*,\s*(\(void\*\))?(HID|SDL)[_A-Z]*_JAVA_[_A-Z]*INTERFACE[_A-Z]*\((?P=method)\)\s*\},?""", line)
assert n, f"'{line}' does not match regex"
methods.add(JniMethodBinding(name=n["method"], spec=n["spec"]))
continue
if methods:
break
if methods:
break
assert methods, f"Could not find methods for {kls} (table={table})"
assert not in_struct
assert kls not in bindings, f"{kls} must be unique in C sources"
bindings[kls] = methods
return bindings
def collect_jni_bindings_from_java() -> dict[str, set[JniMethodBinding]]:
bindings = {}
for root, _, files in os.walk(JAVA_ROOT):
for file in files:
file_path = pathlib.Path(root) / file
java_text = file_path.read_text()
methods = set()
for m in re.finditer(r"(?:(?:public|private)\s+)?(?:static\s+)?native\s+(?P<ret>[A-Za-z0-9_]+)\s+(?P<method>[a-zA-Z0-9_]+)\s*\(\s*(?P<args>[^)]*)\);", java_text):
name = m["method"]
ret = m["ret"]
args = []
args_str = m["args"].strip()
if args_str:
for a_s in args_str.split(","):
atype_str, _ = a_s.strip().rsplit(" ")
args.append(atype_str.strip())
spec = java_method_to_jni_spec(ret=ret, args=args)
methods.add(JniMethodBinding(name=name, spec=spec))
if methods:
relative_java_path = file_path.relative_to(JAVA_ROOT)
relative_java_path_without_suffix = relative_java_path.with_suffix("")
kls = "/".join(relative_java_path_without_suffix.parts)
assert kls not in bindings, f"{kls} must be unique in JAVA sources"
bindings[kls] = methods
return bindings
def print_error(*args):
print("ERROR:", *args)
def main():
parser = argparse.ArgumentParser(allow_abbrev=False, description="Verify Android JNI bindings")
args = parser.parse_args()
bindings_from_c = collect_jni_bindings_from_c()
bindings_from_java = collect_jni_bindings_from_java()
all_ok = bindings_from_c == bindings_from_java
if all_ok:
print("OK")
else:
print("NOT OK")
kls_c = set(bindings_from_c.keys())
kls_java = set(bindings_from_java.keys())
if kls_c != kls_java:
only_c = kls_c - kls_java
for c in only_c:
print_error(f"Missing class in JAVA sources: {c}")
only_java = kls_java - kls_c
for c in only_java:
print_error(f"Missing class in C sources: {c}")
klasses = kls_c.union(kls_java)
for kls in klasses:
m_c = bindings_from_c.get(kls)
m_j = bindings_from_java.get(kls)
if m_c and m_j and m_c != m_j:
m_only_c = m_c - m_j
for c in m_only_c:
print_error(f"{kls}: Binding only in C source: {c.name} {c.spec}")
m_only_j = m_j - m_c
for c in m_only_j:
print_error(f"{kls}: Binding only in JAVA source: {c.name} {c.spec}")
return 0 if all_ok else 1
if __name__ == "__main__":
raise SystemExit(main())

View file

@ -0,0 +1,262 @@
#!/usr/bin/env python3
#
# Simple DirectMedia Layer
# Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
#
# This script detects use of stdlib function in SDL code
import argparse
import os
import pathlib
import re
import sys
SDL_ROOT = pathlib.Path(__file__).resolve().parents[1]
STDLIB_SYMBOLS = [
'abs',
'acos',
'acosf',
'asin',
'asinf',
'asprintf',
'atan',
'atan2',
'atan2f',
'atanf',
'atof',
'atoi',
'bsearch',
'calloc',
'ceil',
'ceilf',
'copysign',
'copysignf',
'cos',
'cosf',
'crc32',
'exp',
'expf',
'fabs',
'fabsf',
'floor',
'floorf',
'fmod',
'fmodf',
'free',
'getenv',
'isalnum',
'isalpha',
'isblank',
'iscntrl',
'isdigit',
'isgraph',
'islower',
'isprint',
'ispunct',
'isspace',
'isupper',
'isxdigit',
'itoa',
'lltoa',
'log10',
'log10f',
'logf',
'lround',
'lroundf',
'ltoa',
'malloc',
'memalign',
'memcmp',
'memcpy',
'memcpy4',
'memmove',
'memset',
'pow',
'powf',
'qsort',
'qsort_r',
'qsort_s',
'realloc',
'round',
'roundf',
'scalbn',
'scalbnf',
'setenv',
'sin',
'sinf',
'snprintf',
'sqrt',
'sqrtf',
'sscanf',
'strcasecmp',
'strchr',
'strcmp',
'strdup',
'strlcat',
'strlcpy',
'strlen',
'strlwr',
'strncasecmp',
'strncmp',
'strrchr',
'strrev',
'strstr',
'strtod',
'strtokr',
'strtol',
'strtoll',
'strtoul',
'strupr',
'tan',
'tanf',
'tolower',
'toupper',
'trunc',
'truncf',
'uitoa',
'ulltoa',
'ultoa',
'utf8strlcpy',
'utf8strlen',
'vasprintf',
'vsnprintf',
'vsscanf',
'wcscasecmp',
'wcscmp',
'wcsdup',
'wcslcat',
'wcslcpy',
'wcslen',
'wcsncasecmp',
'wcsncmp',
'wcsstr',
]
RE_STDLIB_SYMBOL = re.compile(rf"\b(?P<symbol>{'|'.join(STDLIB_SYMBOLS)})\b\(")
def find_symbols_in_file(file: pathlib.Path) -> int:
match_count = 0
allowed_extensions = [ ".c", ".cpp", ".m", ".h", ".hpp", ".cc" ]
excluded_paths = [
"src/stdlib",
"src/libm",
"src/hidapi",
"src/video/khronos",
"src/video/stb_image.h",
"include/SDL3",
"build-scripts/gen_audio_resampler_filter.c",
"build-scripts/gen_audio_channel_conversion.c",
"test/win32/sdlprocdump.c",
]
filename = pathlib.Path(file)
for ep in excluded_paths:
if ep in filename.as_posix():
# skip
return 0
if filename.suffix not in allowed_extensions:
# skip
return 0
# print("Parse %s" % file)
try:
with file.open("r", encoding="UTF-8", newline="") as rfp:
parsing_comment = False
for line_i, original_line in enumerate(rfp, start=1):
line = original_line.strip()
line_comment = ""
# Get the comment block /* ... */ across several lines
while True:
if parsing_comment:
pos_end_comment = line.find("*/")
if pos_end_comment >= 0:
line = line[pos_end_comment+2:]
parsing_comment = False
else:
break
else:
pos_start_comment = line.find("/*")
if pos_start_comment >= 0:
pos_end_comment = line.find("*/", pos_start_comment+2)
if pos_end_comment >= 0:
line_comment += line[pos_start_comment:pos_end_comment+2]
line = line[:pos_start_comment] + line[pos_end_comment+2:]
else:
line_comment += line[pos_start_comment:]
line = line[:pos_start_comment]
parsing_comment = True
break
else:
break
if parsing_comment:
continue
pos_line_comment = line.find("//")
if pos_line_comment >= 0:
line_comment += line[pos_line_comment:]
line = line[:pos_line_comment]
if m := RE_STDLIB_SYMBOL.match(line):
override_string = f"This should NOT be SDL_{m['symbol']}()"
if override_string not in line_comment:
print(f"{filename}:{line_i}")
print(f" {line}")
print(f"")
match_count += 1
except UnicodeDecodeError:
print(f"{file} is not text, skipping", file=sys.stderr)
return match_count
def find_symbols_in_dir(path: pathlib.Path) -> int:
match_count = 0
for entry in path.glob("*"):
if entry.is_dir():
match_count += find_symbols_in_dir(entry)
else:
match_count += find_symbols_in_file(entry)
return match_count
def main():
parser = argparse.ArgumentParser(fromfile_prefix_chars="@")
parser.add_argument("path", default=SDL_ROOT, nargs="?", type=pathlib.Path, help="Path to look for stdlib symbols")
args = parser.parse_args()
print(f"Looking for stdlib usage in {args.path}...")
match_count = find_symbols_in_dir(args.path)
if match_count:
print("If the stdlib usage is intentional, add a '// This should NOT be SDL_<symbol>()' line comment.")
print("")
print("NOT OK")
else:
print("OK")
return 1 if match_count else 0
if __name__ == "__main__":
raise SystemExit(main())

View file

@ -0,0 +1,39 @@
#!/bin/sh
cd "$(dirname $0)/../src"
echo "Running clang-format in $(pwd)"
find . -regex '.*\.[chm]p*' -exec clang-format -i {} \;
# Revert third-party code
git checkout \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
libm \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
video/khronos \
video/x11/edid.h \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
clang-format -i hidapi/SDL_hidapi.c
# Revert generated code
git checkout \
dynapi/SDL_dynapi_overrides.h \
dynapi/SDL_dynapi_procs.h \
render/*/*Shader*.h \
render/metal/SDL_shaders_metal_*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
echo "clang-format complete!"

View file

@ -0,0 +1,18 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86)
find_program(CMAKE_C_COMPILER NAMES i686-w64-mingw32-gcc)
find_program(CMAKE_CXX_COMPILER NAMES i686-w64-mingw32-g++)
find_program(CMAKE_RC_COMPILER NAMES i686-w64-mingw32-windres windres)
if(NOT CMAKE_C_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_C_COMPILER.")
endif()
if(NOT CMAKE_CXX_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_CXX_COMPILER.")
endif()
if(NOT CMAKE_RC_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_RC_COMPILER.")
endif()

View file

@ -0,0 +1,18 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
find_program(CMAKE_C_COMPILER NAMES x86_64-w64-mingw32-gcc)
find_program(CMAKE_CXX_COMPILER NAMES x86_64-w64-mingw32-g++)
find_program(CMAKE_RC_COMPILER NAMES x86_64-w64-mingw32-windres windres)
if(NOT CMAKE_C_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_C_COMPILER.")
endif()
if(NOT CMAKE_CXX_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_CXX_COMPILER.")
endif()
if(NOT CMAKE_RC_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_RC_COMPILER.")
endif()

View file

@ -0,0 +1,14 @@
set(CMAKE_SYSTEM_NAME QNX)
set(arch gcc_ntoaarch64le)
set(CMAKE_C_COMPILER qcc)
set(CMAKE_C_COMPILER_TARGET ${arch})
set(CMAKE_CXX_COMPILER q++)
set(CMAKE_CXX_COMPILER_TARGET ${arch})
set(CMAKE_SYSROOT $ENV{QNX_TARGET})
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View file

@ -0,0 +1,14 @@
set(CMAKE_SYSTEM_NAME QNX)
set(arch gcc_ntox86_64)
set(CMAKE_C_COMPILER qcc)
set(CMAKE_C_COMPILER_TARGET ${arch})
set(CMAKE_CXX_COMPILER q++)
set(CMAKE_CXX_COMPILER_TARGET ${arch})
set(CMAKE_SYSROOT $ENV{QNX_TARGET})
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View file

@ -0,0 +1,59 @@
#!/bin/bash
# This is a script used by some Buildbot build workers to push the project
# through Clang's static analyzer and prepare the output to be uploaded
# back to the buildmaster. You might find it useful too.
# Install Clang (you already have it on macOS, apt-get install clang
# on Ubuntu, etc), install CMake, and pip3 install codechecker.
FINALDIR="$1"
set -x
set -e
cd `dirname "$0"`
cd ..
rm -rf codechecker-buildbot
if [ ! -z "$FINALDIR" ]; then
rm -rf "$FINALDIR"
fi
mkdir codechecker-buildbot
cd codechecker-buildbot
# We turn off deprecated declarations, because we don't care about these warnings during static analysis.
cmake -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DSDL_ASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
# CMake on macOS adds "-arch arm64" or whatever is appropriate, but this confuses CodeChecker, so strip it out.
perl -w -pi -e 's/\-arch\s+.*?\s+//g;' compile_commands.json
rm -rf ../analysis
CodeChecker analyze compile_commands.json -o ./reports
# "parse" returns 2 if there was a static analysis issue to report, but this
# does not signify an error in the parsing (that would be error code 1). Turn
# off the abort-on-error flag.
set +e
CodeChecker parse ./reports -e html -o ../analysis
set -e
cd ..
chmod -R a+r analysis
chmod -R go-w analysis
find analysis -type d -exec chmod a+x {} \;
if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
if [ ! -z "$FINALDIR" ]; then
mv analysis "$FINALDIR"
else
FINALDIR=analysis
fi
rm -rf codechecker-buildbot
echo "Done. Final output is in '$FINALDIR' ..."
# end of codechecker-buildbot.sh ...

View file

@ -0,0 +1,241 @@
#!/usr/bin/env python3
import os
from argparse import ArgumentParser
from pathlib import Path
import re
import shutil
import sys
import textwrap
SDL_ROOT = Path(__file__).resolve().parents[1]
def extract_sdl_version() -> str:
"""
Extract SDL version from SDL3/SDL_version.h
"""
with open(SDL_ROOT / "include/SDL3/SDL_version.h") as f:
data = f.read()
major = int(next(re.finditer(r"#define\s+SDL_MAJOR_VERSION\s+([0-9]+)", data)).group(1))
minor = int(next(re.finditer(r"#define\s+SDL_MINOR_VERSION\s+([0-9]+)", data)).group(1))
micro = int(next(re.finditer(r"#define\s+SDL_MICRO_VERSION\s+([0-9]+)", data)).group(1))
return f"{major}.{minor}.{micro}"
def replace_in_file(path: Path, regex_what: str, replace_with: str) -> None:
with path.open("r") as f:
data = f.read()
new_data, count = re.subn(regex_what, replace_with, data)
assert count > 0, f"\"{regex_what}\" did not match anything in \"{path}\""
with open(path, "w") as f:
f.write(new_data)
def android_mk_use_prefab(path: Path) -> None:
"""
Replace relative SDL inclusion with dependency on prefab package
"""
with path.open() as f:
data = "".join(line for line in f.readlines() if "# SDL" not in line)
data, _ = re.subn("[\n]{3,}", "\n\n", data)
data, count = re.subn(r"(LOCAL_SHARED_LIBRARIES\s*:=\s*SDL3)", "LOCAL_SHARED_LIBRARIES := SDL3 SDL3-Headers", data)
assert count == 1, f"Must have injected SDL3-Headers in {path} exactly once"
newdata = data + textwrap.dedent("""
# https://google.github.io/prefab/build-systems.html
# Add the prefab modules to the import path.
$(call import-add-path,/out)
# Import SDL3 so we can depend on it.
$(call import-module,prefab/SDL3)
""")
with path.open("w") as f:
f.write(newdata)
def cmake_mk_no_sdl(path: Path) -> None:
"""
Don't add the source directories of SDL/SDL_image/SDL_mixer/...
"""
with path.open() as f:
lines = f.readlines()
newlines: list[str] = []
for line in lines:
if "add_subdirectory(SDL" in line:
while newlines[-1].startswith("#"):
newlines = newlines[:-1]
continue
newlines.append(line)
newdata, _ = re.subn("[\n]{3,}", "\n\n", "".join(newlines))
with path.open("w") as f:
f.write(newdata)
def gradle_add_prefab_and_aar(path: Path, aar: str) -> None:
with path.open() as f:
data = f.read()
data, count = re.subn("android {", textwrap.dedent("""
android {
buildFeatures {
prefab true
}"""), data)
assert count == 1
data, count = re.subn("dependencies {", textwrap.dedent(f"""
dependencies {{
implementation files('libs/{aar}')"""), data)
assert count == 1
with path.open("w") as f:
f.write(data)
def gradle_add_package_name(path: Path, package_name: str) -> None:
with path.open() as f:
data = f.read()
data, count = re.subn("org.libsdl.app", package_name, data)
assert count >= 1
with path.open("w") as f:
f.write(data)
def main() -> int:
description = "Create a simple Android gradle project from input sources."
epilog = textwrap.dedent("""\
You need to manually copy a prebuilt SDL3 Android archive into the project tree when using the aar variant.
Any changes you have done to the sources in the Android project will be lost
""")
parser = ArgumentParser(description=description, epilog=epilog, allow_abbrev=False)
parser.add_argument("package_name", metavar="PACKAGENAME", help="Android package name (e.g. com.yourcompany.yourapp)")
parser.add_argument("sources", metavar="SOURCE", nargs="*", help="Source code of your application. The files are copied to the output directory.")
parser.add_argument("--variant", choices=["copy", "symlink", "aar"], default="copy", help="Choose variant of SDL project (copy: copy SDL sources, symlink: symlink SDL sources, aar: use Android aar archive)")
parser.add_argument("--output", "-o", default=SDL_ROOT / "build", type=Path, help="Location where to store the Android project")
parser.add_argument("--version", default=None, help="SDL3 version to use as aar dependency (only used for aar variant)")
args = parser.parse_args()
if not args.sources:
print("Reading source file paths from stdin (press CTRL+D to stop)")
args.sources = [path for path in sys.stdin.read().strip().split() if path]
if not args.sources:
parser.error("No sources passed")
if not os.getenv("ANDROID_HOME"):
print("WARNING: ANDROID_HOME environment variable not set", file=sys.stderr)
if not os.getenv("ANDROID_NDK_HOME"):
print("WARNING: ANDROID_NDK_HOME environment variable not set", file=sys.stderr)
args.sources = [Path(src) for src in args.sources]
build_path = args.output / args.package_name
# Remove the destination folder
shutil.rmtree(build_path, ignore_errors=True)
# Copy the Android project
shutil.copytree(SDL_ROOT / "android-project", build_path)
# Add the source files to the ndk-build and cmake projects
replace_in_file(build_path / "app/jni/src/Android.mk", r"YourSourceHere\.c", " \\\n ".join(src.name for src in args.sources))
replace_in_file(build_path / "app/jni/src/CMakeLists.txt", r"YourSourceHere\.c", "\n ".join(src.name for src in args.sources))
# Remove placeholder source "YourSourceHere.c"
(build_path / "app/jni/src/YourSourceHere.c").unlink()
# Copy sources to output folder
for src in args.sources:
if not src.is_file():
parser.error(f"\"{src}\" is not a file")
shutil.copyfile(src, build_path / "app/jni/src" / src.name)
sdl_project_files = (
SDL_ROOT / "src",
SDL_ROOT / "include",
SDL_ROOT / "LICENSE.txt",
SDL_ROOT / "README.md",
SDL_ROOT / "Android.mk",
SDL_ROOT / "CMakeLists.txt",
SDL_ROOT / "cmake",
)
if args.variant == "copy":
(build_path / "app/jni/SDL").mkdir(exist_ok=True, parents=True)
for sdl_project_file in sdl_project_files:
# Copy SDL project files and directories
if sdl_project_file.is_dir():
shutil.copytree(sdl_project_file, build_path / "app/jni/SDL" / sdl_project_file.name)
elif sdl_project_file.is_file():
shutil.copyfile(sdl_project_file, build_path / "app/jni/SDL" / sdl_project_file.name)
elif args.variant == "symlink":
(build_path / "app/jni/SDL").mkdir(exist_ok=True, parents=True)
# Create symbolic links for all SDL project files
for sdl_project_file in sdl_project_files:
os.symlink(sdl_project_file, build_path / "app/jni/SDL" / sdl_project_file.name)
elif args.variant == "aar":
if not args.version:
args.version = extract_sdl_version()
major = args.version.split(".")[0]
aar = f"SDL{ major }-{ args.version }.aar"
# Remove all SDL java classes
shutil.rmtree(build_path / "app/src/main/java")
# Use prefab to generate include-able files
gradle_add_prefab_and_aar(build_path / "app/build.gradle", aar=aar)
# Make sure to use the prefab-generated files and not SDL sources
android_mk_use_prefab(build_path / "app/jni/src/Android.mk")
cmake_mk_no_sdl(build_path / "app/jni/CMakeLists.txt")
aar_libs_folder = build_path / "app/libs"
aar_libs_folder.mkdir(parents=True)
with (aar_libs_folder / "copy-sdl-aars-here.txt").open("w") as f:
f.write(f"Copy {aar} to this folder.\n")
print(f"WARNING: copy { aar } to { aar_libs_folder }", file=sys.stderr)
# Add the package name to build.gradle
gradle_add_package_name(build_path / "app/build.gradle", args.package_name)
# Create entry activity, subclassing SDLActivity
activity = args.package_name[args.package_name.rfind(".") + 1:].capitalize() + "Activity"
activity_path = build_path / "app/src/main/java" / args.package_name.replace(".", "/") / f"{activity}.java"
activity_path.parent.mkdir(parents=True)
with activity_path.open("w") as f:
f.write(textwrap.dedent(f"""
package {args.package_name};
import org.libsdl.app.SDLActivity;
public class {activity} extends SDLActivity
{{
}}
"""))
# Add the just-generated activity to the Android manifest
replace_in_file(build_path / "app/src/main/AndroidManifest.xml", 'name="SDLActivity"', f'name="{activity}"')
# Update project and build
print("To build and install to a device for testing, run the following:")
print(f"cd {build_path}")
print("./gradlew installDebug")
return 0
if __name__ == "__main__":
raise SystemExit(main())

View file

@ -0,0 +1,45 @@
#!/usr/bin/env python3
import argparse
from pathlib import Path
import json
import logging
import re
import subprocess
ROOT = Path(__file__).resolve().parents[1]
def determine_remote() -> str:
text = (ROOT / "build-scripts/release-info.json").read_text()
release_info = json.loads(text)
if "remote" in release_info:
return release_info["remote"]
project_with_version = release_info["name"]
project, _ = re.subn("([^a-zA-Z_])", "", project_with_version)
return f"libsdl-org/{project}"
def main():
default_remote = determine_remote()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("--ref", required=True, help=f"Name of branch or tag containing release.yml")
parser.add_argument("--remote", "-R", default=default_remote, help=f"Remote repo (default={default_remote})")
parser.add_argument("--commit", help=f"Input 'commit' of release.yml (default is the hash of the ref)")
args = parser.parse_args()
if args.commit is None:
args.commit = subprocess.check_output(["git", "rev-parse", args.ref], cwd=ROOT, text=True).strip()
print(f"Running release.yml workflow:")
print(f" remote = {args.remote}")
print(f" ref = {args.ref}")
print(f" commit = {args.commit}")
subprocess.check_call(["gh", "-R", args.remote, "workflow", "run", "release.yml", "--ref", args.ref, "-f", f"commit={args.commit}"], cwd=ROOT)
if __name__ == "__main__":
raise SystemExit(main())

169
vendor/sdl-3.2.10/build-scripts/fnsince.pl vendored Executable file
View file

@ -0,0 +1,169 @@
#!/usr/bin/perl -w
use warnings;
use strict;
use File::Basename;
use Cwd qw(abs_path);
my $wikipath = undef;
foreach (@ARGV) {
$wikipath = abs_path($_), next if not defined $wikipath;
}
chdir(dirname(__FILE__));
chdir('..');
my %fulltags = ();
my @unsorted_releases = ();
open(PIPEFH, '-|', 'git tag -l') or die "Failed to read git release tags: $!\n";
while (<PIPEFH>) {
chomp;
my $fulltag = $_;
if ($fulltag =~ /\A(prerelease|preview|release)\-(\d+)\.(\d+)\.(\d+)\Z/) {
# Ignore anything that isn't a x.y.0 release.
# Make sure new APIs are assigned to the next minor version and ignore the patch versions, but we'll make an except for the prereleases.
my $release_type = $1;
my $major = int($2);
my $minor = int($3);
my $patch = int($4);
next if ($major != 3); # Ignore anything that isn't an SDL3 release.
next if ($patch != 0) && ($minor >= 2); # Ignore anything that is a patch release (unless it was between the preview release and the official release).
# Consider this release version.
my $ver = "${major}.${minor}.${patch}";
push @unsorted_releases, $ver;
$fulltags{$ver} = $fulltag;
}
}
close(PIPEFH);
#print("\n\nUNSORTED\n");
#foreach (@unsorted_releases) {
# print "$_\n";
#}
my @releases = sort {
my @asplit = split /\./, $a;
my @bsplit = split /\./, $b;
my $rc;
for (my $i = 0; $i < scalar(@asplit); $i++) {
return 1 if (scalar(@bsplit) <= $i); # a is "2.0.1" and b is "2.0", or whatever.
my $aseg = $asplit[$i];
my $bseg = $bsplit[$i];
$rc = int($aseg) <=> int($bseg);
return $rc if ($rc != 0); # found the difference.
}
return 0; # still here? They matched completely?!
} @unsorted_releases;
my $current_release = $releases[-1];
my $next_release;
if (scalar(@releases) > 0) {
# this happens to work for how SDL versions things at the moment.
$current_release = $releases[-1];
my @current_release_segments = split /\./, $current_release;
# if we're still in the 3.1.x prereleases, call the "next release" 3.2.0 even if we do more prereleases.
if (($current_release_segments[0] == '3') && ($current_release_segments[1] == '1')) {
$next_release = '3.2.0';
} else {
@current_release_segments[1] = '' . (int($current_release_segments[1]) + 2);
$next_release = join('.', @current_release_segments);
}
}
#print("\n\nSORTED\n");
#foreach (@releases) {
# print "$_\n";
#}
#print("\nCURRENT RELEASE: $current_release\n");
#print("NEXT RELEASE: $next_release\n\n");
push @releases, 'HEAD';
$fulltags{'HEAD'} = 'HEAD';
my %funcs = ();
foreach my $release (@releases) {
#print("Checking $release...\n");
my $tag = $fulltags{$release};
my $blobname = "$tag:src/dynapi/SDL_dynapi_overrides.h";
if ($release =~ /\A3\.[01]\.\d+\Z/) { # make everything up to the first SDL3 official release look like 3.2.0.
$release = '3.2.0';
}
open(PIPEFH, '-|', "git show '$blobname'") or die "Failed to read git blob '$blobname': $!\n";
while (<PIPEFH>) {
chomp;
if (/\A\#define\s+(SDL_.*?)\s+SDL_.*?_REAL\Z/) {
my $fn = $1;
$funcs{$fn} = $release if not defined $funcs{$fn};
}
}
close(PIPEFH);
}
if (not defined $wikipath) {
foreach my $release (@releases) {
foreach my $fn (sort keys %funcs) {
print("$fn: $funcs{$fn}\n") if $funcs{$fn} eq $release;
}
}
} else {
if (defined $wikipath) {
chdir($wikipath);
foreach my $fn (keys %funcs) {
next if $fn eq 'SDL_ThreadID'; # this was a function early on (it's now called SDL_GetThreadID), but now it's a datatype (which originally had a different capitalization).
my $revision = $funcs{$fn};
$revision = $next_release if $revision eq 'HEAD';
my $fname = "$fn.md";
if ( ! -f $fname ) {
#print STDERR "No such file: $fname\n";
next;
}
my @lines = ();
open(FH, '<', $fname) or die("Can't open $fname for read: $!\n");
my $added = 0;
while (<FH>) {
chomp;
if ((/\A\-\-\-\-/) && (!$added)) {
push @lines, "## Version";
push @lines, "";
push @lines, "This function is available since SDL $revision.";
push @lines, "";
$added = 1;
}
push @lines, $_;
next if not /\A\#\#\s+Version/;
$added = 1;
push @lines, "";
push @lines, "This function is available since SDL $revision.";
push @lines, "";
while (<FH>) {
chomp;
next if not (/\A\#\#\s+/ || /\A\-\-\-\-/);
push @lines, $_;
last;
}
}
close(FH);
if (!$added) {
push @lines, "## Version";
push @lines, "";
push @lines, "This function is available since SDL $revision.";
push @lines, "";
}
open(FH, '>', $fname) or die("Can't open $fname for write: $!\n");
foreach (@lines) {
print FH "$_\n";
}
close(FH);
}
}
}

View file

@ -0,0 +1,461 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include <stdio.h>
/*
Built with:
gcc -o genchancvt build-scripts/gen_audio_channel_conversion.c -lm && ./genchancvt > src/audio/SDL_audio_channel_converters.h
*/
#define NUM_CHANNELS 8
static const char *layout_names[NUM_CHANNELS] = {
"Mono", "Stereo", "2.1", "Quad", "4.1", "5.1", "6.1", "7.1"
};
static const char *channel_names[NUM_CHANNELS][NUM_CHANNELS] = {
/* mono */ { "FC" },
/* stereo */ { "FL", "FR" },
/* 2.1 */ { "FL", "FR", "LFE" },
/* quad */ { "FL", "FR", "BL", "BR" },
/* 4.1 */ { "FL", "FR", "LFE", "BL", "BR" },
/* 5.1 */ { "FL", "FR", "FC", "LFE", "BL", "BR" },
/* 6.1 */ { "FL", "FR", "FC", "LFE", "BC", "SL", "SR" },
/* 7.1 */ { "FL", "FR", "FC", "LFE", "BL", "BR", "SL", "SR" },
};
/*
* This table is from FAudio:
*
* https://raw.githubusercontent.com/FNA-XNA/FAudio/master/src/matrix_defaults.inl
*/
static const float channel_conversion_matrix[8][8][64] = {
{
/* 1 x 1 */
{ 1.000000000f },
/* 1 x 2 */
{ 1.000000000f, 1.000000000f },
/* 1 x 3 */
{ 1.000000000f, 1.000000000f, 0.000000000f },
/* 1 x 4 */
{ 1.000000000f, 1.000000000f, 0.000000000f, 0.000000000f },
/* 1 x 5 */
{ 1.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 1 x 6 */
{ 1.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 1 x 7 */
{ 1.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 1 x 8 */
{ 1.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 2 x 1 */
{ 0.500000000f, 0.500000000f },
/* 2 x 2 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 2 x 3 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f },
/* 2 x 4 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 2 x 5 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 2 x 6 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 2 x 7 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 2 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 3 x 1 */
{ 0.333333343f, 0.333333343f, 0.333333343f },
/* 3 x 2 */
{ 0.800000012f, 0.000000000f, 0.200000003f, 0.000000000f, 0.800000012f, 0.200000003f },
/* 3 x 3 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 3 x 4 */
{ 0.888888896f, 0.000000000f, 0.111111112f, 0.000000000f, 0.888888896f, 0.111111112f, 0.000000000f, 0.000000000f, 0.111111112f, 0.000000000f, 0.000000000f, 0.111111112f },
/* 3 x 5 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 3 x 6 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 3 x 7 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 3 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 4 x 1 */
{ 0.250000000f, 0.250000000f, 0.250000000f, 0.250000000f },
/* 4 x 2 */
{ 0.421000004f, 0.000000000f, 0.358999997f, 0.219999999f, 0.000000000f, 0.421000004f, 0.219999999f, 0.358999997f },
/* 4 x 3 */
{ 0.421000004f, 0.000000000f, 0.358999997f, 0.219999999f, 0.000000000f, 0.421000004f, 0.219999999f, 0.358999997f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 4 x 4 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 4 x 5 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 4 x 6 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 4 x 7 */
{ 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.500000000f, 0.500000000f, 0.000000000f, 0.000000000f, 0.796000004f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.796000004f },
/* 4 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 5 x 1 */
{ 0.200000003f, 0.200000003f, 0.200000003f, 0.200000003f, 0.200000003f },
/* 5 x 2 */
{ 0.374222219f, 0.000000000f, 0.111111112f, 0.319111109f, 0.195555553f, 0.000000000f, 0.374222219f, 0.111111112f, 0.195555553f, 0.319111109f },
/* 5 x 3 */
{ 0.421000004f, 0.000000000f, 0.000000000f, 0.358999997f, 0.219999999f, 0.000000000f, 0.421000004f, 0.000000000f, 0.219999999f, 0.358999997f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f },
/* 5 x 4 */
{ 0.941176474f, 0.000000000f, 0.058823530f, 0.000000000f, 0.000000000f, 0.000000000f, 0.941176474f, 0.058823530f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.058823530f, 0.941176474f, 0.000000000f, 0.000000000f, 0.000000000f, 0.058823530f, 0.000000000f, 0.941176474f },
/* 5 x 5 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 5 x 6 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 5 x 7 */
{ 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.500000000f, 0.500000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.796000004f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.796000004f },
/* 5 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 6 x 1 */
{ 0.166666672f, 0.166666672f, 0.166666672f, 0.166666672f, 0.166666672f, 0.166666672f },
/* 6 x 2 */
{ 0.294545442f, 0.000000000f, 0.208181813f, 0.090909094f, 0.251818180f, 0.154545456f, 0.000000000f, 0.294545442f, 0.208181813f, 0.090909094f, 0.154545456f, 0.251818180f },
/* 6 x 3 */
{ 0.324000001f, 0.000000000f, 0.229000002f, 0.000000000f, 0.277000010f, 0.170000002f, 0.000000000f, 0.324000001f, 0.229000002f, 0.000000000f, 0.170000002f, 0.277000010f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f },
/* 6 x 4 */
{ 0.558095276f, 0.000000000f, 0.394285709f, 0.047619049f, 0.000000000f, 0.000000000f, 0.000000000f, 0.558095276f, 0.394285709f, 0.047619049f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.047619049f, 0.558095276f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.047619049f, 0.000000000f, 0.558095276f },
/* 6 x 5 */
{ 0.586000025f, 0.000000000f, 0.414000005f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.586000025f, 0.414000005f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.586000025f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.586000025f },
/* 6 x 6 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 6 x 7 */
{ 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.500000000f, 0.500000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.796000004f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.796000004f },
/* 6 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 7 x 1 */
{ 0.143142849f, 0.143142849f, 0.143142849f, 0.142857149f, 0.143142849f, 0.143142849f, 0.143142849f },
/* 7 x 2 */
{ 0.247384623f, 0.000000000f, 0.174461529f, 0.076923080f, 0.174461529f, 0.226153851f, 0.100615382f, 0.000000000f, 0.247384623f, 0.174461529f, 0.076923080f, 0.174461529f, 0.100615382f, 0.226153851f },
/* 7 x 3 */
{ 0.268000007f, 0.000000000f, 0.188999996f, 0.000000000f, 0.188999996f, 0.245000005f, 0.108999997f, 0.000000000f, 0.268000007f, 0.188999996f, 0.000000000f, 0.188999996f, 0.108999997f, 0.245000005f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 7 x 4 */
{ 0.463679999f, 0.000000000f, 0.327360004f, 0.040000003f, 0.000000000f, 0.168960005f, 0.000000000f, 0.000000000f, 0.463679999f, 0.327360004f, 0.040000003f, 0.000000000f, 0.000000000f, 0.168960005f, 0.000000000f, 0.000000000f, 0.000000000f, 0.040000003f, 0.327360004f, 0.431039989f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.040000003f, 0.327360004f, 0.000000000f, 0.431039989f },
/* 7 x 5 */
{ 0.483000010f, 0.000000000f, 0.340999991f, 0.000000000f, 0.000000000f, 0.175999999f, 0.000000000f, 0.000000000f, 0.483000010f, 0.340999991f, 0.000000000f, 0.000000000f, 0.000000000f, 0.175999999f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.340999991f, 0.449000001f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.340999991f, 0.000000000f, 0.449000001f },
/* 7 x 6 */
{ 0.611000001f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.223000005f, 0.000000000f, 0.000000000f, 0.611000001f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.223000005f, 0.000000000f, 0.000000000f, 0.611000001f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.432000011f, 0.568000019f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.432000011f, 0.000000000f, 0.568000019f },
/* 7 x 7 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 7 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.707000017f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.707000017f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f }
},
{
/* 8 x 1 */
{ 0.125125006f, 0.125125006f, 0.125125006f, 0.125000000f, 0.125125006f, 0.125125006f, 0.125125006f, 0.125125006f },
/* 8 x 2 */
{ 0.211866662f, 0.000000000f, 0.150266662f, 0.066666670f, 0.181066677f, 0.111066669f, 0.194133341f, 0.085866667f, 0.000000000f, 0.211866662f, 0.150266662f, 0.066666670f, 0.111066669f, 0.181066677f, 0.085866667f, 0.194133341f },
/* 8 x 3 */
{ 0.226999998f, 0.000000000f, 0.160999998f, 0.000000000f, 0.194000006f, 0.119000003f, 0.208000004f, 0.092000000f, 0.000000000f, 0.226999998f, 0.160999998f, 0.000000000f, 0.119000003f, 0.194000006f, 0.092000000f, 0.208000004f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 8 x 4 */
{ 0.466344833f, 0.000000000f, 0.329241365f, 0.034482758f, 0.000000000f, 0.000000000f, 0.169931039f, 0.000000000f, 0.000000000f, 0.466344833f, 0.329241365f, 0.034482758f, 0.000000000f, 0.000000000f, 0.000000000f, 0.169931039f, 0.000000000f, 0.000000000f, 0.000000000f, 0.034482758f, 0.466344833f, 0.000000000f, 0.433517247f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.034482758f, 0.000000000f, 0.466344833f, 0.000000000f, 0.433517247f },
/* 8 x 5 */
{ 0.483000010f, 0.000000000f, 0.340999991f, 0.000000000f, 0.000000000f, 0.000000000f, 0.175999999f, 0.000000000f, 0.000000000f, 0.483000010f, 0.340999991f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.175999999f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.483000010f, 0.000000000f, 0.449000001f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.483000010f, 0.000000000f, 0.449000001f },
/* 8 x 6 */
{ 0.518000007f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.188999996f, 0.000000000f, 0.000000000f, 0.518000007f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.188999996f, 0.000000000f, 0.000000000f, 0.518000007f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.518000007f, 0.000000000f, 0.481999993f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.518000007f, 0.000000000f, 0.481999993f },
/* 8 x 7 */
{ 0.541000009f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.541000009f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.541000009f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.287999988f, 0.287999988f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.458999991f, 0.000000000f, 0.541000009f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.458999991f, 0.000000000f, 0.541000009f },
/* 8 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f }
}
};
static char *remove_dots(const char *str) /* this is NOT robust. */
{
static char retval1[32];
static char retval2[32];
static int idx = 0;
char *retval = (idx++ & 1) ? retval1 : retval2;
char *ptr = retval;
while (*str) {
if (*str != '.') {
*(ptr++) = *str;
}
str++;
}
*ptr = '\0';
return retval;
}
static char *lowercase(const char *str) /* this is NOT robust. */
{
static char retval1[32];
static char retval2[32];
static int idx = 0;
char *retval = (idx++ & 1) ? retval1 : retval2;
char *ptr = retval;
while (*str) {
const char ch = *(str++);
*(ptr++) = ((ch >= 'A') && (ch <= 'Z')) ? (ch - ('A' - 'a')) : ch;
}
*ptr = '\0';
return retval;
}
static void write_converter(const int fromchans, const int tochans)
{
const char *fromstr = layout_names[fromchans-1];
const char *tostr = layout_names[tochans-1];
const float *cvtmatrix = channel_conversion_matrix[fromchans-1][tochans-1];
const float *fptr;
const int convert_backwards = (tochans > fromchans);
int input_channel_used[NUM_CHANNELS];
int i, j;
if (tochans == fromchans) {
return; /* nothing to convert, don't generate a converter. */
}
for (i = 0; i < fromchans; i++) {
input_channel_used[i] = 0;
}
fptr = cvtmatrix;
for (j = 0; j < tochans; j++) {
for (i = 0; i < fromchans; i++) {
#if 0
printf("to=%d, from=%d, coeff=%f\n", j, i, *fptr);
#endif
if (*(fptr++) != 0.0f) {
input_channel_used[i]++;
}
}
}
printf("static void SDL_Convert%sTo%s(float *dst, const float *src, int num_frames)\n{\n", remove_dots(fromstr), remove_dots(tostr));
printf(" int i;\n"
"\n"
" LOG_DEBUG_AUDIO_CONVERT(\"%s\", \"%s\");\n"
"\n", lowercase(fromstr), lowercase(tostr));
if (convert_backwards) { /* must convert backwards when growing the output in-place. */
printf(" // convert backwards, since output is growing in-place.\n");
printf(" src += (num_frames-1)");
if (fromchans != 1) {
printf(" * %d", fromchans);
}
printf(";\n");
printf(" dst += (num_frames-1)");
if (tochans != 1) {
printf(" * %d", tochans);
}
printf(";\n");
printf(" for (i = num_frames; i; i--, ");
if (fromchans == 1) {
printf("src--");
} else {
printf("src -= %d", fromchans);
}
printf(", ");
if (tochans == 1) {
printf("dst--");
} else {
printf("dst -= %d", tochans);
}
printf(") {\n");
fptr = cvtmatrix;
for (i = 0; i < fromchans; i++) {
if (input_channel_used[i] > 1) { /* don't read it from src more than once. */
printf(" const float src%s = src[%d];\n", channel_names[fromchans-1][i], i);
}
}
for (j = tochans - 1; j >= 0; j--) {
int has_input = 0;
fptr = cvtmatrix + (fromchans * j);
printf(" dst[%d] /* %s */ =", j, channel_names[tochans-1][j]);
for (i = fromchans - 1; i >= 0; i--) {
const float coefficient = fptr[i];
char srcname[32];
if (coefficient == 0.0f) {
continue;
} else if (input_channel_used[i] > 1) {
snprintf(srcname, sizeof (srcname), "src%s", channel_names[fromchans-1][i]);
} else {
snprintf(srcname, sizeof (srcname), "src[%d]", i);
}
if (has_input) {
printf(" +");
}
has_input = 1;
if (coefficient == 1.0f) {
printf(" %s", srcname);
} else {
printf(" (%s * %.9ff)", srcname, coefficient);
}
}
if (!has_input) {
printf(" 0.0f");
}
printf(";\n");
}
printf(" }\n");
} else {
printf(" for (i = num_frames; i; i--, ");
if (fromchans == 1) {
printf("src++");
} else {
printf("src += %d", fromchans);
}
printf(", ");
if (tochans == 1) {
printf("dst++");
} else {
printf("dst += %d", tochans);
}
printf(") {\n");
fptr = cvtmatrix;
for (i = 0; i < fromchans; i++) {
if (input_channel_used[i] > 1) { /* don't read it from src more than once. */
printf(" const float src%s = src[%d];\n", channel_names[fromchans-1][i], i);
}
}
for (j = 0; j < tochans; j++) {
int has_input = 0;
fptr = cvtmatrix + (fromchans * j);
printf(" dst[%d] /* %s */ =", j, channel_names[tochans-1][j]);
for (i = 0; i < fromchans; i++) {
const float coefficient = fptr[i];
char srcname[32];
if (coefficient == 0.0f) {
continue;
} else if (input_channel_used[i] > 1) {
snprintf(srcname, sizeof (srcname), "src%s", channel_names[fromchans-1][i]);
} else {
snprintf(srcname, sizeof (srcname), "src[%d]", i);
}
if (has_input) {
printf(" +");
}
has_input = 1;
if (coefficient == 1.0f) {
printf(" %s", srcname);
} else {
printf(" (%s * %.9ff)", srcname, coefficient);
}
}
if (!has_input) {
printf(" 0.0f");
}
printf(";\n");
}
printf(" }\n");
}
printf("\n}\n\n");
}
int main(void)
{
int ini, outi;
printf(
"/*\n"
" Simple DirectMedia Layer\n"
" Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>\n"
"\n"
" This software is provided 'as-is', without any express or implied\n"
" warranty. In no event will the authors be held liable for any damages\n"
" arising from the use of this software.\n"
"\n"
" Permission is granted to anyone to use this software for any purpose,\n"
" including commercial applications, and to alter it and redistribute it\n"
" freely, subject to the following restrictions:\n"
"\n"
" 1. The origin of this software must not be misrepresented; you must not\n"
" claim that you wrote the original software. If you use this software\n"
" in a product, an acknowledgment in the product documentation would be\n"
" appreciated but is not required.\n"
" 2. Altered source versions must be plainly marked as such, and must not be\n"
" misrepresented as being the original software.\n"
" 3. This notice may not be removed or altered from any source distribution.\n"
"*/\n"
"\n"
"// DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c\n"
"\n"
"\n"
"typedef void (*SDL_AudioChannelConverter)(float *dst, const float *src, int num_frames);\n"
"\n"
);
for (ini = 1; ini <= NUM_CHANNELS; ini++) {
for (outi = 1; outi <= NUM_CHANNELS; outi++) {
write_converter(ini, outi);
}
}
printf("static const SDL_AudioChannelConverter channel_converters[%d][%d] = { /* [from][to] */\n", NUM_CHANNELS, NUM_CHANNELS);
for (ini = 1; ini <= NUM_CHANNELS; ini++) {
const char *comma = "";
printf(" {");
for (outi = 1; outi <= NUM_CHANNELS; outi++) {
const char *fromstr = layout_names[ini-1];
const char *tostr = layout_names[outi-1];
if (ini == outi) {
printf("%s NULL", comma);
} else {
printf("%s SDL_Convert%sTo%s", comma, remove_dots(fromstr), remove_dots(tostr));
}
comma = ",";
}
printf(" }%s\n", (ini == NUM_CHANNELS) ? "" : ",");
}
printf("};\n\n");
return 0;
}

View file

@ -0,0 +1,78 @@
#!/usr/bin/perl -w
# To use this script: symlink it to .git/hooks/pre-push, then "git push"
#
# This script is called by "git push" after it has checked the remote status,
# but before anything has been pushed. If this script exits with a non-zero
# status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local sha1> <remote ref> <remote sha1>
use warnings;
use strict;
my $remote = $ARGV[0];
my $url = $ARGV[1];
#print("remote: $remote\n");
#print("url: $url\n");
$url =~ s/\.git$//; # change myorg/myproject.git to myorg/myproject
$url =~ s#^git\@github\.com\:#https://github.com/#i;
my $commiturl = $url =~ /\Ahttps?:\/\/github.com\// ? "$url/commit/" : '';
my $z40 = '0000000000000000000000000000000000000000';
my $reported = 0;
while (<STDIN>) {
chomp;
my ($local_ref, $local_sha, $remote_ref, $remote_sha) = split / /;
#print("local_ref: $local_ref\n");
#print("local_sha: $local_sha\n");
#print("remote_ref: $remote_ref\n");
#print("remote_sha: $remote_sha\n");
my $range = '';
if ($remote_sha eq $z40) { # New branch, examine all commits
$range = $local_sha;
} else { # Update to existing branch, examine new commits
$range = "$remote_sha..$local_sha";
}
my $gitcmd = "git log --reverse --oneline --no-abbrev-commit '$range'";
open(GITPIPE, '-|', $gitcmd) or die("\n\n$0: Failed to run '$gitcmd': $!\n\nAbort push!\n\n");
while (<GITPIPE>) {
chomp;
if (/\A([a-fA-F0-9]+)\s+(.*?)\Z/) {
my $hash = $1;
my $msg = $2;
if (!$reported) {
print("\nCommits expected to be pushed:\n");
$reported = 1;
}
#print("hash: $hash\n");
#print("msg: $msg\n");
print("$commiturl$hash -- $msg\n");
} else {
die("$0: Unexpected output from '$gitcmd'!\n\nAbort push!\n\n");
}
}
die("\n\n$0: Failing exit code from running '$gitcmd'!\n\nAbort push!\n\n") if !close(GITPIPE);
}
print("\n") if $reported;
exit(0); # Let the push go forward.

View file

@ -0,0 +1,322 @@
#!/usr/bin/perl -w
# Simple DirectMedia Layer
# Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
# This script was originally written by Ryan C. Gordon for PhysicsFS
# ( https://icculus.org/physfs/ ), under the zlib license: the same license
# that SDL itself uses).
use warnings;
use strict;
my $HASHBUCKETS1_16 = 256;
my $HASHBUCKETS1_32 = 16;
my $HASHBUCKETS2_16 = 16;
my $HASHBUCKETS3_16 = 4;
my $mem_used = 0;
print <<__EOF__;
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken\@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
* This data was generated by SDL/build-scripts/makecasefoldhashtable.pl
*
* Do not manually edit this file!
*/
#ifndef SDL_casefolding_h_
#define SDL_casefolding_h_
/* We build three simple hashmaps here: one that maps Unicode codepoints to
a one, two, or three lowercase codepoints. To retrieve this info: look at
case_fold_hashX, where X is 1, 2, or 3. Most foldable codepoints fold to one,
a few dozen fold to two, and a handful fold to three. If the codepoint isn't
in any of these hashes, it doesn't fold (no separate upper and lowercase).
Almost all these codepoints fit into 16 bits, so we hash them as such to save
memory. If a codepoint is > 0xFFFF, we have separate hashes for them,
since there are (currently) only about 120 of them and (currently) all of them
map to a single lowercase codepoint. */
typedef struct CaseFoldMapping1_32
{
Uint32 from;
Uint32 to0;
} CaseFoldMapping1_32;
typedef struct CaseFoldMapping1_16
{
Uint16 from;
Uint16 to0;
} CaseFoldMapping1_16;
typedef struct CaseFoldMapping2_16
{
Uint16 from;
Uint16 to0;
Uint16 to1;
} CaseFoldMapping2_16;
typedef struct CaseFoldMapping3_16
{
Uint16 from;
Uint16 to0;
Uint16 to1;
Uint16 to2;
} CaseFoldMapping3_16;
typedef struct CaseFoldHashBucket1_16
{
const CaseFoldMapping1_16 *list;
const Uint8 count;
} CaseFoldHashBucket1_16;
typedef struct CaseFoldHashBucket1_32
{
const CaseFoldMapping1_32 *list;
const Uint8 count;
} CaseFoldHashBucket1_32;
typedef struct CaseFoldHashBucket2_16
{
const CaseFoldMapping2_16 *list;
const Uint8 count;
} CaseFoldHashBucket2_16;
typedef struct CaseFoldHashBucket3_16
{
const CaseFoldMapping3_16 *list;
const Uint8 count;
} CaseFoldHashBucket3_16;
__EOF__
my @foldPairs1_16;
my @foldPairs2_16;
my @foldPairs3_16;
my @foldPairs1_32;
for (my $i = 0; $i < $HASHBUCKETS1_16; $i++) {
$foldPairs1_16[$i] = '';
}
for (my $i = 0; $i < $HASHBUCKETS1_32; $i++) {
$foldPairs1_32[$i] = '';
}
for (my $i = 0; $i < $HASHBUCKETS2_16; $i++) {
$foldPairs2_16[$i] = '';
}
for (my $i = 0; $i < $HASHBUCKETS3_16; $i++) {
$foldPairs3_16[$i] = '';
}
open(FH,'<','casefolding.txt') or die("failed to open casefolding.txt: $!\n");
while (<FH>) {
chomp;
# strip comments from textfile...
s/\#.*\Z//;
# strip whitespace...
s/\A\s+//;
s/\s+\Z//;
next if not /\A([a-fA-F0-9]+)\;\s*(.)\;\s*(.+)\;/;
my ($code, $status, $mapping) = ($1, $2, $3);
my $hexxed = hex($code);
#print("// code '$code' status '$status' mapping '$mapping'\n");
if (($status eq 'C') or ($status eq 'F')) {
my ($map1, $map2, $map3) = (undef, undef, undef);
$map1 = $1 if $mapping =~ s/\A([a-fA-F0-9]+)(\s*|\Z)//;
$map2 = $1 if $mapping =~ s/\A([a-fA-F0-9]+)(\s*|\Z)//;
$map3 = $1 if $mapping =~ s/\A([a-fA-F0-9]+)(\s*|\Z)//;
die("mapping space too small for '$code'\n") if ($mapping ne '');
die("problem parsing mapping for '$code'\n") if (not defined($map1));
if ($hexxed < 128) {
# Just ignore these, we'll handle the low-ASCII ones ourselves.
} elsif ($hexxed > 0xFFFF) {
# We just need to add the 32-bit 2 and/or 3 codepoint maps if this die()'s here.
die("Uhoh, a codepoint > 0xFFFF that folds to multiple codepoints! Fixme.") if defined($map2);
my $hashed = (($hexxed ^ ($hexxed >> 8)) & ($HASHBUCKETS1_32-1));
#print("// hexxed '$hexxed' hashed1 '$hashed'\n");
$foldPairs1_32[$hashed] .= " { 0x$code, 0x$map1 },\n";
$mem_used += 8;
} elsif (not defined($map2)) {
my $hashed = (($hexxed ^ ($hexxed >> 8)) & ($HASHBUCKETS1_16-1));
#print("// hexxed '$hexxed' hashed1 '$hashed'\n");
$foldPairs1_16[$hashed] .= " { 0x$code, 0x$map1 },\n";
$mem_used += 4;
} elsif (not defined($map3)) {
my $hashed = (($hexxed ^ ($hexxed >> 8)) & ($HASHBUCKETS2_16-1));
#print("// hexxed '$hexxed' hashed2 '$hashed'\n");
$foldPairs2_16[$hashed] .= " { 0x$code, 0x$map1, 0x$map2 },\n";
$mem_used += 6;
} else {
my $hashed = (($hexxed ^ ($hexxed >> 8)) & ($HASHBUCKETS3_16-1));
#print("// hexxed '$hexxed' hashed3 '$hashed'\n");
$foldPairs3_16[$hashed] .= " { 0x$code, 0x$map1, 0x$map2, 0x$map3 },\n";
$mem_used += 8;
}
}
}
close(FH);
for (my $i = 0; $i < $HASHBUCKETS1_16; $i++) {
$foldPairs1_16[$i] =~ s/,\n\Z//;
my $str = $foldPairs1_16[$i];
next if $str eq '';
my $num = '000' . $i;
$num =~ s/\A.*?(\d\d\d)\Z/$1/;
my $sym = "case_fold1_16_${num}";
print("static const CaseFoldMapping1_16 ${sym}[] = {\n$str\n};\n\n");
}
for (my $i = 0; $i < $HASHBUCKETS1_32; $i++) {
$foldPairs1_32[$i] =~ s/,\n\Z//;
my $str = $foldPairs1_32[$i];
next if $str eq '';
my $num = '000' . $i;
$num =~ s/\A.*?(\d\d\d)\Z/$1/;
my $sym = "case_fold1_32_${num}";
print("static const CaseFoldMapping1_32 ${sym}[] = {\n$str\n};\n\n");
}
for (my $i = 0; $i < $HASHBUCKETS2_16; $i++) {
$foldPairs2_16[$i] =~ s/,\n\Z//;
my $str = $foldPairs2_16[$i];
next if $str eq '';
my $num = '000' . $i;
$num =~ s/\A.*?(\d\d\d)\Z/$1/;
my $sym = "case_fold2_16_${num}";
print("static const CaseFoldMapping2_16 ${sym}[] = {\n$str\n};\n\n");
}
for (my $i = 0; $i < $HASHBUCKETS3_16; $i++) {
$foldPairs3_16[$i] =~ s/,\n\Z//;
my $str = $foldPairs3_16[$i];
next if $str eq '';
my $num = '000' . $i;
$num =~ s/\A.*?(\d\d\d)\Z/$1/;
my $sym = "case_fold3_16_${num}";
print("static const CaseFoldMapping3_16 ${sym}[] = {\n$str\n};\n\n");
}
print("static const CaseFoldHashBucket1_16 case_fold_hash1_16[] = {\n");
for (my $i = 0; $i < $HASHBUCKETS1_16; $i++) {
my $str = $foldPairs1_16[$i];
if ($str eq '') {
print(" { NULL, 0 },\n");
} else {
my $num = '000' . $i;
$num =~ s/\A.*?(\d\d\d)\Z/$1/;
my $sym = "case_fold1_16_${num}";
print(" { $sym, SDL_arraysize($sym) },\n");
}
$mem_used += 12;
}
print("};\n\n");
print("static const CaseFoldHashBucket1_32 case_fold_hash1_32[] = {\n");
for (my $i = 0; $i < $HASHBUCKETS1_32; $i++) {
my $str = $foldPairs1_32[$i];
if ($str eq '') {
print(" { NULL, 0 },\n");
} else {
my $num = '000' . $i;
$num =~ s/\A.*?(\d\d\d)\Z/$1/;
my $sym = "case_fold1_32_${num}";
print(" { $sym, SDL_arraysize($sym) },\n");
}
$mem_used += 12;
}
print("};\n\n");
print("static const CaseFoldHashBucket2_16 case_fold_hash2_16[] = {\n");
for (my $i = 0; $i < $HASHBUCKETS2_16; $i++) {
my $str = $foldPairs2_16[$i];
if ($str eq '') {
print(" { NULL, 0 },\n");
} else {
my $num = '000' . $i;
$num =~ s/\A.*?(\d\d\d)\Z/$1/;
my $sym = "case_fold2_16_${num}";
print(" { $sym, SDL_arraysize($sym) },\n");
}
$mem_used += 12;
}
print("};\n\n");
print("static const CaseFoldHashBucket3_16 case_fold_hash3_16[] = {\n");
for (my $i = 0; $i < $HASHBUCKETS3_16; $i++) {
my $str = $foldPairs3_16[$i];
if ($str eq '') {
print(" { NULL, 0 },\n");
} else {
my $num = '000' . $i;
$num =~ s/\A.*?(\d\d\d)\Z/$1/;
my $sym = "case_fold3_16_${num}";
print(" { $sym, SDL_arraysize($sym) },\n");
}
$mem_used += 12;
}
print("};\n\n");
print <<__EOF__;
#endif /* SDL_casefolding_h_ */
__EOF__
print STDERR "Memory required for case-folding hashtable: $mem_used bytes\n";
exit 0;
# end of makecashfoldhashtable.pl ...

162
vendor/sdl-3.2.10/build-scripts/mkinstalldirs vendored Executable file
View file

@ -0,0 +1,162 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
scriptversion=2020-07-26.22; # UTC
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain.
#
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
IFS=" "" $nl"
errstatus=0
dirmode=
usage="\
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
Create each directory DIR (with mode MODE, if specified), including all
leading file name components.
Report bugs to <bug-automake@gnu.org>."
# process command line arguments
while test $# -gt 0 ; do
case $1 in
-h | --help | --h*) # -h for help
echo "$usage"
exit $?
;;
-m) # -m PERM arg
shift
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
dirmode=$1
shift
;;
--version)
echo "$0 $scriptversion"
exit $?
;;
--) # stop option processing
shift
break
;;
-*) # unknown option
echo "$usage" 1>&2
exit 1
;;
*) # first non-opt arg
break
;;
esac
done
for file
do
if test -d "$file"; then
shift
else
break
fi
done
case $# in
0) exit 0 ;;
esac
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
# mkdir -p a/c at the same time, both will detect that a is missing,
# one will create a, then the other will try to create a and die with
# a "File exists" error. This is a problem when calling mkinstalldirs
# from a parallel make. We use --version in the probe to restrict
# ourselves to GNU mkdir, which is thread-safe.
case $dirmode in
'')
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
else
# On NextStep and OpenStep, the 'mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because '.' already
# exists.
test -d ./-p && rmdir ./-p
test -d ./--version && rmdir ./--version
fi
;;
*)
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
test ! -d ./--version; then
echo "umask 22"
umask 22
echo "mkdir -m $dirmode -p -- $*"
exec mkdir -m "$dirmode" -p -- "$@"
else
# Clean up after NextStep and OpenStep mkdir.
for d in ./-m ./-p ./--version "./$dirmode";
do
test -d $d && rmdir $d
done
fi
;;
esac
echo "umask 22"
umask 22
for file
do
case $file in
/*) pathcomp=/ ;;
*) pathcomp= ;;
esac
oIFS=$IFS
IFS=/
set fnord $file
shift
IFS=$oIFS
for d
do
test "x$d" = x && continue
pathcomp=$pathcomp$d
case $pathcomp in
-*) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp=$pathcomp/
done
if test ! -z "$dirmode"; then
echo "chmod $dirmode $file"
chmod "$dirmode" "$file" || errstatus=$?
fi
done
exit $errstatus
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

View file

@ -0,0 +1,91 @@
# Using this package
This package contains @<@PROJECT_NAME@>@ built for the Android platform.
## Gradle integration
For integration with CMake/ndk-build, it uses [prefab](https://google.github.io/prefab/).
Copy the aar archive (@<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@.aar) to a `app/libs` directory of your project.
In `app/build.gradle` of your Android project, add:
```
android {
/* ... */
buildFeatures {
prefab true
}
}
dependencies {
implementation files('libs/@<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@.aar')
/* ... */
}
```
If you're using CMake, add the following to your CMakeLists.txt:
```
find_package(@<@PROJECT_NAME@>@ REQUIRED CONFIG)
target_link_libraries(yourgame PRIVATE @<@PROJECT_NAME@>@::@<@PROJECT_NAME@>@)
```
If you use ndk-build, add the following before `include $(BUILD_SHARED_LIBRARY)` to your `Android.mk`:
```
LOCAL_SHARED_LIBARARIES := SDL3 SDL3-Headers
```
And add the following at the bottom:
```
# https://google.github.io/prefab/build-systems.html
# Add the prefab modules to the import path.
$(call import-add-path,/out)
# Import @<@PROJECT_NAME@>@ so we can depend on it.
$(call import-module,prefab/@<@PROJECT_NAME@>@)
```
---
## Other build systems (advanced)
If you want to build a project without Gradle,
running the following command will extract the Android archive into a more common directory structure.
```
python @<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@.aar -o android_prefix
```
Add `--help` for a list of all available options.
# Documentation
An API reference, tutorials, and additional documentation is available at:
https://wiki.libsdl.org/@<@PROJECT_NAME@>@
# Example code
There are simple example programs available at:
https://examples.libsdl.org/SDL3
# Discussions
## Discord
You can join the official Discord server at:
https://discord.com/invite/BwpFGBWsv8
## Forums/mailing lists
You can join SDL development discussions at:
https://discourse.libsdl.org/
Once you sign up, you can use the forum through the website or as a mailing list from your email client.
## Announcement list
You can sign up for the low traffic announcement list at:
https://www.libsdl.org/mailing-list.php

View file

@ -0,0 +1,104 @@
#!/usr/bin/env python
"""
Create a @<@PROJECT_NAME@>@ SDK prefix from an Android archive
This file is meant to be placed in a the root of an android .aar archive
Example usage:
```sh
python @<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@.aar -o /usr/opt/android-sdks
cmake -S my-project \
-DCMAKE_PREFIX_PATH=/usr/opt/android-sdks \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-B build-arm64 -DANDROID_ABI=arm64-v8a \
-DCMAKE_BUILD_TYPE=Releaase
cmake --build build-arm64
```
"""
import argparse
import io
import json
import os
import pathlib
import re
import stat
import zipfile
AAR_PATH = pathlib.Path(__file__).resolve().parent
ANDROID_ARCHS = { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" }
def main():
parser = argparse.ArgumentParser(
description="Convert a @<@PROJECT_NAME@>@ Android .aar archive into a SDK",
allow_abbrev=False,
)
parser.add_argument("--version", action="version", version="@<@PROJECT_NAME@>@ @<@PROJECT_VERSION@>@")
parser.add_argument("-o", dest="output", type=pathlib.Path, required=True, help="Folder where to store the SDK")
args = parser.parse_args()
print(f"Creating a @<@PROJECT_NAME@>@ SDK at {args.output}...")
prefix = args.output
incdir = prefix / "include"
libdir = prefix / "lib"
RE_LIB_MODULE_ARCH = re.compile(r"prefab/modules/(?P<module>[A-Za-z0-9_-]+)/libs/android\.(?P<arch>[a-zA-Z0-9_-]+)/(?P<filename>lib[A-Za-z0-9_]+\.(?:so|a))")
RE_INC_MODULE_ARCH = re.compile(r"prefab/modules/(?P<module>[A-Za-z0-9_-]+)/include/(?P<header>[a-zA-Z0-9_./-]+)")
RE_LICENSE = re.compile(r"(?:.*/)?(?P<filename>(?:license|copying)(?:\.md|\.txt)?)", flags=re.I)
RE_PROGUARD = re.compile(r"(?:.*/)?(?P<filename>proguard.*\.(?:pro|txt))", flags=re.I)
RE_CMAKE = re.compile(r"(?:.*/)?(?P<filename>.*\.cmake)", flags=re.I)
with zipfile.ZipFile(AAR_PATH) as zf:
project_description = json.loads(zf.read("description.json"))
project_name = project_description["name"]
project_version = project_description["version"]
licensedir = prefix / "share/licenses" / project_name
cmakedir = libdir / "cmake" / project_name
javadir = prefix / "share/java" / project_name
javadocdir = prefix / "share/javadoc" / project_name
def read_zipfile_and_write(path: pathlib.Path, zippath: str):
data = zf.read(zippath)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(data)
for zip_info in zf.infolist():
zippath = zip_info.filename
if m := RE_LIB_MODULE_ARCH.match(zippath):
lib_path = libdir / m["arch"] / m["filename"]
read_zipfile_and_write(lib_path, zippath)
if m["filename"].endswith(".so"):
os.chmod(lib_path, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)
elif m := RE_INC_MODULE_ARCH.match(zippath):
header_path = incdir / m["header"]
read_zipfile_and_write(header_path, zippath)
elif m:= RE_LICENSE.match(zippath):
license_path = licensedir / m["filename"]
read_zipfile_and_write(license_path, zippath)
elif m:= RE_PROGUARD.match(zippath):
proguard_path = javadir / m["filename"]
read_zipfile_and_write(proguard_path, zippath)
elif m:= RE_CMAKE.match(zippath):
cmake_path = cmakedir / m["filename"]
read_zipfile_and_write(cmake_path, zippath)
elif zippath == "classes.jar":
versioned_jar_path = javadir / f"{project_name}-{project_version}.jar"
unversioned_jar_path = javadir / f"{project_name}.jar"
read_zipfile_and_write(versioned_jar_path, zippath)
os.symlink(src=versioned_jar_path.name, dst=unversioned_jar_path)
elif zippath == "classes-sources.jar":
jarpath = javadir / f"{project_name}-{project_version}-sources.jar"
read_zipfile_and_write(jarpath, zippath)
elif zippath == "classes-doc.jar":
jarpath = javadocdir / f"{project_name}-{project_version}-javadoc.jar"
read_zipfile_and_write(jarpath, zippath)
print("... done")
return 0
if __name__ == "__main__":
raise SystemExit(main())

View file

@ -0,0 +1,148 @@
# SDL CMake configuration file:
# This file is meant to be placed in lib/cmake/SDL3 subfolder of a reconstructed Android SDL3 SDK
cmake_minimum_required(VERSION 3.0...3.28)
include(FeatureSummary)
set_package_properties(SDL3 PROPERTIES
URL "https://www.libsdl.org/"
DESCRIPTION "low level access to audio, keyboard, mouse, joystick, and graphics hardware"
)
# Copied from `configure_package_config_file`
macro(set_and_check _var _file)
set(${_var} "${_file}")
if(NOT EXISTS "${_file}")
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
endif()
endmacro()
# Copied from `configure_package_config_file`
macro(check_required_components _NAME)
foreach(comp ${${_NAME}_FIND_COMPONENTS})
if(NOT ${_NAME}_${comp}_FOUND)
if(${_NAME}_FIND_REQUIRED_${comp})
set(${_NAME}_FOUND FALSE)
endif()
endif()
endforeach()
endmacro()
set(SDL3_FOUND TRUE)
if(SDL_CPU_X86)
set(_sdl_arch_subdir "x86")
elseif(SDL_CPU_X64)
set(_sdl_arch_subdir "x86_64")
elseif(SDL_CPU_ARM32)
set(_sdl_arch_subdir "armeabi-v7a")
elseif(SDL_CPU_ARM64)
set(_sdl_arch_subdir "arm64-v8a")
else()
set(SDL3_FOUND FALSE)
return()
endif()
get_filename_component(_sdl3_prefix "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
get_filename_component(_sdl3_prefix "${_sdl3_prefix}/.." ABSOLUTE)
get_filename_component(_sdl3_prefix "${_sdl3_prefix}/.." ABSOLUTE)
set_and_check(_sdl3_prefix "${_sdl3_prefix}")
set_and_check(_sdl3_include_dirs "${_sdl3_prefix}/include")
set_and_check(_sdl3_lib "${_sdl3_prefix}/lib/${_sdl_arch_subdir}/libSDL3.so")
set_and_check(_sdl3test_lib "${_sdl3_prefix}/lib/${_sdl_arch_subdir}/libSDL3_test.a")
set_and_check(_sdl3_jar "${_sdl3_prefix}/share/java/SDL3/SDL3-${SDL3_VERSION}.jar")
unset(_sdl_arch_subdir)
unset(_sdl3_prefix)
# All targets are created, even when some might not be requested though COMPONENTS.
# This is done for compatibility with CMake generated SDL3-target.cmake files.
if(NOT TARGET SDL3::Headers)
add_library(SDL3::Headers INTERFACE IMPORTED)
set_target_properties(SDL3::Headers
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_sdl3_include_dirs}"
)
endif()
set(SDL3_Headers_FOUND TRUE)
unset(_sdl3_include_dirs)
if(EXISTS "${_sdl3_lib}")
if(NOT TARGET SDL3::SDL3-shared)
add_library(SDL3::SDL3-shared SHARED IMPORTED)
set_target_properties(SDL3::SDL3-shared
PROPERTIES
INTERFACE_LINK_LIBRARIES "SDL3::Headers"
IMPORTED_LOCATION "${_sdl3_lib}"
COMPATIBLE_INTERFACE_BOOL "SDL3_SHARED"
INTERFACE_SDL3_SHARED "ON"
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
INTERFACE_SDL_VERSION "SDL3"
)
endif()
set(SDL3_SDL3-shared_FOUND TRUE)
else()
set(SDL3_SDL3-shared_FOUND FALSE)
endif()
unset(_sdl3_lib)
set(SDL3_SDL3-static_FOUND FALSE)
if(EXISTS "${_sdl3test_lib}")
if(NOT TARGET SDL3::SDL3_test)
add_library(SDL3::SDL3_test STATIC IMPORTED)
set_target_properties(SDL3::SDL3_test
PROPERTIES
INTERFACE_LINK_LIBRARIES "SDL3::Headers"
IMPORTED_LOCATION "${_sdl3test_lib}"
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
INTERFACE_SDL_VERSION "SDL3"
)
endif()
set(SDL3_SDL3_test_FOUND TRUE)
else()
set(SDL3_SDL3_test_FOUND FALSE)
endif()
unset(_sdl3test_lib)
if(SDL3_SDL3-shared_FOUND)
set(SDL3_SDL3_FOUND TRUE)
endif()
function(_sdl_create_target_alias_compat NEW_TARGET TARGET)
if(CMAKE_VERSION VERSION_LESS "3.18")
# Aliasing local targets is not supported on CMake < 3.18, so make it global.
add_library(${NEW_TARGET} INTERFACE IMPORTED)
set_target_properties(${NEW_TARGET} PROPERTIES INTERFACE_LINK_LIBRARIES "${TARGET}")
else()
add_library(${NEW_TARGET} ALIAS ${TARGET})
endif()
endfunction()
# Make sure SDL3::SDL3 always exists
if(NOT TARGET SDL3::SDL3)
if(TARGET SDL3::SDL3-shared)
_sdl_create_target_alias_compat(SDL3::SDL3 SDL3::SDL3-shared)
endif()
endif()
if(EXISTS "${_sdl3_jar}")
if(NOT TARGET SDL3::Jar)
add_library(SDL3::Jar INTERFACE IMPORTED)
set_property(TARGET SDL3::Jar PROPERTY JAR_FILE "${_sdl3_jar}")
endif()
set(SDL3_Jar_FOUND TRUE)
else()
set(SDL3_Jar_FOUND FALSE)
endif()
unset(_sdl3_jar)
check_required_components(SDL3)
set(SDL3_LIBRARIES SDL3::SDL3)
set(SDL3_STATIC_LIBRARIES SDL3::SDL3-static)
set(SDL3_STATIC_PRIVATE_LIBS)
set(SDL3TEST_LIBRARY SDL3::SDL3_test)

View file

@ -0,0 +1,38 @@
# @<@PROJECT_NAME@>@ CMake version configuration file:
# This file is meant to be placed in a lib/cmake/@<@PROJECT_NAME@>@ subfolder of a reconstructed Android SDL3 SDK
set(PACKAGE_VERSION "@<@PROJECT_VERSION@>@")
if(PACKAGE_FIND_VERSION_RANGE)
# Package version must be in the requested version range
if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
endif()
else()
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
endif()
# if the using project doesn't have CMAKE_SIZEOF_VOID_P set, fail.
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/sdlcpu.cmake")
SDL_DetectTargetCPUArchitectures(_detected_archs)
# check that the installed version has a compatible architecture as the one which is currently searching:
if(NOT(SDL_CPU_X86 OR SDL_CPU_X64 OR SDL_CPU_ARM32 OR SDL_CPU_ARM64))
set(PACKAGE_VERSION "${PACKAGE_VERSION} (X86,X64,ARM32,ARM64)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()

View file

@ -0,0 +1,5 @@
{
"name": "@<@PROJECT_NAME@>@",
"version": "@<@PROJECT_VERSION@>@",
"git-hash": "@<@PROJECT_COMMIT@>@"
}

View file

@ -0,0 +1,53 @@
# Using this package
This package contains @<@PROJECT_NAME@>@ built for the mingw-w64 toolchain.
The files for 32-bit architecture are in i686-w64-mingw32
The files for 64-bit architecture are in x86_64-w64-mingw32
You can install them to another location, just type `make` for help.
To use this package, point your include path at _arch_/include and your library path at _arch_/lib, link with the @<@PROJECT_NAME@>@ library and copy _arch_/bin/@<@PROJECT_NAME@>@.dll next to your executable.
e.g.
```sh
gcc -o hello.exe hello.c -Ix86_64-w64-mingw32/include -Lx86_64-w64-mingw32/lib -l@<@PROJECT_NAME@>@
cp x86_64-w64-mingw32/bin/@<@PROJECT_NAME@>@.dll .
./hello.exe
```
# Documentation
An API reference, tutorials, and additional documentation is available at:
https://wiki.libsdl.org/@<@PROJECT_NAME@>@
# Example code
There are simple example programs available at:
https://examples.libsdl.org/SDL3
# Discussions
## Discord
You can join the official Discord server at:
https://discord.com/invite/BwpFGBWsv8
## Forums/mailing lists
You can join SDL development discussions at:
https://discourse.libsdl.org/
Once you sign up, you can use the forum through the website or as a mailing list from your email client.
## Announcement list
You can sign up for the low traffic announcement list at:
https://www.libsdl.org/mailing-list.php

View file

@ -0,0 +1,39 @@
#
# Makefile for installing the mingw32 version of the SDL library
DESTDIR = /usr/local
ARCHITECTURES := i686-w64-mingw32 x86_64-w64-mingw32
default:
@echo "Run \"make install-i686\" to install 32-bit"
@echo "Run \"make install-x86_64\" to install 64-bit"
@echo "Run \"make install-all\" to install both"
@echo "Add DESTDIR=/custom/path to change the destination folder"
install:
@if test -d $(ARCH) && test -d $(DESTDIR); then \
(cd $(ARCH) && cp -rv bin include lib share $(DESTDIR)/); \
else \
echo "*** ERROR: $(ARCH) or $(DESTDIR) does not exist!"; \
exit 1; \
fi
install-i686:
$(MAKE) install ARCH=i686-w64-mingw32
install-x86_64:
$(MAKE) install ARCH=x86_64-w64-mingw32
install-all:
@if test -d $(DESTDIR); then \
mkdir -p $(DESTDIR)/cmake; \
cp -rv cmake/* $(DESTDIR)/cmake; \
for arch in $(ARCHITECTURES); do \
$(MAKE) install ARCH=$$arch DESTDIR=$(DESTDIR)/$$arch; \
done \
else \
echo "*** ERROR: $(DESTDIR) does not exist!"; \
exit 1; \
fi
.PHONY: default install install-i686 install-x86_64 install-all

View file

@ -0,0 +1,19 @@
# SDL3 CMake configuration file:
# This file is meant to be placed in a cmake subfolder of SDL3-devel-3.x.y-mingw
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL3/SDL3Config.cmake")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL3/SDL3Config.cmake")
else()
set(SDL3_FOUND FALSE)
return()
endif()
if(NOT EXISTS "${sdl3_config_path}")
message(WARNING "${sdl3_config_path} does not exist: MinGW development package is corrupted")
set(SDL3_FOUND FALSE)
return()
endif()
include("${sdl3_config_path}")

View file

@ -0,0 +1,19 @@
# SDL3 CMake version configuration file:
# This file is meant to be placed in a cmake subfolder of SDL3-devel-3.x.y-mingw
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL3/SDL3ConfigVersion.cmake")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL3/SDL3ConfigVersion.cmake")
else()
set(PACKAGE_VERSION_UNSUITABLE TRUE)
return()
endif()
if(NOT EXISTS "${sdl3_config_path}")
message(WARNING "${sdl3_config_path} does not exist: MinGW development package is corrupted")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
return()
endif()
include("${sdl3_config_path}")

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>SDL_VENDOR_INFO="libsdl.org";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
</Project>

View file

@ -0,0 +1,45 @@
# Using this package
This package contains @<@PROJECT_NAME@>@ built for Visual Studio.
To use this package, edit your project properties:
- Add the include directory to "VC++ Directories" -> "Include Directories"
- Add the lib/_arch_ directory to "VC++ Directories" -> "Library Directories"
- Add @<@PROJECT_NAME@>@.lib to Linker -> Input -> "Additional Dependencies"
- Copy lib/_arch_/@<@PROJECT_NAME@>@.dll to your project directory.
# Documentation
An API reference, tutorials, and additional documentation is available at:
https://wiki.libsdl.org/@<@PROJECT_NAME@>@
# Example code
There are simple example programs available at:
https://examples.libsdl.org/SDL3
# Discussions
## Discord
You can join the official Discord server at:
https://discord.com/invite/BwpFGBWsv8
## Forums/mailing lists
You can join SDL development discussions at:
https://discourse.libsdl.org/
Once you sign up, you can use the forum through the website or as a mailing list from your email client.
## Announcement list
You can sign up for the low traffic announcement list at:
https://www.libsdl.org/mailing-list.php

View file

@ -0,0 +1,13 @@
# Using this package
This package contains @<@PROJECT_NAME@>@ built for arm64 Windows.
To use this package, simply replace an existing 64-bit ARM @<@PROJECT_NAME@>@.dll with the one included here.
# Development packages
If you're looking for packages with headers and libraries, you can download one of these:
- @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-VC.zip, for development using Visual Studio
- @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-mingw.zip, for development using mingw-w64

View file

@ -0,0 +1,135 @@
# @<@PROJECT_NAME@>@ CMake configuration file:
# This file is meant to be placed in a cmake subfolder of @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-VC.zip
cmake_minimum_required(VERSION 3.0...3.28)
include(FeatureSummary)
set_package_properties(SDL3 PROPERTIES
URL "https://www.libsdl.org/"
DESCRIPTION "low level access to audio, keyboard, mouse, joystick, and graphics hardware"
)
# Copied from `configure_package_config_file`
macro(set_and_check _var _file)
set(${_var} "${_file}")
if(NOT EXISTS "${_file}")
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
endif()
endmacro()
# Copied from `configure_package_config_file`
macro(check_required_components _NAME)
foreach(comp ${${_NAME}_FIND_COMPONENTS})
if(NOT ${_NAME}_${comp}_FOUND)
if(${_NAME}_FIND_REQUIRED_${comp})
set(${_NAME}_FOUND FALSE)
endif()
endif()
endforeach()
endmacro()
set(SDL3_FOUND TRUE)
if(SDL_CPU_X86)
set(_sdl_arch_subdir "x86")
elseif(SDL_CPU_X64 OR SDL_CPU_ARM64EC)
set(_sdl_arch_subdir "x64")
elseif(SDL_CPU_ARM64)
set(_sdl_arch_subdir "arm64")
else()
set(SDL3_FOUND FALSE)
return()
endif()
get_filename_component(_sdl3_prefix "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
set_and_check(_sdl3_prefix "${_sdl3_prefix}")
set(_sdl3_include_dirs "${_sdl3_prefix}/include")
set(_sdl3_implib "${_sdl3_prefix}/lib/${_sdl_arch_subdir}/SDL3.lib")
set(_sdl3_dll "${_sdl3_prefix}/lib/${_sdl_arch_subdir}/SDL3.dll")
set(_sdl3test_lib "${_sdl3_prefix}/lib/${_sdl_arch_subdir}/SDL3_test.lib")
unset(_sdl_arch_subdir)
unset(_sdl3_prefix)
# All targets are created, even when some might not be requested though COMPONENTS.
# This is done for compatibility with CMake generated SDL3-target.cmake files.
if(NOT TARGET SDL3::Headers)
add_library(SDL3::Headers INTERFACE IMPORTED)
set_target_properties(SDL3::Headers
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_sdl3_include_dirs}"
)
endif()
set(SDL3_Headers_FOUND TRUE)
unset(_sdl3_include_dirs)
if(EXISTS "${_sdl3_implib}" AND EXISTS "${_sdl3_dll}")
if(NOT TARGET SDL3::SDL3-shared)
add_library(SDL3::SDL3-shared SHARED IMPORTED)
set_target_properties(SDL3::SDL3-shared
PROPERTIES
INTERFACE_LINK_LIBRARIES "SDL3::Headers"
IMPORTED_IMPLIB "${_sdl3_implib}"
IMPORTED_LOCATION "${_sdl3_dll}"
COMPATIBLE_INTERFACE_BOOL "SDL3_SHARED"
INTERFACE_SDL3_SHARED "ON"
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
INTERFACE_SDL_VERSION "SDL3"
)
endif()
set(SDL3_SDL3-shared_FOUND TRUE)
else()
set(SDL3_SDL3-shared_FOUND FALSE)
endif()
unset(_sdl3_implib)
unset(_sdl3_dll)
set(SDL3_SDL3-static_FOUND FALSE)
if(EXISTS "${_sdl3test_lib}")
if(NOT TARGET SDL3::SDL3_test)
add_library(SDL3::SDL3_test STATIC IMPORTED)
set_target_properties(SDL3::SDL3_test
PROPERTIES
INTERFACE_LINK_LIBRARIES "SDL3::Headers"
IMPORTED_LOCATION "${_sdl3test_lib}"
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
INTERFACE_SDL_VERSION "SDL3"
)
endif()
set(SDL3_SDL3_test_FOUND TRUE)
else()
set(SDL3_SDL3_test_FOUND FALSE)
endif()
unset(_sdl3test_lib)
if(SDL3_SDL3-shared_FOUND OR SDL3_SDL3-static_FOUND)
set(SDL3_SDL3_FOUND TRUE)
endif()
function(_sdl_create_target_alias_compat NEW_TARGET TARGET)
if(CMAKE_VERSION VERSION_LESS "3.18")
# Aliasing local targets is not supported on CMake < 3.18, so make it global.
add_library(${NEW_TARGET} INTERFACE IMPORTED)
set_target_properties(${NEW_TARGET} PROPERTIES INTERFACE_LINK_LIBRARIES "${TARGET}")
else()
add_library(${NEW_TARGET} ALIAS ${TARGET})
endif()
endfunction()
# Make sure SDL3::SDL3 always exists
if(NOT TARGET SDL3::SDL3)
if(TARGET SDL3::SDL3-shared)
_sdl_create_target_alias_compat(SDL3::SDL3 SDL3::SDL3-shared)
endif()
endif()
check_required_components(SDL3)
set(SDL3_LIBRARIES SDL3::SDL3)
set(SDL3_STATIC_LIBRARIES SDL3::SDL3-static)
set(SDL3_STATIC_PRIVATE_LIBS)
set(SDL3TEST_LIBRARY SDL3::SDL3_test)

View file

@ -0,0 +1,38 @@
# @<@PROJECT_NAME@>@ CMake version configuration file:
# This file is meant to be placed in a cmake subfolder of @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-VC.zip
set(PACKAGE_VERSION "@<@PROJECT_VERSION@>@")
if(PACKAGE_FIND_VERSION_RANGE)
# Package version must be in the requested version range
if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
endif()
else()
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
endif()
# if the using project doesn't have CMAKE_SIZEOF_VOID_P set, fail.
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/sdlcpu.cmake")
SDL_DetectTargetCPUArchitectures(_detected_archs)
# check that the installed version has a compatible architecture as the one which is currently searching:
if(NOT(SDL_CPU_X86 OR SDL_CPU_X64 OR SDL_CPU_ARM64 OR SDL_CPU_ARM64EC))
set(PACKAGE_VERSION "${PACKAGE_VERSION} (X86,X64,ARM64)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()

View file

@ -0,0 +1,13 @@
# Using this package
This package contains @<@PROJECT_NAME@>@ built for x64 Windows.
To use this package, simply replace an existing 64-bit @<@PROJECT_NAME@>@.dll with the one included here.
# Development packages
If you're looking for packages with headers and libraries, you can download one of these:
- @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-VC.zip, for development using Visual Studio
- @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-mingw.zip, for development using mingw-w64

View file

@ -0,0 +1,13 @@
# Using this package
This package contains @<@PROJECT_NAME@>@ built for x86 Windows.
To use this package, simply replace an existing 32-bit @<@PROJECT_NAME@>@.dll with the one included here.
# Development packages
If you're looking for packages with headers and libraries, you can download one of these:
- @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-VC.zip, for development using Visual Studio
- @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-mingw.zip, for development using mingw-w64

View file

@ -0,0 +1,41 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* WIKI CATEGORY: Version */
/*
* SDL_revision.h contains the SDL revision, which might be defined on the
* compiler command line, or generated right into the header itself by the
* build system.
*/
#ifndef SDL_revision_h_
#define SDL_revision_h_
#cmakedefine SDL_VENDOR_INFO "@SDL_VENDOR_INFO@"
#if defined(SDL_VENDOR_INFO)
#define SDL_REVISION "@<@PROJECT_REVISION@>@ (" SDL_VENDOR_INFO ")"
#else
#define SDL_REVISION "@<@PROJECT_REVISION@>@"
#endif
#endif /* SDL_revision_h_ */

View file

@ -0,0 +1,56 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* WIKI CATEGORY: Version */
/*
* SDL_revision.h contains the SDL revision, which might be defined on the
* compiler command line, or generated right into the header itself by the
* build system.
*/
#ifndef SDL_revision_h_
#define SDL_revision_h_
#ifdef SDL_WIKI_DOCUMENTATION_SECTION
/**
* This macro is a string describing the source at a particular point in
* development.
*
* This string is often generated from revision control's state at build time.
*
* This string can be quite complex and does not follow any standard. For
* example, it might be something like "SDL-prerelease-3.1.1-47-gf687e0732".
* It might also be user-defined at build time, so it's best to treat it as a
* clue in debugging forensics and not something the app will parse in any
* way.
*
* \since This macro is available since SDL 3.0.0.
*/
#define SDL_REVISION "Some arbitrary string decided at SDL build time"
#elif defined(SDL_VENDOR_INFO)
#define SDL_REVISION "@<@PROJECT_REVISION@>@ (" SDL_VENDOR_INFO ")"
#else
#define SDL_REVISION "@<@PROJECT_REVISION@>@"
#endif
#endif /* SDL_revision_h_ */

View file

@ -0,0 +1,210 @@
{
"name": "SDL3",
"remote": "libsdl-org/SDL",
"version": {
"file": "include/SDL3/SDL_version.h",
"re_major": "^#define SDL_MAJOR_VERSION\\s+([0-9]+)$",
"re_minor": "^#define SDL_MINOR_VERSION\\s+([0-9]+)$",
"re_micro": "^#define SDL_MICRO_VERSION\\s+([0-9]+)$"
},
"source": {
"checks": [
"src/SDL.c",
"include/SDL3/SDL.h",
"test/testsprite.c",
"android-project/app/src/main/java/org/libsdl/app/SDLActivity.java"
],
"files": {
"include/SDL3": [
"build-scripts/pkg-support/source/SDL_revision.h.in:SDL_revision.h"
],
"include/build_config": [
"build-scripts/pkg-support/source/SDL_revision.h.cmake.in:SDL_revision.h.cmake"
]
}
},
"dmg": {
"project": "Xcode/SDL/SDL.xcodeproj",
"path": "Xcode/SDL/build/SDL3.dmg",
"target": "SDL3.dmg",
"build-xcconfig": "Xcode/SDL/pkg-support/build.xcconfig"
},
"mingw": {
"cmake": {
"archs": ["x86", "x64"],
"args": [
"-DSDL_SHARED=ON",
"-DSDL_STATIC=OFF",
"-DSDL_DISABLE_INSTALL_DOCS=ON",
"-DSDL_RELOCATABLE=ON",
"-DSDL_TEST_LIBRARY=ON",
"-DSDL_TESTS=OFF",
"-DSDL_VENDOR_INFO=libsdl.org"
],
"shared-static": "args"
},
"files": {
"": [
"build-scripts/pkg-support/mingw/INSTALL.md.in:INSTALL.md",
"build-scripts/pkg-support/mingw/Makefile",
"LICENSE.txt",
"README.md"
],
"cmake": [
"build-scripts/pkg-support/mingw/cmake/SDL3Config.cmake",
"build-scripts/pkg-support/mingw/cmake/SDL3ConfigVersion.cmake"
]
}
},
"msvc": {
"msbuild": {
"archs": [
"x86",
"x64"
],
"directory-build-props": "build-scripts/pkg-support/msvc/Directory.Build.props",
"projects": [
"VisualC/SDL/SDL.vcxproj",
"VisualC/SDL_test/SDL_test.vcxproj"
],
"files-lib": {
"": [
"VisualC/SDL/@<@PLATFORM@>@/@<@CONFIGURATION@>@/SDL3.dll"
]
},
"files-devel": {
"lib/@<@ARCH@>@": [
"VisualC/SDL/@<@PLATFORM@>@/@<@CONFIGURATION@>@/SDL3.dll",
"VisualC/SDL/@<@PLATFORM@>@/@<@CONFIGURATION@>@/SDL3.lib",
"VisualC/SDL/@<@PLATFORM@>@/@<@CONFIGURATION@>@/SDL3.pdb",
"VisualC/SDL_test/@<@PLATFORM@>@/@<@CONFIGURATION@>@/SDL3_test.lib"
]
}
},
"cmake": {
"archs": [
"arm64"
],
"args": [
"-DSDL_SHARED=ON",
"-DSDL_STATIC=OFF",
"-DSDL_TEST_LIBRARY=ON",
"-DSDL_TESTS=OFF",
"-DSDL_DISABLE_INSTALL_DOCS=ON",
"-DSDL_RELOCATABLE=ON",
"-DSDL_VENDOR_INFO=libsdl.org"
],
"files-lib": {
"": [
"bin/SDL3.dll"
]
},
"files-devel": {
"lib/@<@ARCH@>@": [
"bin/SDL3.dll",
"bin/SDL3.pdb",
"lib/SDL3.lib",
"lib/SDL3_test.lib"
]
}
},
"files-lib": {
"": [
"build-scripts/pkg-support/msvc/@<@ARCH@>@/INSTALL.md.in:INSTALL.md",
"LICENSE.txt",
"README.md"
]
},
"files-devel": {
"": [
"build-scripts/pkg-support/msvc/INSTALL.md.in:INSTALL.md",
"LICENSE.txt",
"README.md"
],
"cmake": [
"build-scripts/pkg-support/msvc/cmake/SDL3Config.cmake.in:SDL3Config.cmake",
"build-scripts/pkg-support/msvc/cmake/SDL3ConfigVersion.cmake.in:SDL3ConfigVersion.cmake",
"cmake/sdlcpu.cmake"
],
"include/SDL3": [
"include/SDL3/*.h"
]
}
},
"android": {
"cmake": {
"args": [
"-DSDL_SHARED=ON",
"-DSDL_STATIC=OFF",
"-DSDL_TEST_LIBRARY=ON",
"-DSDL_TESTS=OFF",
"-DSDL_ANDROID_JAR=ON",
"-DSDL_INSTALL=ON",
"-DSDL_INSTALL_DOCS=ON",
"-DSDL_VENDOR_INFO=libsdl.org"
]
},
"modules": {
"SDL3-Headers": {
"type": "interface",
"includes": {
"SDL3": ["include/SDL3/*.h"]
}
},
"Headers": {
"type": "interface",
"export-libraries": [":SDL3-Headers"]
},
"SDL3_test": {
"type": "library",
"library": "lib/libSDL3_test.a",
"export-libraries": [":Headers"]
},
"SDL3-shared": {
"type": "library",
"library": "lib/libSDL3.so",
"export-libraries": [":Headers"]
},
"SDL3": {
"type": "interface",
"export-libraries": [":SDL3-shared"]
}
},
"jars": {
"classes": "share/java/@<@PROJECT_NAME@>@/@<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@.jar",
"sources": "share/java/@<@PROJECT_NAME@>@/@<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@-sources.jar",
"doc": "share/javadoc/@<@PROJECT_NAME@>@/@<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@-javadoc.jar"
},
"abis": [
"armeabi-v7a",
"arm64-v8a",
"x86",
"x86_64"
],
"api-minimum": 21,
"api-target": 35,
"ndk-minimum": 21,
"aar-files": {
"": [
"android-project/app/proguard-rules.pro:proguard.txt",
"build-scripts/pkg-support/android/aar/__main__.py.in:__main__.py",
"build-scripts/pkg-support/android/aar/description.json.in:description.json"
],
"META-INF": [
"LICENSE.txt"
],
"cmake": [
"cmake/sdlcpu.cmake",
"build-scripts/pkg-support/android/aar/cmake/SDL3Config.cmake",
"build-scripts/pkg-support/android/aar/cmake/SDL3ConfigVersion.cmake.in:SDL3ConfigVersion.cmake"
]
},
"files": {
"": [
"build-scripts/pkg-support/android/INSTALL.md.in:INSTALL.md",
"LICENSE.txt",
"README.md"
]
}
}
}

254
vendor/sdl-3.2.10/build-scripts/rename_api.py vendored Executable file
View file

@ -0,0 +1,254 @@
#!/usr/bin/env python3
#
# This script renames symbols in the API, updating SDL_oldnames.h and
# adding documentation for the change.
import argparse
import os
import pathlib
import pprint
import re
import sys
from rename_symbols import create_regex_from_replacements, replace_symbols_in_path
SDL_ROOT = pathlib.Path(__file__).resolve().parents[1]
SDL_INCLUDE_DIR = SDL_ROOT / "include/SDL3"
SDL_BUILD_SCRIPTS = SDL_ROOT / "build-scripts"
def main():
if len(args.args) == 0 or (len(args.args) % 2) != 0:
print("Usage: %s [-h] [--skip-header-check] header {enum,function,hint,structure,symbol} [old new ...]" % sys.argv[0])
exit(1)
# Check whether we can still modify the ABI
version_header = pathlib.Path( SDL_INCLUDE_DIR / "SDL_version.h" ).read_text()
if not re.search(r"SDL_MINOR_VERSION\s+[01]\s", version_header):
raise Exception("ABI is frozen, symbols cannot be renamed")
# Find the symbol in the headers
if pathlib.Path(args.header).is_file():
header = pathlib.Path(args.header)
else:
header = pathlib.Path(SDL_INCLUDE_DIR / args.header)
if not header.exists():
raise Exception("Couldn't find header %s" % header)
header_name = header.name
if (header.name == "SDL_gamepad.h"):
header_name = "SDL_gamecontroller.h"
header_text = header.read_text()
# Replace the symbols in source code
replacements = {}
i = 0
while i < len(args.args):
oldname = args.args[i + 0]
newname = args.args[i + 1]
if not args.skip_header_check and not re.search((r"\b%s\b" % oldname), header_text):
raise Exception("Couldn't find %s in %s" % (oldname, header))
replacements[ oldname ] = newname
replacements[ oldname + "_REAL" ] = newname + "_REAL"
i += 2
regex = create_regex_from_replacements(replacements)
for dir in ["src", "test", "examples", "include", "docs", "cmake/test"]:
replace_symbols_in_path(SDL_ROOT / dir, regex, replacements)
# Replace the symbols in documentation
i = 0
while i < len(args.args):
oldname = args.args[i + 0]
newname = args.args[i + 1]
add_symbol_to_oldnames(header_name, oldname, newname)
add_symbol_to_migration(header_name, args.type, oldname, newname)
add_symbol_to_coccinelle(args.type, oldname, newname)
i += 2
def add_line(lines, i, section):
lines.insert(i, section)
i += 1
return i
def add_content(lines, i, content, add_trailing_line):
if lines[i - 1] == "":
lines[i - 1] = content
else:
i = add_line(lines, i, content)
if add_trailing_line:
i = add_line(lines, i, "")
return i
def add_symbol_to_coccinelle(symbol_type, oldname, newname):
file = open(SDL_BUILD_SCRIPTS / "SDL_migration.cocci", "a")
# Append-adds at last
if symbol_type == "function":
file.write("@@\n")
file.write("@@\n")
file.write("- %s\n" % oldname)
file.write("+ %s\n" % newname)
file.write(" (...)\n")
if symbol_type == "symbol":
file.write("@@\n")
file.write("@@\n")
file.write("- %s\n" % oldname)
file.write("+ %s\n" % newname)
# double check ?
if symbol_type == "hint":
file.write("@@\n")
file.write("@@\n")
file.write("- %s\n" % oldname)
file.write("+ %s\n" % newname)
if symbol_type == "enum" or symbol_type == "structure":
file.write("@@\n")
file.write("typedef %s, %s;\n" % (oldname, newname))
file.write("@@\n")
file.write("- %s\n" % oldname)
file.write("+ %s\n" % newname)
file.close()
def add_symbol_to_oldnames(header, oldname, newname):
file = (SDL_INCLUDE_DIR / "SDL_oldnames.h")
lines = file.read_text().splitlines()
mode = 0
i = 0
while i < len(lines):
line = lines[i]
if line == "#ifdef SDL_ENABLE_OLD_NAMES":
if mode == 0:
mode = 1
section = ("/* ##%s */" % header)
section_added = False
content = ("#define %s %s" % (oldname, newname))
content_added = False
else:
raise Exception("add_symbol_to_oldnames(): expected mode 0")
elif line == "#elif !defined(SDL_DISABLE_OLD_NAMES)":
if mode == 1:
if not section_added:
i = add_line(lines, i, section)
if not content_added:
i = add_content(lines, i, content, True)
mode = 2
section = ("/* ##%s */" % header)
section_added = False
content = ("#define %s %s_renamed_%s" % (oldname, oldname, newname))
content_added = False
else:
raise Exception("add_symbol_to_oldnames(): expected mode 1")
elif line == "#endif /* SDL_ENABLE_OLD_NAMES */":
if mode == 2:
if not section_added:
i = add_line(lines, i, section)
if not content_added:
i = add_content(lines, i, content, True)
mode = 3
else:
raise Exception("add_symbol_to_oldnames(): expected mode 2")
elif line != "" and (mode == 1 or mode == 2):
if line.startswith("/* ##"):
if section_added:
if not content_added:
i = add_content(lines, i, content, True)
content_added = True
elif line == section:
section_added = True
elif section < line:
i = add_line(lines, i, section)
section_added = True
i = add_content(lines, i, content, True)
content_added = True
elif line != "" and section_added and not content_added:
if content == line:
content_added = True
elif content < line:
i = add_content(lines, i, content, False)
content_added = True
i += 1
file.write_text("\n".join(lines) + "\n")
def add_symbol_to_migration(header, symbol_type, oldname, newname):
file = (SDL_ROOT / "docs/README-migration.md")
lines = file.read_text().splitlines()
section = ("## %s" % header)
section_added = False
note = ("The following %ss have been renamed:" % symbol_type)
note_added = False
if symbol_type == "function":
content = ("* %s() => %s()" % (oldname, newname))
else:
content = ("* %s => %s" % (oldname, newname))
content_added = False
mode = 0
i = 0
while i < len(lines):
line = lines[i]
if line.startswith("##") and line.endswith(".h"):
if line == section:
section_added = True
elif section < line:
break
elif section_added and not note_added:
if note == line:
note_added = True
elif note_added and not content_added:
if content == line:
content_added = True
elif line == "" or content < line:
i = add_line(lines, i, content)
content_added = True
i += 1
if not section_added:
i = add_line(lines, i, section)
i = add_line(lines, i, "")
if not note_added:
i = add_line(lines, i, note)
if not content_added:
i = add_content(lines, i, content, True)
file.write_text("\n".join(lines) + "\n")
if __name__ == "__main__":
parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
parser.add_argument("--skip-header-check", action="store_true")
parser.add_argument("header")
parser.add_argument("type", choices=["enum", "function", "hint", "structure", "symbol"])
parser.add_argument("args", nargs="*")
args = parser.parse_args()
try:
main()
except Exception as e:
print(e)
exit(-1)
exit(0)

View file

@ -0,0 +1,75 @@
#!/usr/bin/env python3
#
# This script renames SDL headers in the specified paths
import argparse
import pathlib
import re
def do_include_replacements(paths):
replacements = [
( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_image.h(?:[\">])"), r"<SDL3_image/SDL_image.h>" ),
( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_mixer.h(?:[\">])"), r"<SDL3_mixer/SDL_mixer.h>" ),
( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_net.h(?:[\">])"), r"<SDL3_net/SDL_net.h>" ),
( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_rtf.h(?:[\">])"), r"<SDL3_rtf/SDL_rtf.h>" ),
( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_ttf.h(?:[\">])"), r"<SDL3_ttf/SDL_ttf.h>" ),
( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_gamecontroller.h(?:[\">])"), r"<SDL3/SDL_gamepad.h>" ),
( re.compile(r"(?:[\"<])(?:SDL2/)?begin_code.h(?:[\">])"), r"<SDL3/SDL_begin_code.h>" ),
( re.compile(r"(?:[\"<])(?:SDL2/)?close_code.h(?:[\">])"), r"<SDL3/SDL_close_code.h>" ),
( re.compile(r"(?:[\"<])(?:SDL2/)?(SDL[_a-z0-9]*\.h)(?:[\">])"), r"<SDL3/\1>" )
]
for entry in paths:
path = pathlib.Path(entry)
if not path.exists():
print("{} does not exist, skipping".format(entry))
continue
replace_headers_in_path(path, replacements)
def replace_headers_in_file(file, replacements):
try:
with file.open("r", encoding="UTF-8", newline="") as rfp:
original = rfp.read()
contents = original
for regex, replacement in replacements:
contents = regex.sub(replacement, contents)
if contents != original:
with file.open("w", encoding="UTF-8", newline="") as wfp:
wfp.write(contents)
except UnicodeDecodeError:
print("%s is not text, skipping" % file)
except Exception as err:
print("%s" % err)
def replace_headers_in_dir(path, replacements):
for entry in path.glob("*"):
if entry.is_dir():
replace_headers_in_dir(entry, replacements)
else:
print("Processing %s" % entry)
replace_headers_in_file(entry, replacements)
def replace_headers_in_path(path, replacements):
if path.is_dir():
replace_headers_in_dir(path, replacements)
else:
replace_headers_in_file(path, replacements)
def main():
parser = argparse.ArgumentParser(fromfile_prefix_chars='@', description="Rename #include's for SDL3.")
parser.add_argument("args", metavar="PATH", nargs="*", help="Input source file")
args = parser.parse_args()
try:
do_include_replacements(args.args)
except Exception as e:
print(e)
return 1
if __name__ == "__main__":
raise SystemExit(main())

View file

@ -0,0 +1,382 @@
#!/usr/bin/env python3
#
# This script renames SDL macros in the specified paths
import argparse
import pathlib
import re
class TextReplacer:
def __init__(self, macros, repl_format):
if isinstance(macros, dict):
macros_keys = macros.keys()
else:
macros_keys = macros
self.macros = macros
self.re_macros = re.compile(r"\W(" + "|".join(macros_keys) + r")(?:\W|$)")
self.repl_format = repl_format
def apply(self, contents):
def cb(m):
macro = m.group(1)
original = m.group(0)
match_start, _ = m.span(0)
platform_start, platform_end = m.span(1)
if isinstance(self.macros, dict):
repl_args = (macro, self.macros[macro])
else:
repl_args = macro,
new_text = self.repl_format.format(*repl_args)
r = original[:(platform_start-match_start)] + new_text + original[platform_end-match_start:]
return r
contents, _ = self.re_macros.subn(cb, contents)
return contents
class MacrosCheck:
def __init__(self):
self.renamed_platform_macros = TextReplacer(RENAMED_MACROS, "{1}")
self.deprecated_platform_macros = TextReplacer(DEPRECATED_PLATFORM_MACROS, "{0} /* {0} has been removed in SDL3 */")
def run(self, contents):
contents = self.renamed_platform_macros.apply(contents)
contents = self.deprecated_platform_macros.apply(contents)
return contents
def apply_checks(paths):
checks = (
MacrosCheck(),
)
for entry in paths:
path = pathlib.Path(entry)
if not path.exists():
print("{} does not exist, skipping".format(entry))
continue
apply_checks_in_path(path, checks)
def apply_checks_in_file(file, checks):
try:
with file.open("r", encoding="UTF-8", newline="") as rfp:
original = rfp.read()
contents = original
for check in checks:
contents = check.run(contents)
if contents != original:
with file.open("w", encoding="UTF-8", newline="") as wfp:
wfp.write(contents)
except UnicodeDecodeError:
print("%s is not text, skipping" % file)
except Exception as err:
print("%s" % err)
def apply_checks_in_dir(path, checks):
for entry in path.glob("*"):
if entry.is_dir():
apply_checks_in_dir(entry, checks)
else:
print("Processing %s" % entry)
apply_checks_in_file(entry, checks)
def apply_checks_in_path(path, checks):
if path.is_dir():
apply_checks_in_dir(path, checks)
else:
apply_checks_in_file(path, checks)
def main():
parser = argparse.ArgumentParser(fromfile_prefix_chars='@', description="Rename macros for SDL3")
parser.add_argument("args", nargs="*", help="Input source files")
args = parser.parse_args()
try:
apply_checks(args.args)
except Exception as e:
print(e)
return 1
RENAMED_MACROS = {
"__AIX__": "SDL_PLATFORM_AIX",
"__HAIKU__": "SDL_PLATFORM_HAIKU",
"__BSDI__": "SDL_PLATFORM_BSDI",
"__FREEBSD__": "SDL_PLATFORM_FREEBSD",
"__HPUX__": "SDL_PLATFORM_HPUX",
"__IRIX__": "SDL_PLATFORM_IRIX",
"__LINUX__": "SDL_PLATFORM_LINUX",
"__OS2__": "SDL_PLATFORM_OS2",
# "__ANDROID__": "SDL_PLATFORM_ANDROID,
"__APPLE__": "SDL_PLATFORM_APPLE",
"__TVOS__": "SDL_PLATFORM_TVOS",
"__IPHONEOS__": "SDL_PLATFORM_IOS",
"__MACOSX__": "SDL_PLATFORM_MACOS",
"__NETBSD__": "SDL_PLATFORM_NETBSD",
"__OPENBSD__": "SDL_PLATFORM_OPENBSD",
"__OSF__": "SDL_PLATFORM_OSF",
"__QNXNTO__": "SDL_PLATFORM_QNXNTO",
"__RISCOS__": "SDL_PLATFORM_RISCOS",
"__SOLARIS__": "SDL_PLATFORM_SOLARIS",
"__PSP__": "SDL_PLATFORM_PSP",
"__PS2__": "SDL_PLATFORM_PS2",
"__VITA__": "SDL_PLATFORM_VITA",
"__3DS__": "SDL_PLATFORM_3DS",
# "__unix__": "SDL_PLATFORM_UNIX,
"__XBOXSERIES__": "SDL_PLATFORM_XBOXSERIES",
"__XBOXONE__": "SDL_PLATFORM_XBOXONE",
"__WINDOWS__": "SDL_PLATFORM_WINDOWS",
"__WIN32__": "SDL_PLATFORM_WIN32",
# "__CYGWIN_": "SDL_PLATFORM_CYGWIN",
"__WINGDK__": "SDL_PLATFORM_WINGDK",
"__GDK__": "SDL_PLATFORM_GDK",
# "__EMSCRIPTEN__": "SDL_PLATFORM_EMSCRIPTEN",
}
DEPRECATED_PLATFORM_MACROS = {
"__DREAMCAST__",
"__NACL__",
"__PNACL__",
"__WINDOWS__",
"__WINRT__",
"SDL_ALTIVEC_BLITTERS",
"SDL_ARM_NEON_BLITTERS",
"SDL_ARM_SIMD_BLITTERS",
"SDL_ATOMIC_DISABLED",
"SDL_AUDIO_DISABLED",
"SDL_AUDIO_DRIVER_AAUDIO",
"SDL_AUDIO_DRIVER_ALSA",
"SDL_AUDIO_DRIVER_ALSA_DYNAMIC",
"SDL_AUDIO_DRIVER_ANDROID",
"SDL_AUDIO_DRIVER_ARTS",
"SDL_AUDIO_DRIVER_ARTS_DYNAMIC",
"SDL_AUDIO_DRIVER_COREAUDIO",
"SDL_AUDIO_DRIVER_DISK",
"SDL_AUDIO_DRIVER_DSOUND",
"SDL_AUDIO_DRIVER_DUMMY",
"SDL_AUDIO_DRIVER_EMSCRIPTEN",
"SDL_AUDIO_DRIVER_ESD",
"SDL_AUDIO_DRIVER_ESD_DYNAMIC",
"SDL_AUDIO_DRIVER_FUSIONSOUND",
"SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC",
"SDL_AUDIO_DRIVER_HAIKU",
"SDL_AUDIO_DRIVER_JACK",
"SDL_AUDIO_DRIVER_JACK_DYNAMIC",
"SDL_AUDIO_DRIVER_N3DS",
"SDL_AUDIO_DRIVER_NAS",
"SDL_AUDIO_DRIVER_NAS_DYNAMIC",
"SDL_AUDIO_DRIVER_NETBSD",
"SDL_AUDIO_DRIVER_OPENSLES",
"SDL_AUDIO_DRIVER_OS2",
"SDL_AUDIO_DRIVER_OSS",
"SDL_AUDIO_DRIVER_PAUDIO",
"SDL_AUDIO_DRIVER_PIPEWIRE",
"SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC",
"SDL_AUDIO_DRIVER_PS2",
"SDL_AUDIO_DRIVER_PSP",
"SDL_AUDIO_DRIVER_PULSEAUDIO",
"SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC",
"SDL_AUDIO_DRIVER_QSA",
"SDL_AUDIO_DRIVER_SNDIO",
"SDL_AUDIO_DRIVER_SNDIO_DYNAMIC",
"SDL_AUDIO_DRIVER_SUNAUDIO",
"SDL_AUDIO_DRIVER_VITA",
"SDL_AUDIO_DRIVER_WASAPI",
"SDL_AUDIO_DRIVER_WINMM",
"SDL_CPUINFO_DISABLED",
"SDL_DEFAULT_ASSERT_LEVEL",
"SDL_EVENTS_DISABLED",
"SDL_FILESYSTEM_ANDROID",
"SDL_FILESYSTEM_COCOA",
"SDL_FILESYSTEM_DISABLED",
"SDL_FILESYSTEM_DUMMY",
"SDL_FILESYSTEM_EMSCRIPTEN",
"SDL_FILESYSTEM_HAIKU",
"SDL_FILESYSTEM_N3DS",
"SDL_FILESYSTEM_OS2",
"SDL_FILESYSTEM_PS2",
"SDL_FILESYSTEM_PSP",
"SDL_FILESYSTEM_RISCOS",
"SDL_FILESYSTEM_UNIX",
"SDL_FILESYSTEM_VITA",
"SDL_FILESYSTEM_WINDOWS",
"SDL_FILE_DISABLED",
"SDL_HAPTIC_ANDROID",
"SDL_HAPTIC_DINPUT",
"SDL_HAPTIC_DISABLED",
"SDL_HAPTIC_DUMMY",
"SDL_HAPTIC_IOKIT",
"SDL_HAPTIC_LINUX",
"SDL_HAPTIC_XINPUT",
"SDL_HAVE_LIBDECOR_GET_MIN_MAX",
"SDL_HAVE_MACHINE_JOYSTICK_H",
"SDL_HIDAPI_DISABLED",
"SDL_INPUT_FBSDKBIO",
"SDL_INPUT_LINUXEV",
"SDL_INPUT_LINUXKD",
"SDL_INPUT_WSCONS",
"SDL_IPHONE_KEYBOARD",
"SDL_IPHONE_LAUNCHSCREEN",
"SDL_JOYSTICK_ANDROID",
"SDL_JOYSTICK_DINPUT",
"SDL_JOYSTICK_DISABLED",
"SDL_JOYSTICK_DUMMY",
"SDL_JOYSTICK_EMSCRIPTEN",
"SDL_JOYSTICK_HAIKU",
"SDL_JOYSTICK_HIDAPI",
"SDL_JOYSTICK_IOKIT",
"SDL_JOYSTICK_LINUX",
"SDL_JOYSTICK_MFI",
"SDL_JOYSTICK_N3DS",
"SDL_JOYSTICK_OS2",
"SDL_JOYSTICK_PS2",
"SDL_JOYSTICK_PSP",
"SDL_JOYSTICK_RAWINPUT",
"SDL_JOYSTICK_USBHID",
"SDL_JOYSTICK_VIRTUAL",
"SDL_JOYSTICK_VITA",
"SDL_JOYSTICK_WGI",
"SDL_JOYSTICK_XINPUT",
"SDL_LIBSAMPLERATE_DYNAMIC",
"SDL_LIBUSB_DYNAMIC",
"SDL_LOADSO_DISABLED",
"SDL_LOADSO_DLOPEN",
"SDL_LOADSO_DUMMY",
"SDL_LOADSO_LDG",
"SDL_LOADSO_OS2",
"SDL_LOADSO_WINDOWS",
"SDL_LOCALE_DISABLED",
"SDL_LOCALE_DUMMY",
"SDL_MISC_DISABLED",
"SDL_MISC_DUMMY",
"SDL_POWER_ANDROID",
"SDL_POWER_DISABLED",
"SDL_POWER_EMSCRIPTEN",
"SDL_POWER_HAIKU",
"SDL_POWER_HARDWIRED",
"SDL_POWER_LINUX",
"SDL_POWER_MACOSX",
"SDL_POWER_N3DS",
"SDL_POWER_PSP",
"SDL_POWER_UIKIT",
"SDL_POWER_VITA",
"SDL_POWER_WINDOWS",
"SDL_POWER_WINRT",
"SDL_RENDER_DISABLED",
"SDL_SENSOR_ANDROID",
"SDL_SENSOR_COREMOTION",
"SDL_SENSOR_DISABLED",
"SDL_SENSOR_DUMMY",
"SDL_SENSOR_N3DS",
"SDL_SENSOR_VITA",
"SDL_SENSOR_WINDOWS",
"SDL_THREADS_DISABLED",
"SDL_THREAD_GENERIC_COND_SUFFIX",
"SDL_THREAD_N3DS",
"SDL_THREAD_OS2",
"SDL_THREAD_PS2",
"SDL_THREAD_PSP",
"SDL_THREAD_PTHREAD",
"SDL_THREAD_PTHREAD_RECURSIVE_MUTEX",
"SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP",
"SDL_THREAD_VITA",
"SDL_THREAD_WINDOWS",
"SDL_TIMERS_DISABLED",
"SDL_TIMER_DUMMY",
"SDL_TIMER_HAIKU",
"SDL_TIMER_N3DS",
"SDL_TIMER_OS2",
"SDL_TIMER_PS2",
"SDL_TIMER_PSP",
"SDL_TIMER_UNIX",
"SDL_TIMER_VITA",
"SDL_TIMER_WINDOWS",
"SDL_UDEV_DYNAMIC",
"SDL_USE_IME",
"SDL_USE_LIBICONV",
"SDL_VIDEO_DISABLED",
"SDL_VIDEO_DRIVER_ANDROID",
"SDL_VIDEO_DRIVER_COCOA",
"SDL_VIDEO_DRIVER_DIRECTFB",
"SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC",
"SDL_VIDEO_DRIVER_DUMMY",
"SDL_VIDEO_DRIVER_EMSCRIPTEN",
"SDL_VIDEO_DRIVER_HAIKU",
"SDL_VIDEO_DRIVER_KMSDRM",
"SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC",
"SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM",
"SDL_VIDEO_DRIVER_N3DS",
"SDL_VIDEO_DRIVER_OFFSCREEN",
"SDL_VIDEO_DRIVER_OS2",
"SDL_VIDEO_DRIVER_PS2",
"SDL_VIDEO_DRIVER_PSP",
"SDL_VIDEO_DRIVER_QNX",
"SDL_VIDEO_DRIVER_RISCOS",
"SDL_VIDEO_DRIVER_RPI",
"SDL_VIDEO_DRIVER_UIKIT",
"SDL_VIDEO_DRIVER_VITA",
"SDL_VIDEO_DRIVER_VIVANTE",
"SDL_VIDEO_DRIVER_VIVANTE_VDK",
"SDL_VIDEO_DRIVER_WAYLAND",
"SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC",
"SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR",
"SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL",
"SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR",
"SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON",
"SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH",
"SDL_VIDEO_DRIVER_WINDOWS",
"SDL_VIDEO_DRIVER_WINRT",
"SDL_VIDEO_DRIVER_X11",
"SDL_VIDEO_DRIVER_X11_DYNAMIC",
"SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR",
"SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT",
"SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES",
"SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2",
"SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR",
"SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS",
"SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM",
"SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS",
"SDL_VIDEO_DRIVER_X11_XCURSOR",
"SDL_VIDEO_DRIVER_X11_XDBE",
"SDL_VIDEO_DRIVER_X11_XFIXES",
"SDL_VIDEO_DRIVER_X11_XINPUT2",
"SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH",
"SDL_VIDEO_DRIVER_X11_XRANDR",
"SDL_VIDEO_DRIVER_X11_XSCRNSAVER",
"SDL_VIDEO_DRIVER_X11_XSHAPE",
"SDL_VIDEO_METAL",
"SDL_VIDEO_OPENGL",
"SDL_VIDEO_OPENGL_BGL",
"SDL_VIDEO_OPENGL_CGL",
"SDL_VIDEO_OPENGL_EGL",
"SDL_VIDEO_OPENGL_ES",
"SDL_VIDEO_OPENGL_ES2",
"SDL_VIDEO_OPENGL_GLX",
"SDL_VIDEO_OPENGL_OSMESA",
"SDL_VIDEO_OPENGL_OSMESA_DYNAMIC",
"SDL_VIDEO_OPENGL_WGL",
"SDL_VIDEO_RENDER_D3D",
"SDL_VIDEO_RENDER_D3D11",
"SDL_VIDEO_RENDER_D3D12",
"SDL_VIDEO_RENDER_DIRECTFB",
"SDL_VIDEO_RENDER_METAL",
"SDL_VIDEO_RENDER_OGL",
"SDL_VIDEO_RENDER_OGL_ES",
"SDL_VIDEO_RENDER_OGL_ES2",
"SDL_VIDEO_RENDER_PS2",
"SDL_VIDEO_RENDER_PSP",
"SDL_VIDEO_RENDER_VITA_GXM",
"SDL_VIDEO_VITA_PIB",
"SDL_VIDEO_VITA_PVR",
"SDL_VIDEO_VITA_PVR_OGL",
"SDL_VIDEO_VULKAN",
}
if __name__ == "__main__":
raise SystemExit(main())

View file

@ -0,0 +1,130 @@
#!/usr/bin/env python3
#
# This script renames symbols in the specified paths
import argparse
import os
import pathlib
import re
import sys
SDL_ROOT = pathlib.Path(__file__).resolve().parents[1]
SDL_INCLUDE_DIR = SDL_ROOT / "include/SDL3"
def main():
if args.all_symbols:
if len(args.args) < 1:
print("Usage: %s --all-symbols files_or_directories ..." % sys.argv[0])
exit(1)
replacements = get_all_replacements()
entries = args.args
else:
if len(args.args) < 3:
print("Usage: %s [--substring] oldname newname files_or_directories ..." % sys.argv[0])
exit(1)
replacements = { args.args[0]: args.args[1] }
entries = args.args[2:]
if args.substring:
regex = create_substring_regex_from_replacements(replacements)
else:
regex = create_regex_from_replacements(replacements)
for entry in entries:
path = pathlib.Path(entry)
if not path.exists():
print("%s doesn't exist, skipping" % entry)
continue
replace_symbols_in_path(path, regex, replacements)
def get_all_replacements():
replacements = {}
file = (SDL_INCLUDE_DIR / "SDL_oldnames.h")
mode = 0
for line in file.read_text().splitlines():
if line == "#ifdef SDL_ENABLE_OLD_NAMES":
if mode == 0:
mode = 1
else:
raise Exception("get_all_replacements(): expected mode 0")
elif line == "#elif !defined(SDL_DISABLE_OLD_NAMES)":
if mode == 1:
mode = 2
else:
raise Exception("get_all_replacements(): expected mode 1")
elif line == "#endif /* SDL_ENABLE_OLD_NAMES */":
if mode == 2:
mode = 3
else:
raise Exception("add_symbol_to_oldnames(): expected mode 2")
elif mode == 1 and line.startswith("#define "):
words = line.split()
replacements[words[1]] = words[2]
# In case things are accidentally renamed to the "X_renamed_Y" symbol
#replacements[words[1] + "_renamed_" + words[2]] = words[2]
return replacements
def create_regex_from_replacements(replacements):
return re.compile(r"\b(%s)\b" % "|".join(map(re.escape, replacements.keys())))
def create_substring_regex_from_replacements(replacements):
return re.compile(r"(%s)" % "|".join(map(re.escape, replacements.keys())))
def replace_symbols_in_file(file, regex, replacements):
try:
with file.open("r", encoding="UTF-8", newline="") as rfp:
original = rfp.read()
contents = regex.sub(lambda mo: replacements[mo.string[mo.start():mo.end()]], original)
if contents != original:
with file.open("w", encoding="UTF-8", newline="") as wfp:
wfp.write(contents)
except UnicodeDecodeError:
print("%s is not text, skipping" % file)
except Exception as err:
print("%s" % err)
def replace_symbols_in_dir(path, regex, replacements):
for entry in path.glob("*"):
if entry.is_dir():
replace_symbols_in_dir(entry, regex, replacements)
else:
print("Processing %s" % entry)
replace_symbols_in_file(entry, regex, replacements)
def replace_symbols_in_path(path, regex, replacements):
if path.is_dir():
replace_symbols_in_dir(path, regex, replacements)
else:
replace_symbols_in_file(path, regex, replacements)
if __name__ == "__main__":
parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
parser.add_argument("--all-symbols", action="store_true")
parser.add_argument("--substring", action="store_true")
parser.add_argument("args", nargs="*")
args = parser.parse_args()
try:
main()
except Exception as e:
print(e)
exit(-1)
exit(0)

View file

@ -0,0 +1,80 @@
#!/usr/bin/env python3
#
# This script renames symbols in the specified paths
import argparse
import os
import pathlib
import re
import sys
def main():
if len(args.args) < 1:
print("Usage: %s files_or_directories ..." % sys.argv[0])
exit(1)
replacements = {
"SDL_bool": "bool",
"SDL_TRUE": "true",
"SDL_FALSE": "false",
}
entries = args.args[0:]
regex = create_regex_from_replacements(replacements)
for entry in entries:
path = pathlib.Path(entry)
if not path.exists():
print("%s doesn't exist, skipping" % entry)
continue
replace_symbols_in_path(path, regex, replacements)
def create_regex_from_replacements(replacements):
return re.compile(r"\b(%s)\b" % "|".join(map(re.escape, replacements.keys())))
def replace_symbols_in_file(file, regex, replacements):
try:
with file.open("r", encoding="UTF-8", newline="") as rfp:
original = rfp.read()
contents = regex.sub(lambda mo: replacements[mo.string[mo.start():mo.end()]], original)
if contents != original:
with file.open("w", encoding="UTF-8", newline="") as wfp:
wfp.write(contents)
except UnicodeDecodeError:
print("%s is not text, skipping" % file)
except Exception as err:
print("%s" % err)
def replace_symbols_in_dir(path, regex, replacements):
for entry in path.glob("*"):
if entry.is_dir():
replace_symbols_in_dir(entry, regex, replacements)
else:
print("Processing %s" % entry)
replace_symbols_in_file(entry, regex, replacements)
def replace_symbols_in_path(path, regex, replacements):
if path.is_dir():
replace_symbols_in_dir(path, regex, replacements)
else:
replace_symbols_in_file(path, regex, replacements)
if __name__ == "__main__":
parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
parser.add_argument("args", nargs="*")
args = parser.parse_args()
try:
main()
except Exception as e:
print(e)
exit(-1)
exit(0)

View file

@ -0,0 +1,303 @@
#!/usr/bin/env python
import argparse
import functools
import logging
import os
from pathlib import Path
import re
import shutil
import subprocess
import tempfile
import textwrap
import urllib.request
import zipfile
# Update both variables when updating the GDK
GIT_REF = "June_2024_Update_1"
GDK_EDITION = "240601" # YYMMUU
logger = logging.getLogger(__name__)
class GdDesktopConfigurator:
def __init__(self, gdk_path, arch, vs_folder, vs_version=None, vs_toolset=None, temp_folder=None, git_ref=None, gdk_edition=None):
self.git_ref = git_ref or GIT_REF
self.gdk_edition = gdk_edition or GDK_EDITION
self.gdk_path = gdk_path
self.temp_folder = temp_folder or Path(tempfile.gettempdir())
self.dl_archive_path = Path(self.temp_folder) / f"{ self.git_ref }.zip"
self.gdk_extract_path = Path(self.temp_folder) / f"GDK-{ self.git_ref }"
self.arch = arch
self.vs_folder = vs_folder
self._vs_version = vs_version
self._vs_toolset = vs_toolset
def download_archive(self) -> None:
gdk_url = f"https://github.com/microsoft/GDK/archive/refs/tags/{ GIT_REF }.zip"
logger.info("Downloading %s to %s", gdk_url, self.dl_archive_path)
urllib.request.urlretrieve(gdk_url, self.dl_archive_path)
assert self.dl_archive_path.is_file()
def extract_zip_archive(self) -> None:
extract_path = self.gdk_extract_path.parent
assert self.dl_archive_path.is_file()
logger.info("Extracting %s to %s", self.dl_archive_path, extract_path)
with zipfile.ZipFile(self.dl_archive_path) as zf:
zf.extractall(extract_path)
assert self.gdk_extract_path.is_dir(), f"{self.gdk_extract_path} must exist"
def extract_development_kit(self) -> None:
extract_dks_cmd = self.gdk_extract_path / "SetupScripts/ExtractXboxOneDKs.cmd"
assert extract_dks_cmd.is_file()
logger.info("Extracting GDK Development Kit: running %s", extract_dks_cmd)
cmd = ["cmd.exe", "/C", str(extract_dks_cmd), str(self.gdk_extract_path), str(self.gdk_path)]
logger.debug("Running %r", cmd)
subprocess.check_call(cmd)
def detect_vs_version(self) -> str:
vs_regex = re.compile("VS([0-9]{4})")
supported_vs_versions = []
for p in self.gaming_grdk_build_path.iterdir():
if not p.is_dir():
continue
if m := vs_regex.match(p.name):
supported_vs_versions.append(m.group(1))
logger.info(f"Supported Visual Studio versions: {supported_vs_versions}")
vs_versions = set(self.vs_folder.parts).intersection(set(supported_vs_versions))
if not vs_versions:
raise RuntimeError("Visual Studio version is incompatible")
if len(vs_versions) > 1:
raise RuntimeError(f"Too many compatible VS versions found ({vs_versions})")
vs_version = vs_versions.pop()
logger.info(f"Used Visual Studio version: {vs_version}")
return vs_version
def detect_vs_toolset(self) -> str:
toolset_paths = []
for ts_path in self.gdk_toolset_parent_path.iterdir():
if not ts_path.is_dir():
continue
ms_props = ts_path / "Microsoft.Cpp.props"
if not ms_props.is_file():
continue
toolset_paths.append(ts_path.name)
logger.info("Detected Visual Studio toolsets: %s", toolset_paths)
assert toolset_paths, "Have we detected at least one toolset?"
def toolset_number(toolset: str) -> int:
if m:= re.match("[^0-9]*([0-9]+).*", toolset):
return int(m.group(1))
return -9
return max(toolset_paths, key=toolset_number)
@property
def vs_version(self) -> str:
if self._vs_version is None:
self._vs_version = self.detect_vs_version()
return self._vs_version
@property
def vs_toolset(self) -> str:
if self._vs_toolset is None:
self._vs_toolset = self.detect_vs_toolset()
return self._vs_toolset
@staticmethod
def copy_files_and_merge_into(srcdir: Path, dstdir: Path) -> None:
logger.info(f"Copy {srcdir} to {dstdir}")
for root, _, files in os.walk(srcdir):
dest_root = dstdir / Path(root).relative_to(srcdir)
if not dest_root.is_dir():
dest_root.mkdir()
for file in files:
srcfile = Path(root) / file
dstfile = dest_root / file
shutil.copy(srcfile, dstfile)
def copy_msbuild(self) -> None:
vc_toolset_parent_path = self.vs_folder / "MSBuild/Microsoft/VC"
if 1:
logger.info(f"Detected compatible Visual Studio version: {self.vs_version}")
srcdir = vc_toolset_parent_path
dstdir = self.gdk_toolset_parent_path
assert srcdir.is_dir(), "Source directory must exist"
assert dstdir.is_dir(), "Destination directory must exist"
self.copy_files_and_merge_into(srcdir=srcdir, dstdir=dstdir)
@property
def game_dk_path(self) -> Path:
return self.gdk_path / "Microsoft GDK"
@property
def game_dk_latest_path(self) -> Path:
return self.game_dk_path / self.gdk_edition
@property
def windows_sdk_path(self) -> Path:
return self.gdk_path / "Windows Kits/10"
@property
def gaming_grdk_build_path(self) -> Path:
return self.game_dk_latest_path / "GRDK"
@property
def gdk_toolset_parent_path(self) -> Path:
return self.gaming_grdk_build_path / f"VS{self.vs_version}/flatDeployment/MSBuild/Microsoft/VC"
@property
def env(self) -> dict[str, str]:
game_dk = self.game_dk_path
game_dk_latest = self.game_dk_latest_path
windows_sdk_dir = self.windows_sdk_path
gaming_grdk_build = self.gaming_grdk_build_path
return {
"GRDKEDITION": f"{self.gdk_edition}",
"GameDK": f"{game_dk}\\",
"GameDKLatest": f"{ game_dk_latest }\\",
"WindowsSdkDir": f"{ windows_sdk_dir }\\",
"GamingGRDKBuild": f"{ gaming_grdk_build }\\",
"VSInstallDir": f"{ self.vs_folder }\\",
}
def create_user_props(self, path: Path) -> None:
vc_targets_path = self.gaming_grdk_build_path / f"VS{ self.vs_version }/flatDeployment/MSBuild/Microsoft/VC/{ self.vs_toolset }"
vc_targets_path16 = self.gaming_grdk_build_path / f"VS2019/flatDeployment/MSBuild/Microsoft/VC/{ self.vs_toolset }"
vc_targets_path17 = self.gaming_grdk_build_path / f"VS2022/flatDeployment/MSBuild/Microsoft/VC/{ self.vs_toolset }"
additional_include_directories = ";".join(str(p) for p in self.gdk_include_paths)
additional_library_directories = ";".join(str(p) for p in self.gdk_library_paths)
durango_xdk_install_path = self.gdk_path / "Microsoft GDK"
with path.open("w") as f:
f.write(textwrap.dedent(f"""\
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VCTargetsPath>{ vc_targets_path }\\</VCTargetsPath>
<VCTargetsPath16>{ vc_targets_path16 }\\</VCTargetsPath16>
<VCTargetsPath17>{ vc_targets_path17 }\\</VCTargetsPath17>
<BWOI_GDK_Path>{ self.gaming_grdk_build_path }\\</BWOI_GDK_Path>
<Platform Condition="'$(Platform)' == ''">Gaming.Desktop.x64</Platform>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<XdkEditionTarget>{ self.gdk_edition }</XdkEditionTarget>
<DurangoXdkInstallPath>{ durango_xdk_install_path }</DurangoXdkInstallPath>
<DefaultXdkEditionRootVS2019>$(DurangoXdkInstallPath)\\{self.gdk_edition}\\GRDK\\VS2019\\flatDeployment\\MSBuild\\Microsoft\\VC\\{self.vs_toolset}\\Platforms\\$(Platform)\\</DefaultXdkEditionRootVS2019>
<XdkEditionRootVS2019>$(DurangoXdkInstallPath)\\{self.gdk_edition}\\GRDK\\VS2019\\flatDeployment\\MSBuild\\Microsoft\\VC\\{self.vs_toolset}\\Platforms\\$(Platform)\\</XdkEditionRootVS2019>
<DefaultXdkEditionRootVS2022>$(DurangoXdkInstallPath)\\{self.gdk_edition}\\GRDK\\VS2022\\flatDeployment\\MSBuild\\Microsoft\\VC\\{self.vs_toolset}\\Platforms\\$(Platform)\\</DefaultXdkEditionRootVS2022>
<XdkEditionRootVS2022>$(DurangoXdkInstallPath)\\{self.gdk_edition}\\GRDK\\VS2022\\flatDeployment\\MSBuild\\Microsoft\\VC\\{self.vs_toolset}\\Platforms\\$(Platform)\\</XdkEditionRootVS2022>
<Deterministic>true</Deterministic>
<DisableInstalledVCTargetsUse>true</DisableInstalledVCTargetsUse>
<ClearDevCommandPromptEnvVars>true</ClearDevCommandPromptEnvVars>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Platform)' == 'Gaming.Desktop.x64'">
<ClCompile>
<AdditionalIncludeDirectories>{ additional_include_directories };%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>{ additional_library_directories };%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
</Project>
"""))
@property
def gdk_include_paths(self) -> list[Path]:
return [
self.gaming_grdk_build_path / "gamekit/include",
]
@property
def gdk_library_paths(self) -> list[Path]:
return [
self.gaming_grdk_build_path / f"gamekit/lib/{self.arch}",
]
@property
def gdk_binary_path(self) -> list[Path]:
return [
self.gaming_grdk_build_path / "bin",
self.game_dk_path / "bin",
]
@property
def build_env(self) -> dict[str, str]:
gdk_include = ";".join(str(p) for p in self.gdk_include_paths)
gdk_lib = ";".join(str(p) for p in self.gdk_library_paths)
gdk_path = ";".join(str(p) for p in self.gdk_binary_path)
return {
"GDK_INCLUDE": gdk_include,
"GDK_LIB": gdk_lib,
"GDK_PATH": gdk_path,
}
def print_env(self) -> None:
for k, v in self.env.items():
print(f"set \"{k}={v}\"")
print()
for k, v in self.build_env.items():
print(f"set \"{k}={v}\"")
print()
print(f"set \"PATH=%GDK_PATH%;%PATH%\"")
print(f"set \"LIB=%GDK_LIB%;%LIB%\"")
print(f"set \"INCLUDE=%GDK_INCLUDE%;%INCLUDE%\"")
def main():
logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("--arch", choices=["amd64"], default="amd64", help="Architecture")
parser.add_argument("--download", action="store_true", help="Download GDK")
parser.add_argument("--extract", action="store_true", help="Extract downloaded GDK")
parser.add_argument("--copy-msbuild", action="store_true", help="Copy MSBuild files")
parser.add_argument("--temp-folder", help="Temporary folder where to download and extract GDK")
parser.add_argument("--gdk-path", required=True, type=Path, help="Folder where to store the GDK")
parser.add_argument("--ref-edition", type=str, help="Git ref and GDK edition separated by comma")
parser.add_argument("--vs-folder", required=True, type=Path, help="Installation folder of Visual Studio")
parser.add_argument("--vs-version", required=False, type=int, help="Visual Studio version")
parser.add_argument("--vs-toolset", required=False, help="Visual Studio toolset (e.g. v150)")
parser.add_argument("--props-folder", required=False, type=Path, default=Path(), help="Visual Studio toolset (e.g. v150)")
parser.add_argument("--no-user-props", required=False, dest="user_props", action="store_false", help="Don't ")
args = parser.parse_args()
logging.basicConfig(level=logging.INFO)
git_ref = None
gdk_edition = None
if args.ref_edition is not None:
git_ref, gdk_edition = args.ref_edition.split(",", 1)
try:
int(gdk_edition)
except ValueError:
parser.error("Edition should be an integer (YYMMUU) (Y=year M=month U=update)")
configurator = GdDesktopConfigurator(
arch=args.arch,
git_ref=git_ref,
gdk_edition=gdk_edition,
vs_folder=args.vs_folder,
vs_version=args.vs_version,
vs_toolset=args.vs_toolset,
gdk_path=args.gdk_path,
temp_folder=args.temp_folder,
)
if args.download:
configurator.download_archive()
if args.extract:
configurator.extract_zip_archive()
configurator.extract_development_kit()
if args.copy_msbuild:
configurator.copy_msbuild()
if args.user_props:
configurator.print_env()
configurator.create_user_props(args.props_folder / "Directory.Build.props")
if __name__ == "__main__":
raise SystemExit(main())

48
vendor/sdl-3.2.10/build-scripts/showrev.sh vendored Executable file
View file

@ -0,0 +1,48 @@
#!/bin/sh
#
# Print the current source revision, if available
SDL_ROOT=$(dirname $0)/..
cd $SDL_ROOT
if [ -e ./VERSION.txt ]; then
cat ./VERSION.txt
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_MICRO_VERSION *//p' include/SDL3/SDL_version.h)
version="${major}.${minor}.${micro}"
if [ -x "$(command -v git)" ]; then
rev="$(git describe --tags --long 2>/dev/null)"
if [ -n "$rev" ]; then
# e.g. release-2.24.0-542-g96361fc47
# or release-2.24.1-5-g36b987dab
# or prerelease-2.23.2-0-gcb46e1b3f
echo "$rev"
exit 0
fi
rev="$(git describe --always --tags --long 2>/dev/null)"
if [ -n "$rev" ]; then
# Just a truncated sha1, e.g. 96361fc47.
# Turn it into e.g. 2.25.0-g96361fc47
echo "${version}-g${rev}"
exit 0
fi
fi
if [ -x "$(command -v p4)" ]; then
rev="$(p4 changes -m1 ./...\#have 2>/dev/null| awk '{print $2}')"
if [ $? = 0 ]; then
# e.g. 2.25.0-p7511446
echo "${version}-p${rev}"
exit 0
fi
fi
# best we can do
echo "${version}-no-vcs"
exit 0

21
vendor/sdl-3.2.10/build-scripts/strip_fPIC.sh vendored Executable file
View file

@ -0,0 +1,21 @@
#!/bin/sh
#
# libtool assumes that the compiler can handle the -fPIC flag
# This isn't always true (for example, nasm can't handle it)
command=""
while [ $# -gt 0 ]; do
case "$1" in
-?PIC)
# Ignore -fPIC and -DPIC options
;;
-fno-common)
# Ignore -fPIC and -DPIC options
;;
*)
command="$command $1"
;;
esac
shift
done
echo $command
exec $command

View file

@ -0,0 +1,170 @@
#!/bin/sh
# Copyright 2022 Collabora Ltd.
# SPDX-License-Identifier: Zlib
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_MICRO_VERSION *//p' include/SDL3/SDL_version.h)
ref_version="${ref_major}.${ref_minor}.${ref_micro}"
tests=0
failed=0
ok () {
tests=$(( tests + 1 ))
echo "ok - $*"
}
not_ok () {
tests=$(( tests + 1 ))
echo "not ok - $*"
failed=1
}
version=$(sed -Ene 's/^.* version ([0-9.]*)$/\1/p' include/SDL3/SDL.h)
if [ "$ref_version" = "$version" ]; then
ok "SDL.h $version"
else
not_ok "SDL.h $version disagrees with SDL_version.h $ref_version"
fi
version=$(sed -Ene 's/^project\(SDL[0-9]+ LANGUAGES C VERSION "([0-9.]*)"\)$/\1/p' CMakeLists.txt)
if [ "$ref_version" = "$version" ]; then
ok "CMakeLists.txt $version"
else
not_ok "CMakeLists.txt $version disagrees with SDL_version.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)
minor=$(sed -ne 's/.*SDL_MINOR_VERSION = \([0-9]*\);/\1/p' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java)
micro=$(sed -ne 's/.*SDL_MICRO_VERSION = \([0-9]*\);/\1/p' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java)
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"
fi
tuple=$(sed -ne 's/^ *FILEVERSION *//p' src/core/windows/version.rc | tr -d '\r')
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"
fi
tuple=$(sed -ne 's/^ *PRODUCTVERSION *//p' src/core/windows/version.rc | tr -d '\r')
if [ "$ref_tuple" = "$tuple" ]; then
ok "version.rc PRODUCTVERSION $tuple"
else
not_ok "version.rc PRODUCTVERSION $tuple disagrees with SDL_version.h $ref_tuple"
fi
tuple=$(sed -Ene 's/^ *VALUE "FileVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/core/windows/version.rc | tr -d '\r')
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"
fi
tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/core/windows/version.rc | tr -d '\r')
if [ "$ref_tuple" = "$tuple" ]; then
ok "version.rc ProductVersion $tuple"
else
not_ok "version.rc ProductVersion $tuple disagrees with SDL_version.h $ref_tuple"
fi
version=$(sed -Ene '/CFBundleShortVersionString/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist)
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"
fi
version=$(sed -Ene '/CFBundleVersion/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist)
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"
fi
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"
fi
marketing=$(sed -Ene 's/.*MARKETING_VERSION = (.*);/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
ref="$ref_version
$ref_version"
if [ "$ref" = "$marketing" ]; then
ok "project.pbxproj MARKETING_VERSION is consistent"
else
not_ok "project.pbxproj MARKETING_VERSION is inconsistent, expected $ref, got $marketing"
fi
# For simplicity this assumes we'll never break ABI before SDL 3.
dylib_compat=$(sed -Ene 's/.*DYLIB_COMPATIBILITY_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
case "$ref_minor" in
(*[02468])
major="$(( ref_minor * 100 + 1 ))"
minor="0"
;;
(*)
major="$(( ref_minor * 100 + ref_micro + 1 ))"
minor="0"
;;
esac
ref="${major}.${minor}.0
${major}.${minor}.0"
if [ "$ref" = "$dylib_compat" ]; then
ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is consistent"
else
not_ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is inconsistent, expected $ref, got $dylib_compat"
fi
dylib_cur=$(sed -Ene 's/.*DYLIB_CURRENT_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
case "$ref_minor" in
(*[02468])
major="$(( ref_minor * 100 + 1 ))"
minor="$ref_micro"
;;
(*)
major="$(( ref_minor * 100 + ref_micro + 1 ))"
minor="0"
;;
esac
ref="${major}.${minor}.0
${major}.${minor}.0"
if [ "$ref" = "$dylib_cur" ]; then
ok "project.pbxproj DYLIB_CURRENT_VERSION is consistent"
else
not_ok "project.pbxproj DYLIB_CURRENT_VERSION is inconsistent, expected $ref, got $dylib_cur"
fi
echo "1..$tests"
exit "$failed"

View file

@ -0,0 +1,15 @@
#!/bin/sh
if [ "$SED" = "" ]; then
if type gsed >/dev/null; then
SED=gsed
else
SED=sed
fi
fi
find . -type f \
| grep -v \.git \
| while read file; do \
LC_ALL=C $SED -b -i "s/\(.*Copyright.*\)[0-9]\{4\}\( *Sam Lantinga\)/\1`date +%Y`\2/" "$file"; \
done

View file

@ -0,0 +1,81 @@
#!/bin/sh
#set -x
cd `dirname $0`/..
ARGSOKAY=1
if [ -z $1 ]; then
ARGSOKAY=0
fi
if [ -z $2 ]; then
ARGSOKAY=0
fi
if [ -z $3 ]; then
ARGSOKAY=0
fi
if [ "x$ARGSOKAY" = "x0" ]; then
echo "USAGE: $0 <major> <minor> <patch>" 1>&2
exit 1
fi
MAJOR="$1"
MINOR="$2"
MICRO="$3"
NEWVERSION="$MAJOR.$MINOR.$MICRO"
echo "Updating version to '$NEWVERSION' ..."
perl -w -pi -e 's/\A(.* version )[0-9.]+/${1}'$NEWVERSION'/;' include/SDL3/SDL.h
# !!! FIXME: This first one is a kinda scary search/replace that might fail later if another X.Y.Z version is added to the file.
perl -w -pi -e 's/(\<string\>)\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/Info-Framework.plist
perl -w -pi -e 's/(Title SDL )\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/pkg-support/SDL.info
perl -w -pi -e 's/(MARKETING_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
DYVER=`expr $MINOR \* 100 + 1`
perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
# Set compat to major.minor.0 by default.
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$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'.'$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 + $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
fi
perl -w -pi -e 's/\A(project\(SDL[0-9]+ LANGUAGES C VERSION ")[0-9.]+/${1}'$NEWVERSION'/;' CMakeLists.txt
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}'$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_MICRO_VERSION\s+)\d+/${1}'$MICRO'/;' include/SDL3/SDL_version.h
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
echo "All done."
echo "Run 'git diff' and make sure this looks correct, before 'git commit'."
exit 0

48
vendor/sdl-3.2.10/build-scripts/updaterev.sh vendored Executable file
View file

@ -0,0 +1,48 @@
#!/bin/sh
#
# Generate a header file with the current source revision
outdir=`pwd`
cd `dirname $0`
srcdir=..
header=$outdir/include/SDL3/SDL_revision.h
dist=
vendor=
while [ "$#" -gt 0 ]; do
case "$1" in
(--dist)
dist=yes
shift
;;
(--vendor)
vendor="$2"
shift 2
;;
(*)
echo "$0: Unknown option: $1" >&2
exit 2
;;
esac
done
rev=`sh showrev.sh 2>/dev/null`
if [ "$rev" != "" ]; then
if [ -n "$dist" ]; then
echo "$rev" > "$outdir/VERSION.txt"
fi
echo "/* Generated by updaterev.sh, do not edit */" >"$header.new"
if [ -n "$vendor" ]; then
echo "#define SDL_VENDOR_INFO \"$vendor\"" >>"$header.new"
fi
echo "#ifdef SDL_VENDOR_INFO" >>"$header.new"
echo "#define SDL_REVISION \"SDL-$rev (\" SDL_VENDOR_INFO \")\"" >>"$header.new"
echo "#else" >>"$header.new"
echo "#define SDL_REVISION \"SDL-$rev\"" >>"$header.new"
echo "#endif" >>"$header.new"
if diff $header $header.new >/dev/null 2>&1; then
rm "$header.new"
else
mv "$header.new" "$header"
fi
fi

3360
vendor/sdl-3.2.10/build-scripts/wikiheaders.pl vendored Executable file

File diff suppressed because it is too large Load diff