🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
5.5 KiB

  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_RegisterApp'} = '2.0.2';
  77. $funcs{'SDL_UnregisterApp'} = '2.0.2';
  78. $funcs{'SDL_GetAssertionHandler'} = '2.0.2';
  79. $funcs{'SDL_GetDefaultAssertionHandler'} = '2.0.2';
  80. $funcs{'SDL_AtomicAdd'} = '2.0.2';
  81. $funcs{'SDL_AtomicGet'} = '2.0.2';
  82. $funcs{'SDL_AtomicGetPtr'} = '2.0.2';
  83. $funcs{'SDL_AtomicSet'} = '2.0.2';
  84. $funcs{'SDL_AtomicSetPtr'} = '2.0.2';
  85. $funcs{'SDL_HasAVX'} = '2.0.2';
  86. $funcs{'SDL_GameControllerAddMappingsFromRW'} = '2.0.2';
  87. $funcs{'SDL_acos'} = '2.0.2';
  88. $funcs{'SDL_asin'} = '2.0.2';
  89. $funcs{'SDL_vsscanf'} = '2.0.2';
  90. $funcs{'SDL_DetachThread'} = '2.0.2';
  91. $funcs{'SDL_GL_ResetAttributes'} = '2.0.2';
  92. $funcs{'SDL_DXGIGetOutputInfo'} = '2.0.2';
  93. # these are incorrect in the dynapi header, because we forgot to add them
  94. # until a later release, but are available in the older release.
  95. $funcs{'SDL_WinRTGetFSPathUNICODE'} = '2.0.3';
  96. $funcs{'SDL_WinRTGetFSPathUTF8'} = '2.0.3';
  97. $funcs{'SDL_WinRTRunApp'} = '2.0.3';
  98. if (not defined $wikipath) {
  99. foreach my $release (@releases) {
  100. foreach my $fn (sort keys %funcs) {
  101. print("$fn: $funcs{$fn}\n") if $funcs{$fn} eq $release;
  102. }
  103. }
  104. } else {
  105. if (defined $wikipath) {
  106. chdir($wikipath);
  107. foreach my $fn (keys %funcs) {
  108. my $revision = $funcs{$fn};
  109. $revision = $next_release if $revision eq 'HEAD';
  110. my $fname = "$fn.mediawiki";
  111. if ( ! -f $fname ) {
  112. #print STDERR "No such file: $fname\n";
  113. next;
  114. }
  115. my @lines = ();
  116. open(FH, '<', $fname) or die("Can't open $fname for read: $!\n");
  117. my $added = 0;
  118. while (<FH>) {
  119. chomp;
  120. if ((/\A\-\-\-\-/) && (!$added)) {
  121. push @lines, "== Version ==";
  122. push @lines, "";
  123. push @lines, "This function is available since SDL $revision.";
  124. push @lines, "";
  125. $added = 1;
  126. }
  127. push @lines, $_;
  128. next if not /\A\=\=\s+Version\s+\=\=/;
  129. $added = 1;
  130. push @lines, "";
  131. push @lines, "This function is available since SDL $revision.";
  132. push @lines, "";
  133. while (<FH>) {
  134. chomp;
  135. next if not (/\A\=\=\s+/ || /\A\-\-\-\-/);
  136. push @lines, $_;
  137. last;
  138. }
  139. }
  140. close(FH);
  141. if (!$added) {
  142. push @lines, "== Version ==";
  143. push @lines, "";
  144. push @lines, "This function is available since SDL $revision.";
  145. push @lines, "";
  146. }
  147. open(FH, '>', $fname) or die("Can't open $fname for write: $!\n");
  148. foreach (@lines) {
  149. print FH "$_\n";
  150. }
  151. close(FH);
  152. }
  153. }
  154. }