fnsince.pl 5.7 KB

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