This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
devel/mktodo: Add ability for multiple source dirs
[perl5.git] / dist / Devel-PPPort / devel / mktodo
CommitLineData
adfe19db
MHM
1#!/usr/bin/perl -w
2################################################################################
3#
4# mktodo -- generate baseline and todo files by running mktodo.pl
5#
b53c2d56
KW
6# It calls plain 'mktodo' on each perl version it finds based on the input
7# parameters.
8#
adfe19db
MHM
9################################################################################
10#
b2049988 11# Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
adfe19db
MHM
12# Version 2.x, Copyright (C) 2001, Paul Marquess.
13# Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
14#
15# This program is free software; you can redistribute it and/or
16# modify it under the same terms as Perl itself.
17#
18################################################################################
19
20use strict;
21use Getopt::Long;
22
3d7c117d 23require './devel/devtools.pl';
0c96388f
MHM
24
25our %opt = (
b53c2d56
KW
26 base => 0, # If specified, this will generate base files, not todo ones
27 check => 1, # Do extra checking
0c96388f 28 verbose => 0,
49ef49fe 29 install => '/tmp/perl/install/default',
b2049988 30 blead => 'bleadperl-debug',
adfe19db
MHM
31);
32
b53c2d56
KW
33# The way this works, is it expects to find perl binaries for a bunch of
34# different versions in a given directory. This defaults to the 'install' one
01514562
KW
35# listed above, but is overriddable by the --install parameter. Comma
36# separating --install allows multiple source directories.
37# It also uses blead, again with an overridable default.
b53c2d56
KW
38#
39# It first verifies that the test file works properly for blead.
40#
41# Then it goes through the list of perl binaries sorted in decreasing order of
42# version number. If something works in version n, but not in version n-1,
43# that means it was introduced (or perhaps fixed) in version n, and adds that
44# thing to the version n list.
45#
46# After everything is done, we have lists of what got added when. The --base
47# parameter tells it to not use ppport.h when computing this. Thus we get
48# what the official perls added when. Without this parameter, we do use
49# ppport.h, so we get, as patched by ppport.h, what gets added when
50
49ef49fe 51GetOptions(\%opt, qw( base check! verbose install=s blead=s blead-version=s )) or die;
adfe19db 52
0c96388f
MHM
53identify();
54
adfe19db
MHM
55my $outdir = 'parts/todo';
56
49ef49fe 57
01514562
KW
58# Get blead and all other perls
59my @perls = $opt{blead};
60for my $dir (split ",", $opt{install}) {
61 push @perls, grep !/-RC\d+/, glob "$dir/bin/perl5.*";
62}
63
64# Sort in descending version order. Each element is a hash describing a perl,
65# with keys 'version' and 'path'
66@perls = sort { $b->{version} <=> $a->{version} }
67
68 # Call the perl to get it to print out it's $]
69 # version
70 map { { version => `$_ -e 'printf "%.6f", \$]'`,
71 path => $_ }
72 }
73 @perls;
74
75# Override blead's version if specified.
49ef49fe
CBW
76if (exists $opt{'blead-version'}) {
77 $perls[0]{version} = $opt{'blead-version'};
78}
adfe19db 79
01514562
KW
80my %seen;
81
ac18778d 82# blead's todo is its version plus 1. Otherwise, each todo is the previous
01514562 83# one's version. Also get rid of duplicate versions.
ac18778d 84$perls[0]{todo} = $perls[0]{version} + 1;
01514562
KW
85$seen{$perls[0]{version}} = 1;
86for my $i (1 .. $#perls) {
87 last unless defined $perls[$i];
88 if ( exists $seen{$perls[$i]{version}}
89 ) {
90 splice @perls, $i, 1;
91 redo;
92 }
93 $seen{$perls[$i]{version}} = 1;
94 $perls[$i]{todo} = $perls[$i-1]{version};
adfe19db
MHM
95}
96
01514562 97# Go through all the perls, creating a todo file for it.
adfe19db
MHM
98for (@perls) {
99 my $todo = do { my $v = $_->{todo}; $v =~ s/\D+//g; $v };
ac18778d
KW
100 my @args = ('--perl', $_->{path}, '--version', "$_->{todo}");
101
102 push @args, '--blead' if $_ == $perls[0]; # First one is blead
103 push @args, '--todo', $_->{'todo'};
adfe19db 104 push @args, '--base' if $opt{base};
0c96388f 105 push @args, '--verbose' if $opt{verbose};
ba120f6f 106 push @args, '--nocheck' unless $opt{check};
0c96388f 107 runperl('devel/mktodo.pl', @args) or die "error running mktodo.pl [$!] [$?]\n";
adfe19db 108}