early-access version 2281

This commit is contained in:
pineappleEA
2021-12-07 02:20:09 +01:00
parent c2ae6d480a
commit c4fa174d53
591 changed files with 36978 additions and 18653 deletions

View File

@@ -27,7 +27,7 @@ cd checker-buildbot
# The -Wno-liblto is new since our checker-279 upgrade, I think; checker otherwise warns "libLTO.dylib relative to clang installed dir not found"
# You might want to do this for CMake-backed builds instead...
scan-build -o analysis cmake -G Ninja -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_SHARED_LINKER_FLAGS="-Wno-liblto" ..
scan-build -o analysis cmake -G Ninja -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DSDL_ASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_SHARED_LINKER_FLAGS="-Wno-liblto" ..
# ...or run configure without the scan-build wrapper...
#CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0 -Wno-deprecated-declarations" LDFLAGS="-Wno-liblto" ../configure --enable-assertions=enabled

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

@@ -4,7 +4,7 @@
# shellcheck disable=SC2006,SC2268 # see below for rationale
timestamp='2021-07-03'
timestamp='2021-08-14'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -121,9 +121,11 @@ esac
# Split fields of configuration type
# shellcheck disable=SC2162
saved_IFS=$IFS
IFS="-" read field1 field2 field3 field4 <<EOF
$1
EOF
IFS=$saved_IFS
# Separate into logical components for further validation
case $1 in
@@ -172,6 +174,10 @@ case $1 in
basic_machine=$field1
basic_os=$field2
;;
zephyr*)
basic_machine=$field1-unknown
basic_os=$field2
;;
# Manufacturers
dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
@@ -931,9 +937,11 @@ case $basic_machine in
*-*)
# shellcheck disable=SC2162
saved_IFS=$IFS
IFS="-" read cpu vendor <<EOF
$basic_machine
EOF
IFS=$saved_IFS
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
@@ -1313,9 +1321,11 @@ case $basic_os in
;;
*-*)
# shellcheck disable=SC2162
saved_IFS=$IFS
IFS="-" read kernel os <<EOF
$basic_os
EOF
IFS=$saved_IFS
;;
# Default OS when just kernel was specified
nto*)
@@ -1697,7 +1707,7 @@ fi
# Now, validate our (potentially fixed-up) OS.
case $os in
# Sometimes we do "kernel-libc", so those need to count as OSes.
musl* | newlib* | uclibc*)
musl* | newlib* | relibc* | uclibc*)
;;
# Likewise for "kernel-abi"
eabi* | gnueabi*)
@@ -1738,7 +1748,7 @@ case $os in
| skyos* | haiku* | rdos* | toppers* | drops* | es* \
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*)
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr*)
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
@@ -1755,11 +1765,12 @@ esac
# As a final step for OS-related things, validate the OS-kernel combination
# (given a valid OS), if there is a kernel.
case $kernel-$os in
linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* )
linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
| linux-musl* | linux-relibc* | linux-uclibc* )
;;
uclinux-uclibc* )
;;
-dietlibc* | -newlib* | -musl* | -uclibc* )
-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
# These are just libc implementations, not actual OSes, and thus
# require a kernel.
echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2

174
externals/SDL/build-scripts/fnsince.pl vendored Executable file
View File

