fnsince.pl 5.4 KB

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