fnsince.pl 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #!/usr/bin/perl -w
  2. use warnings;
  3. use strict;
  4. use File::Basename;
  5. use Cwd qw(abs_path);
  6. my $wikipath = undef;
  7. foreach (@ARGV) {
  8. $wikipath = abs_path($_), next if not defined $wikipath;
  9. }
  10. chdir(dirname(__FILE__));
  11. chdir('..');
  12. my @unsorted_releases = ();
  13. open(PIPEFH, '-|', 'git tag -l') or die "Failed to read git release tags: $!\n";
  14. while (<PIPEFH>) {
  15. chomp;
  16. if (/\Arelease\-(.*?)\Z/) {
  17. # After 2.24.x, ignore anything that isn't a x.y.0 release.
  18. # We moved to bugfix-only point releases there, so make sure new APIs
  19. # are assigned to the next minor version and ignore the patch versions.
  20. my $ver = $1;
  21. my @versplit = split /\./, $ver;
  22. next if (scalar(@versplit) > 2) && (($versplit[0] > 2) || (($versplit[0] == 2) && ($versplit[1] >= 24))) && ($versplit[2] != 0);
  23. # Consider this release version.
  24. push @unsorted_releases, $ver;
  25. }
  26. }
  27. close(PIPEFH);
  28. #print("\n\nUNSORTED\n");
  29. #foreach (@unsorted_releases) {
  30. # print "$_\n";
  31. #}
  32. my @releases = sort {
  33. my @asplit = split /\./, $a;
  34. my @bsplit = split /\./, $b;
  35. my $rc;
  36. for (my $i = 0; $i < scalar(@asplit); $i++) {
  37. return 1 if (scalar(@bsplit) <= $i); # a is "2.0.1" and b is "2.0", or whatever.
  38. my $aseg = $asplit[$i];
  39. my $bseg = $bsplit[$i];
  40. $rc = int($aseg) <=> int($bseg);
  41. return $rc if ($rc != 0); # found the difference.
  42. }
  43. return 0; # still here? They matched completely?!
  44. } @unsorted_releases;
  45. # this happens to work for how SDL versions things at the moment.
  46. my $current_release = $releases[-1];
  47. my $next_release;
  48. if ($current_release eq '2.0.22') { # Hack for our jump from 2.0.22 to 2.24.0...
  49. $next_release = '2.24.0';
  50. } else {
  51. my @current_release_segments = split /\./, $current_release;
  52. @current_release_segments[1] = '' . ($current_release_segments[1] + 2);
  53. $next_release = join('.', @current_release_segments);
  54. }
  55. #print("\n\nSORTED\n");
  56. #foreach (@releases) {
  57. # print "$_\n";
  58. #}
  59. #print("\nCURRENT RELEASE: $current_release\n");
  60. #print("NEXT RELEASE: $next_release\n\n");
  61. push @releases, 'HEAD';
  62. my %funcs = ();
  63. foreach my $release (@releases) {
  64. #print("Checking $release...\n");
  65. next if ($release eq '2.0.0') || ($release eq '2.0.1'); # no dynapi before 2.0.2
  66. 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.
  67. my $tag = ($release eq 'HEAD') ? $release : "release-$release";
  68. my $blobname = "$tag:src/dynapi/SDL_dynapi_overrides.h";
  69. open(PIPEFH, '-|', "git show '$blobname'") or die "Failed to read git blob '$blobname': $!\n";
  70. while (<PIPEFH>) {
  71. chomp;
  72. if (/\A\#define\s+(SDL_.*?)\s+SDL_.*?_REAL\Z/) {
  73. my $fn = $1;
  74. $funcs{$fn} = $assigned_release if not defined $funcs{$fn};
  75. }
  76. }
  77. close(PIPEFH);
  78. }
  79. # Fixup the handful of functions that were added in 2.0.1 and 2.0.2 that we
  80. # didn't have dynapi revision data about...
  81. $funcs{'SDL_GetSystemRAM'} = '2.0.1';
  82. $funcs{'SDL_GetBasePath'} = '2.0.1';
  83. $funcs{'SDL_GetPrefPath'} = '2.0.1';
  84. $funcs{'SDL_UpdateYUVTexture'} = '2.0.1';
  85. $funcs{'SDL_GL_GetDrawableSize'} = '2.0.1';
  86. $funcs{'SDL_Direct3D9GetAdapterIndex'} = '2.0.1';
  87. $funcs{'SDL_RenderGetD3D9Device'} = '2.0.1';
  88. $funcs{'SDL_RegisterApp'} = '2.0.2';
  89. $funcs{'SDL_UnregisterApp'} = '2.0.2';
  90. $funcs{'SDL_GetAssertionHandler'} = '2.0.2';
  91. $funcs{'SDL_GetDefaultAssertionHandler'} = '2.0.2';
  92. $funcs{'SDL_AtomicAdd'} = '2.0.2';
  93. $funcs{'SDL_AtomicGet'} = '2.0.2';
  94. $funcs{'SDL_AtomicGetPtr'} = '2.0.2';
  95. $funcs{'SDL_AtomicSet'} = '2.0.2';
  96. $funcs{'SDL_AtomicSetPtr'} = '2.0.2';
  97. $funcs{'SDL_HasAVX'} = '2.0.2';
  98. $funcs{'SDL_GameControllerAddMappingsFromRW'} = '2.0.2';
  99. $funcs{'SDL_acos'} = '2.0.2';
  100. $funcs{'SDL_asin'} = '2.0.2';
  101. $funcs{'SDL_vsscanf'} = '2.0.2';
  102. $funcs{'SDL_DetachThread'} = '2.0.2';
  103. $funcs{'SDL_GL_ResetAttributes'} = '2.0.2';
  104. $funcs{'SDL_DXGIGetOutputInfo'} = '2.0.2';
  105. # these are incorrect in the dynapi header, because we forgot to add them
  106. # until a later release, but are available in the older release.
  107. $funcs{'SDL_WinRTGetFSPathUNICODE'} = '2.0.3';
  108. $funcs{'SDL_WinRTGetFSPathUTF8'} = '2.0.3';
  109. $funcs{'SDL_WinRTRunApp'} = '2.0.3';
  110. if (not defined $wikipath) {
  111. foreach my $release (@releases) {
  112. foreach my $fn (sort keys %funcs) {
  113. print("$fn: $funcs{$fn}\n") if $funcs{$fn} eq $release;
  114. }
  115. }
  116. } else {
  117. if (defined $wikipath) {
  118. chdir($wikipath);
  119. foreach my $fn (keys %funcs) {
  120. my $revision = $funcs{$fn};
  121. $revision = $next_release if $revision eq 'HEAD';
  122. my $fname = "$fn.mediawiki";
  123. if ( ! -f $fname ) {
  124. #print STDERR "No such file: $fname\n";
  125. next;
  126. }
  127. my @lines = ();
  128. open(FH, '<', $fname) or die("Can't open $fname for read: $!\n");
  129. my $added = 0;
  130. while (<FH>) {
  131. chomp;
  132. if ((/\A\-\-\-\-/) && (!$added)) {
  133. push @lines, "== Version ==";
  134. push @lines, "";
  135. push @lines, "This function is available since SDL $revision.";
  136. push @lines, "";
  137. $added = 1;
  138. }
  139. push @lines, $_;
  140. next if not /\A\=\=\s+Version\s+\=\=/;
  141. $added = 1;
  142. push @lines, "";
  143. push @lines, "This function is available since SDL $revision.";
  144. push @lines, "";
  145. while (<FH>) {
  146. chomp;
  147. next if not (/\A\=\=\s+/ || /\A\-\-\-\-/);
  148. push @lines, $_;
  149. last;
  150. }
  151. }
  152. close(FH);
  153. if (!$added) {
  154. push @lines, "== Version ==";
  155. push @lines, "";
  156. push @lines, "This function is available since SDL $revision.";
  157. push @lines, "";
  158. }
  159. open(FH, '>', $fname) or die("Can't open $fname for write: $!\n");
  160. foreach (@lines) {
  161. print FH "$_\n";
  162. }
  163. close(FH);
  164. }
  165. }
  166. }