This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
devel/mktodo.pl: Don't discard earliest info
authorKarl Williamson <khw@cpan.org>
Sun, 21 Jul 2019 03:43:12 +0000 (21:43 -0600)
committerNicolas R <atoomic@cpan.org>
Fri, 27 Sep 2019 22:39:33 +0000 (16:39 -0600)
When regenerating the files of what came when, the code uses version n
as a base to see what version n+1 added.  Prior to this commit the
information from version 0 was simply discarded.  That meant you had to
have one more perl to compile than what you wanted info for.  That is
wasteful and unnecessary.

This commit changes so that a file is generated for the earliest perl
being generated, containing all the API symbols known to that perl.
Effectively, it assumes that all of them popped into existence when that
version came out.  Words will be changed in the output to indicate that
these symbols have been available AT LEAST since this version.

For many years, the earliest perl that we had info for was 5.003_07.
That meant that the regeneration was run with an even earlier perl.
With this commit, wherever we stop, we have information from it, and
don't have to throw anything away.

(cherry picked from commit 28c1bee885eb2373eda222e45b5af49cec6ccfb5)
Signed-off-by: Nicolas R <atoomic@cpan.org>
dist/Devel-PPPort/PPPort_pm.PL
dist/Devel-PPPort/devel/devtools.pl
dist/Devel-PPPort/devel/mktodo
dist/Devel-PPPort/devel/mktodo.pl

index c9f9ec4..d5b0376 100644 (file)
@@ -62,9 +62,16 @@ $data =~ s!^(.*)__EXPLICIT_API__(\s*?)^!
 my %raw_base = %{&parse_todo('parts/base')};
 my %raw_todo = %{&parse_todo('parts/todo')};
 
+# Invert so each key is the 7 digit version number, and it's value is an array
+# of all symbols within it, like:
+#          '5005003' => [
+#                         'POPpx',
+#                         'get_vtbl',
+#                         'save_generic_svref'
+#                       ],
 my %todo;
 for (keys %raw_todo) {
-  push @{$todo{$raw_todo{$_}}}, $_;
+  push @{$todo{int_parse_version($raw_todo{$_})}}, $_;
 }
 
 # Most recent first
@@ -73,15 +80,22 @@ my @todo_list = reverse sort keys %todo;
 # The first and final elements give the extremes of the supported versions.
 # (Use defaults that were reasonable at the time of this commit if the
 # directories are empty (which should only happen during regeneration of the
-# base and todo files).)
-my $MAX_PERL = format_version((@todo_list) ? $todo_list[0] : '5.30.0');
+# base and todo files).).  Actually the final element is for blead (at the
+# time things were regenerated), which is 1 beyond the max version supported.
+my $INT_MAX_PERL = (@todo_list) ? $todo_list[0] - 1 : '5030000';
+my $MAX_PERL = format_version($INT_MAX_PERL);
 my $INT_MIN_PERL = (@todo_list) ? $todo_list[-1] : 5003007;
 my $MIN_PERL = format_version($INT_MIN_PERL);
 
+
 # check consistency
 for (@api) {
-  if (exists $raw_todo{$_} and exists $raw_base{$_}) {
-    if ($raw_base{$_} eq $raw_todo{$_}) {
+  if (   exists $raw_todo{$_}
+      && $raw_todo{$_} > $INT_MIN_PERL      # INT_MIN_PERL contents are real
+                                            # symbols, not something to do
+      && exists $raw_base{$_})
+  {
+    if ($raw_base{$_} == $raw_todo{$_}) {
       warn "$INCLUDE/$provides{$_} provides $_, which is still marked "
            . "todo for " . format_version($raw_todo{$_}) . "\n";
     }
@@ -130,6 +144,7 @@ my $undocumented = "(undocumented)";
 my @todo;
 for (@todo_list) {
   my $ver = format_version($_);
+  $ver .= " (at least)" if $_ == $todo_list[-1];
   my $todo = "=item perl $ver\n\n";
   for (sort dictionary_order @{$todo{$_}}) {
     $todo .= "  $_";
index 96939e0..e2437a5 100644 (file)
@@ -212,6 +212,10 @@ sub get_and_sort_perls($)
         $perls[$i]{todo} = $perls[$i-1]{file};
     }
 
+    # The earliest perl gets a special marker key, consisting of the proper
+    # file name
+    $perls[$#perls]{final} = $perls[$#perls]{file};
+
     if ($opt{debug}) {
         print STDERR "The perls returned are: ", Dumper \@perls;
     }
index 999d6ca..40e3467 100755 (executable)
@@ -75,5 +75,6 @@ for (my $i = 0; $i < @$perls_ref; $i++) {
   push @args, "--debug=$opt{debug}" if $opt{debug};
   push @args, '--verbose' if $opt{verbose};
   push @args, '--nocheck' unless $opt{check};
+  push @args, '--final', $this_perl->{'final'} if $this_perl->{'final'};
   runperl('devel/mktodo.pl', @args) or die "error running mktodo.pl [$!] [$?]\n";
 }
index 89b7754..62936bd 100644 (file)
@@ -32,13 +32,14 @@ our %opt = (
   base      => 0,     # Don't use ppport.h when generating
   verbose   => 0,
   check     => 1,
+  final     => "",
  'todo-dir' => "",
   todo      => "",    # If no --todo, this is a blead perl
   shlib     => 'blib/arch/auto/Devel/PPPort/PPPort.so',
 );
 
 GetOptions(\%opt, qw(
-perl=s todo=i blead todo-dir=s version=s shlib=s debug=i base verbose check!
+perl=s todo=i blead todo-dir=s version=s shlib=s debug=i base final=s verbose check!
           )) or die;
 
 identify();
@@ -347,6 +348,29 @@ if ($opt{check}) {
 print STDERR __LINE__, ": %todo at end ", Dumper \%todo  if $opt{debug} > 6;
 write_todo($todo_file, $todo_version, \%todo);
 
+# If this is the earliest perl being tested, we can extend down our values to
+# include it.  (Remember, that we create files for the next higher version,
+# but this allows us to create a file for the lowest as well.)  This
+# effectively writes out all the known symbols of this earliest version as if
+# they came into existence during it.
+if ($opt{final}) {
+    my $file = "$opt{'todo-dir'}/$opt{final}";
+    my $version = format_version_line($opt{final});
+
+    regen_Makefile();
+    my $r = run(qw(make));
+    $r->{didnotrun} and die "couldn't run make: $!\n" .
+        join('', @{$r->{stdout}})."\n---\n".join('', @{$r->{stderr}});
+
+    my $symbols = read_sym(file => $opt{shlib}, options => [qw( --defined-only )]);
+    my @stuff = map { /_DPPP_test_(.*)/ } keys %$symbols;
+    %todo = map { $_ => 'T' } @stuff;
+
+    print STDERR __LINE__, ": write at ", Dumper $file, $version, \%todo
+                                                            if $opt{debug} > 5;
+    write_todo($file, $version, \%todo);
+}
+
 # Clean up after ourselves
 $opt{debug} = 0;    # Don't care about failures
 run(qw(make realclean));