fnsince.pl 5.1 KB

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