@@ -0,0 +1,174 @@
#!/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 @unsorted_releases = ();
open(PIPEFH, '-|', 'git tag -l') or die "Failed to read git release tags: $!\n";
while (<PIPEFH>) {
chomp;
if (/\Arelease\-(.*?)\Z/) {
push @unsorted_releases, $1;
}
}
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;
# this happens to work for how SDL versions things at the moment.
my $current_release = $releases[-1];
my @current_release_segments = split /\./, $current_release;
@current_release_segments[2] = '' . ($current_release_segments[2] + 2);
my $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';
my %funcs = ();
foreach my $release (@releases) {
#print("Checking $release...\n");
next if ($release eq '2.0.0') || ($release eq '2.0.1'); # no dynapi before 2.0.2
my $assigned_release = ($release eq '2.0.2') ? '2.0.0' : $release; # assume everything in 2.0.2--first with dynapi--was there since 2.0.0. We'll fix it up later.
my $tag = ($release eq 'HEAD') ? $release : "release-$release";
my $blobname = "$tag:src/dynapi/SDL_dynapi_overrides.h";
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} = $assigned_release if not defined $funcs{$fn};
}
}
close(PIPEFH);
}
# Fixup the handful of functions that were added in 2.0.1 and 2.0.2 that we
# didn't have dynapi revision data about...
$funcs{'SDL_GetSystemRAM'} = '2.0.1';
$funcs{'SDL_GetBasePath'} = '2.0.1';
$funcs{'SDL_GetPrefPath'} = '2.0.1';
$funcs{'SDL_UpdateYUVTexture'} = '2.0.1';
$funcs{'SDL_GL_GetDrawableSize'} = '2.0.1';
$funcs{'SDL_Direct3D9GetAdapterIndex'} = '2.0.1';
$funcs{'SDL_RenderGetD3D9Device'} = '2.0.1';
$funcs{'SDL_RegisterApp'} = '2.0.2';
$funcs{'SDL_UnregisterApp'} = '2.0.2';
$funcs{'SDL_GetAssertionHandler'} = '2.0.2';
$funcs{'SDL_GetDefaultAssertionHandler'} = '2.0.2';
$funcs{'SDL_AtomicAdd'} = '2.0.2';
$funcs{'SDL_AtomicGet'} = '2.0.2';
$funcs{'SDL_AtomicGetPtr'} = '2.0.2';
$funcs{'SDL_AtomicSet'} = '2.0.2';
$funcs{'SDL_AtomicSetPtr'} = '2.0.2';
$funcs{'SDL_HasAVX'} = '2.0.2';
$funcs{'SDL_GameControllerAddMappingsFromRW'} = '2.0.2';
$funcs{'SDL_acos'} = '2.0.2';
$funcs{'SDL_asin'} = '2.0.2';
$funcs{'SDL_vsscanf'} = '2.0.2';
$funcs{'SDL_DetachThread'} = '2.0.2';
$funcs{'SDL_GL_ResetAttributes'} = '2.0.2';
$funcs{'SDL_DXGIGetOutputInfo'} = '2.0.2';
# these are incorrect in the dynapi header, because we forgot to add them
# until a later release, but are available in the older release.
$funcs{'SDL_WinRTGetFSPathUNICODE'} = '2.0.3';
$funcs{'SDL_WinRTGetFSPathUTF8'} = '2.0.3';
$funcs{'SDL_WinRTRunApp'} = '2.0.3';
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) {
my $revision = $funcs{$fn};
$revision = $next_release if $revision eq 'HEAD';
my $fname = "$fn.mediawiki";
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\s+\=\=/;
$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

@@ -136,14 +136,21 @@ sub wikify_chunk {
#print("\n\nWIKIFY CHUNK:\n\n$str\n\n\n");
if ($wikitype eq 'mediawiki') {
# convert `code` things first, so they aren't mistaken for other markdown items.
my $codedstr = '';
while ($str =~ s/\A(.*?)\`(.*?)\`//ms) {
my $codeblock = $2;
$codedstr .= wikify_chunk($wikitype, $1, undef, undef);
# Convert obvious SDL things to wikilinks, even inside `code` blocks.
$codeblock =~ s/\b(SDL_[a-zA-Z0-9_]+)/[[$1]]/gms;
$codedstr .= "<code>$codeblock</code>";
}
# Convert obvious SDL things to wikilinks.
$str =~ s/\b(SDL_[a-zA-Z0-9_]+)/[[$1]]/gms;
# Make some Markdown things into MediaWiki...
# <code></code> is also popular. :/
$str =~ s/\`(.*?)\`/<code>$1<\/code>/gms;
# bold+italic
$str =~ s/\*\*\*(.*?)\*\*\*/'''''$1'''''/gms;
@@ -156,6 +163,8 @@ sub wikify_chunk {
# bullets
$str =~ s/^\- /* /gm;
$str = $codedstr . $str;
if (defined $code) {
$str .= "<syntaxhighlight lang='$codelang'>$code<\/syntaxhighlight>";
}
@@ -261,6 +270,7 @@ usage() if not defined $wikipath;
my @standard_wiki_sections = (
'Draft',
'[Brief]',
'Deprecated',
'Syntax',
'Function Parameters',
'Return Value',
@@ -283,6 +293,7 @@ my %headerfuncs = (); # $headerfuncs{"SDL_OpenAudio"} -> string of header docu
my %headerdecls = ();
my %headerfuncslocation = (); # $headerfuncslocation{"SDL_OpenAudio"} -> name of header holding SDL_OpenAudio define ("SDL_audio.h" in this case).
my %headerfuncschunk = (); # $headerfuncschunk{"SDL_OpenAudio"} -> offset in array in %headers that should be replaced for this function.
my %headerfuncshasdoxygen = (); # $headerfuncschunk{"SDL_OpenAudio"} -> 1 if there was no existing doxygen for this function.
my $incpath = "$srcpath/include";
opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n");
@@ -295,46 +306,54 @@ while (readdir(DH)) {
while (<FH>) {
chomp;
if (not /\A\/\*\*\s*\Z/) { # not doxygen comment start?
my $decl;
my @templines;
my $str;
my $has_doxygen = 1;
if (/\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC/) { # a function declaration without a doxygen comment?
@templines = ();
$decl = $_;
$str = '';
$has_doxygen = 0;
} elsif (not /\A\/\*\*\s*\Z/) { # not doxygen comment start?
push @contents, $_;
next;
}
my @templines = ();
push @templines, $_;
my $str = '';
while (<FH>) {
chomp;
push @templines, $_;
last if /\A\s*\*\/\Z/;
if (s/\A\s*\*\s*\`\`\`/```/) { # this is a hack, but a lot of other code relies on the whitespace being trimmed, but we can't trim it in code blocks...
$str .= "$_\n";
while (<FH>) {
chomp;
push @templines, $_;
s/\A\s*\*\s?//;
if (s/\A\s*\`\`\`/```/) {
$str .= "$_\n";
last;
} else {
$str .= "$_\n";
} else { # Start of a doxygen comment, parse it out.
@templines = ( $_ );
while (<FH>) {
chomp;
push @templines, $_;
last if /\A\s*\*\/\Z/;
if (s/\A\s*\*\s*\`\`\`/```/) { # this is a hack, but a lot of other code relies on the whitespace being trimmed, but we can't trim it in code blocks...
$str .= "$_\n";
while (<FH>) {
chomp;
push @templines, $_;
s/\A\s*\*\s?//;
if (s/\A\s*\`\`\`/```/) {
$str .= "$_\n";
last;
} else {
$str .= "$_\n";
}
}
} else {
s/\A\s*\*\s*//;
$str .= "$_\n";
}
} else {
s/\A\s*\*\s*//;
$str .= "$_\n";
}
}
my $decl = <FH>;
chomp($decl);
if (not $decl =~ /\A\s*extern\s+DECLSPEC/) {
#print "Found doxygen but no function sig:\n$str\n\n";
foreach (@templines) {
push @contents, $_;
$decl = <FH>;
$decl = '' if not defined $decl;
chomp($decl);
if (not $decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC/) {
#print "Found doxygen but no function sig:\n$str\n\n";
foreach (@templines) {
push @contents, $_;
}
push @contents, $decl;
next;
}
push @contents, $decl;
next;
}
my @decllines = ( $decl );
@@ -355,8 +374,8 @@ while (readdir(DH)) {
#print("DECL: [$decl]\n");
my $fn = '';
if ($decl =~ /\A\s*extern\s+DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
$fn = $5;
if ($decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
$fn = $6;
#$decl =~ s/\A\s*extern\s+DECLSPEC\s+(.*?)\s+SDLCALL/$1/;
} else {
#print "Found doxygen but no function sig:\n$str\n\n";
@@ -373,9 +392,10 @@ while (readdir(DH)) {
foreach (@decllines) {
if ($decl eq '') {
$decl = $_;
$decl =~ s/\Aextern\s+DECLSPEC\s+(.*?)\s+(\*?)SDLCALL\s+/$1$2 /;
$decl =~ s/\Aextern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(.*?)\s+(\*?)SDLCALL\s+/$2$3 /;
} else {
my $trimmed = $_;
# !!! FIXME: trim space for SDL_DEPRECATED if it was used, too.
$trimmed =~ s/\A\s{24}//; # 24 for shrinking to match the removed "extern DECLSPEC SDLCALL "
$decl .= $trimmed;
}
@@ -384,13 +404,33 @@ while (readdir(DH)) {
#print("$fn:\n$str\n\n");
$headerfuncs{$fn} = $str;
$headerdecls{$fn} = $decl;
$headerfuncslocation{$fn} = $dent;
$headerfuncschunk{$fn} = scalar(@contents);
# There might be multiple declarations of a function due to #ifdefs,
# and only one of them will have documentation. If we hit an
# undocumented one before, delete the placeholder line we left for
# it so it doesn't accumulate a new blank line on each run.
my $skipfn = 0;
if (defined $headerfuncshasdoxygen{$fn}) {
if ($headerfuncshasdoxygen{$fn} == 0) { # An undocumented declaration already exists, nuke its placeholder line.
delete $contents[$headerfuncschunk{$fn}]; # delete DOES NOT RENUMBER existing elements!
} else { # documented function already existed?
$skipfn = 1; # don't add this copy to the list of functions.
if ($has_doxygen) {
print STDERR "WARNING: Function '$fn' appears to be documented in multiple locations. Only keeping the first one we saw!\n";
}
push @contents, join("\n", @decllines); # just put the existing declation in as-is.
}
}
if (!$skipfn) {
$headerfuncs{$fn} = $str;
$headerdecls{$fn} = $decl;
$headerfuncslocation{$fn} = $dent;
$headerfuncschunk{$fn} = scalar(@contents);
$headerfuncshasdoxygen{$fn} = $has_doxygen;
push @contents, join("\n", @templines);
push @contents, join("\n", @decllines);
}
push @contents, join("\n", @templines);
push @contents, join("\n", @decllines);
}
close(FH);
@@ -513,7 +553,6 @@ if ($copy_direction == 1) { # --copy-to-headers
$wordwrap_mode = 'md'; # the headers use Markdown format.
# if it's not in the headers already, we don't add it, so iterate what we know is already there for changes.
foreach (keys %headerfuncs) {
my $fn = $_;
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
@@ -524,10 +563,13 @@ if ($copy_direction == 1) { # --copy-to-headers
my $returns = %$sectionsref{'Return Value'};
my $version = %$sectionsref{'Version'};
my $related = %$sectionsref{'Related Functions'};
my $deprecated = %$sectionsref{'Deprecated'};
my $brief = %$sectionsref{'[Brief]'};
my $addblank = 0;
my $str = '';
$headerfuncshasdoxygen{$fn} = 1; # Added/changed doxygen for this header.
$brief = dewikify($wikitype, $brief);
$brief =~ s/\A(.*?\.) /$1\n/; # \brief should only be one sentence, delimited by a period+space. Split if necessary.
my @briefsplit = split /\n/, $brief;
@@ -547,6 +589,21 @@ if ($copy_direction == 1) { # --copy-to-headers
$str .= wordwrap($remarks) . "\n";
}
if (defined $deprecated) {
# !!! FIXME: lots of code duplication in all of these.
$str .= "\n" if $addblank; $addblank = 1;
my $v = dewikify($wikitype, $deprecated);
my $whitespacelen = length("\\deprecated") + 1;
my $whitespace = ' ' x $whitespacelen;
$v = wordwrap($v, -$whitespacelen);
my @desclines = split /\n/, $v;
my $firstline = shift @desclines;
$str .= "\\deprecated $firstline\n";
foreach (@desclines) {
$str .= "${whitespace}$_\n";
}
}
if (defined $params) {
$str .= "\n" if $addblank; $addblank = (defined $returns) ? 0 : 1;
my @lines = split /\n/, dewikify($wikitype, $params);
@@ -623,8 +680,15 @@ if ($copy_direction == 1) { # --copy-to-headers
}
}
my $header = $headerfuncslocation{$fn};
my $contentsref = $headers{$header};
my $chunk = $headerfuncschunk{$fn};
my @lines = split /\n/, $str;
my $output = "/**\n";
my $addnewline = (($chunk > 0) && ($$contentsref[$chunk-1] ne '')) ? "\n" : '';
my $output = "$addnewline/**\n";
foreach (@lines) {
chomp;
s/\s*\Z//;
@@ -638,9 +702,6 @@ if ($copy_direction == 1) { # --copy-to-headers
#print("$fn:\n$output\n\n");
my $header = $headerfuncslocation{$fn};
my $chunk = $headerfuncschunk{$fn};
my $contentsref = $headers{$header};
$$contentsref[$chunk] = $output;
#$$contentsref[$chunk+1] = $headerdecls{$fn};
@@ -648,19 +709,36 @@ if ($copy_direction == 1) { # --copy-to-headers
}
foreach (keys %changed_headers) {
my $contentsref = $headers{$_};
my $path = "$incpath/$_.tmp";
my $header = $_;
# this is kinda inefficient, but oh well.
my @removelines = ();
foreach (keys %headerfuncslocation) {
my $fn = $_;
next if $headerfuncshasdoxygen{$fn};
next if $headerfuncslocation{$fn} ne $header;
# the index of the blank line we put before the function declaration in case we needed to replace it with new content from the wiki.
push @removelines, $headerfuncschunk{$fn};
}
my $contentsref = $headers{$header};
foreach (@removelines) {
delete $$contentsref[$_]; # delete DOES NOT RENUMBER existing elements!
}
my $path = "$incpath/$header.tmp";
open(FH, '>', $path) or die("Can't open '$path': $!\n");
foreach (@$contentsref) {
print FH "$_\n";
print FH "$_\n" if defined $_;
}
close(FH);
rename($path, "$incpath/$_") or die("Can't rename '$path' to '$incpath/$_': $!\n");
rename($path, "$incpath/$header") or die("Can't rename '$path' to '$incpath/$header': $!\n");
}
} elsif ($copy_direction == -1) { # --copy-to-wiki
foreach (keys %headerfuncs) {
my $fn = $_;
next if not $headerfuncshasdoxygen{$fn};
my $wikitype = defined $wikitypes{$fn} ? $wikitypes{$fn} : 'mediawiki'; # default to MediaWiki for new stuff FOR NOW.
die("Unexpected wikitype '$wikitype'\n") if (($wikitype ne 'mediawiki') and ($wikitype ne 'md'));
@@ -669,6 +747,7 @@ if ($copy_direction == 1) { # --copy-to-headers
$wordwrap_mode = $wikitype;
my $raw = $headerfuncs{$fn}; # raw doxygen text with comment characters stripped from start/end and start of each line.
next if not defined $raw;
$raw =~ s/\A\s*\\brief\s+//; # Technically we don't need \brief (please turn on JAVADOC_AUTOBRIEF if you use Doxygen), so just in case one is present, strip it.
my @doxygenlines = split /\n/, $raw;
@@ -714,7 +793,7 @@ if ($copy_direction == 1) { # --copy-to-headers
my $decl = $headerdecls{$fn};
#$decl =~ s/\*\s+SDLCALL/ *SDLCALL/; # Try to make "void * Function" become "void *Function"
#$decl =~ s/\A\s*extern\s+DECLSPEC\s+(.*?)\s+(\*?)SDLCALL/$1$2/;
#$decl =~ s/\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(.*?)\s+(\*?)SDLCALL/$2$3/;
my $syntax = '';
if ($wikitype eq 'mediawiki') {
@@ -768,6 +847,21 @@ if ($copy_direction == 1) { # --copy-to-headers
}
$desc =~ s/[\s\n]+\Z//ms;
$sections{'Return Value'} = wordwrap("$retstr " . wikify($wikitype, $desc)) . "\n";
} elsif ($l =~ /\A\\deprecated\s+(.*)\Z/) {
my $desc = $1;
while (@doxygenlines) {
my $subline = $doxygenlines[0];
$subline =~ s/\A\s*//;
last if $subline =~ /\A\\/; # some sort of doxygen command, assume we're past this thing.
shift @doxygenlines; # dump this line from the array; we're using it.
if ($subline eq '') { # empty line, make sure it keeps the newline char.
$desc .= "\n";
} else {
$desc .= " $subline";
}
}
$desc =~ s/[\s\n]+\Z//ms;
$sections{'Deprecated'} = wordwrap(wikify($wikitype, $desc)) . "\n";
} elsif ($l =~ /\A\\since\s+(.*)\Z/) {
my $desc = $1;
while (@doxygenlines) {
@@ -854,30 +948,57 @@ if ($copy_direction == 1) { # --copy-to-headers
}
my $wikisectionorderref = $wikisectionorder{$fn};
my @ordered_sections = (@standard_wiki_sections, defined $wikisectionorderref ? @$wikisectionorderref : ()); # this copies the arrays into one.
# Make sure there's a footer in the wiki that puts this function in CategoryAPI...
if (not $$sectionsref{'[footer]'}) {
$$sectionsref{'[footer]'} = '';
push @$wikisectionorderref, '[footer]';
}
# !!! FIXME: This won't be CategoryAPI if we eventually handle things other than functions.
my $footer = $$sectionsref{'[footer]'};
if ($wikitype eq 'mediawiki') {
$footer =~ s/\[\[CategoryAPI\]\],?\s*//g;
$footer = '[[CategoryAPI]]' . (($footer eq '') ? "\n" : ", $footer");
} elsif ($wikitype eq 'md') {
$footer =~ s/\[CategoryAPI\]\(CategoryAPI\),?\s*//g;
$footer = '[CategoryAPI](CategoryAPI)' . (($footer eq '') ? '' : ', ') . $footer;
} else { die("Unexpected wikitype '$wikitype'\n"); }
$$sectionsref{'[footer]'} = $footer;
my $prevsectstr = '';
my @ordered_sections = (@standard_wiki_sections, defined $wikisectionorderref ? @$wikisectionorderref : ()); # this copies the arrays into one.
foreach (@ordered_sections) {
my $sect = $_;
next if $sect eq '[start]';
next if (not defined $sections{$sect} and not defined $$sectionsref{$sect});
my $section = defined $sections{$sect} ? $sections{$sect} : $$sectionsref{$sect};
if ($sect eq '[footer]') {
# Make sure previous section ends with two newlines.
if (substr($prevsectstr, -1) ne "\n") {
print FH "\n\n";
} elsif (substr($prevsectstr, -2) ne "\n\n") {
print FH "\n";
}
print FH "----\n"; # It's the same in Markdown and MediaWiki.
} elsif ($sect eq '[Brief]') {
if ($wikitype eq 'mediawiki') {
print FH "= $fn =\n\n";
} elsif ($wikitype eq 'md') {
print FH "# $fn\n\n";
} else { die("Expected wikitype '$wikitype'\n"); }
} else { die("Unexpected wikitype '$wikitype'\n"); }
} else {
if ($wikitype eq 'mediawiki') {
print FH "\n== $sect ==\n\n";
} elsif ($wikitype eq 'md') {
print FH "\n## $sect\n\n";
} else { die("Expected wikitype '$wikitype'\n"); }
} else { die("Unexpected wikitype '$wikitype'\n"); }
}
print FH defined $sections{$sect} ? $sections{$sect} : $$sectionsref{$sect};
my $sectstr = defined $sections{$sect} ? $sections{$sect} : $$sectionsref{$sect};
print FH $sectstr;
$prevsectstr = $sectstr;
# make sure these don't show up twice.
delete($sections{$sect});

View File

@@ -39,7 +39,7 @@
#
# Base version of SDL, used for packaging purposes
$SDLVersion = "2.0.16"
$SDLVersion = "2.0.18"
# Gets the .bat file that sets up an MSBuild environment, given one of
# Visual Studio's, "PlatformToolset"s.