2 ################################################################################
4 # mktodo.pl -- generate baseline and todo files
6 ################################################################################
10 # $Date: 2006/05/25 17:22:32 +0200 $
12 ################################################################################
14 # Version 3.x, Copyright (C) 2004-2006, Marcus Holland-Moritz.
15 # Version 2.x, Copyright (C) 2001, Paul Marquess.
16 # Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
18 # This program is free software; you can redistribute it and/or
19 # modify it under the same terms as Perl itself.
21 ################################################################################
28 use Time::HiRes qw( gettimeofday tv_interval );
30 require 'devel/devtools.pl';
39 perl=s todo=s version=s debug base verbose
44 print "\n", ident_str(), "\n\n";
46 my $fullperl = `which $opt{perl}`;
49 $ENV{SKIP_SLOW_TESTS} = 1;
54 for (`nm $fullperl`) {
56 /\s+T\s+(\w+)\s*$/ and $sym{$1}++;
58 keys %sym >= 50 or die "less than 50 symbols found in $fullperl\n";
60 my %all = %{load_todo($opt{todo}, $opt{version})};
67 my $r = run(qw(make test));
68 $r->{didnotrun} and die "couldn't run make test: $!\n";
69 $r->{status} == 0 and last;
70 my(@new, @tmp, %seen);
71 for my $l (@{$r->{stderr}}) {
72 if ($l =~ /_DPPP_test_(\w+)/) {
74 my @s = grep { exists $sym{$_} } $1, "Perl_$1", "perl_$1";
76 push @tmp, [$1, "E (@s)"];
83 if ($l =~ /undefined symbol: (?:[Pp]erl_)?(\w+)/) {
85 my @s = grep { exists $sym{$_} } $1, "Perl_$1", "perl_$1";
86 push @new, [$1, @s ? "U (@s)" : "U"];
90 @new = grep !$all{$_->[0]}, @new;
92 @new = grep !$all{$_->[0]}, @tmp;
93 # TODO: @recheck was here, find a better way to get recheck syms
94 # * try to grep out warnings before making symlist ?
103 die "no new TODO symbols found...";
105 # don't recheck undefined symbols reported by the dynamic linker
106 push @recheck, map { $_->[0] } grep { $_->[1] !~ /^U/ } @new;
108 printf "[$opt{version}] new symbol: %-30s # %s\n", @$_;
109 $all{$_->[0]} = $_->[1];
111 write_todo($opt{todo}, $opt{version}, \%all);
114 my $ifmt = '%' . length(scalar @recheck) . 'd';
115 my $t0 = [gettimeofday];
117 RECHECK: for my $i (0 .. $#recheck) {
118 my $sym = $recheck[$i];
119 my $cur = delete $all{$sym};
121 printf "[$opt{version}] chk symbol: %-30s # %s [$ifmt/$ifmt, ETA %s]\n",
122 $sym, $cur, $i + 1, scalar @recheck, eta($t0, $i, scalar @recheck);
124 write_todo($opt{todo}, $opt{version}, \%all);
126 if ($cur eq "E (Perl_$sym)") {
127 # we can try a shortcut here
128 regen_apicheck($sym);
130 my $r = run(qw(make test));
132 if (!$r->{didnotrun} && $r->{status} == 0) {
133 printf "[$opt{version}] del symbol: %-30s # %s\n", $sym, $cur;
141 my $r = run(qw(make test));
143 $r->{didnotrun} and die "couldn't run make test: $!\n";
145 if ($r->{status} == 0) {
146 printf "[$opt{version}] del symbol: %-30s # %s\n", $sym, $cur;
153 write_todo($opt{todo}, $opt{version}, \%all);
155 run(qw(make realclean));
161 my @mf_arg = ('--with-apicheck', 'OPTIMIZE=-O0');
162 push @mf_arg, qw( DEFINE=-DDPPP_APICHECK_NO_PPPORT_H ) if $opt{base};
165 run(qw(make realclean));
166 run($fullperl, "Makefile.PL", @mf_arg)->{status} == 0
167 or die "cannot run Makefile.PL: $!\n";
172 unlink qw(apicheck.c apicheck.o);
173 runtool({ out => '/dev/null' }, $fullperl, 'apicheck_c.PL', map { "--api=$_" } @_)
174 or die "cannot regenerate apicheck.c\n";
179 my($file, $expver) = @_;
182 my $f = new IO::File $file or die "cannot open $file: $!\n";
185 if ($ver eq $expver) {
189 /^(\w+)\s+#\s+(.*)/ or goto nuke_file;
190 exists $sym{$1} and goto nuke_file;
198 unlink $file or die "cannot remove $file: $!\n";
206 my($file, $ver, $sym) = @_;
209 $f = new IO::File ">$file" or die "cannot open $file: $!\n";
212 for (sort keys %$sym) {
213 $f->print(sprintf "%-30s # %s\n", $_, $sym->{$_});