This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
some more Porting/ script documentation
[perl5.git] / Porting / cmpVERSION.pl
CommitLineData
f1c5bace
JH
1#!/usr/bin/perl -w
2
3#
4# cmpVERSION - compare two Perl source trees for modules
5# that have identical version numbers but different contents.
6#
7# Original by slaven@rezic.de, modified by jhi.
8#
9
10use strict;
11
12use ExtUtils::MakeMaker;
13use File::Compare;
14use File::Find;
15use File::Spec::Functions qw(rel2abs abs2rel catfile catdir curdir);
16
0c429c78
DM
17@ARGV == 2 or die "usage: $0 source_dir1 source_dir2\n";
18
f1c5bace
JH
19for (@ARGV[0, 1]) {
20 die "$0: '$_' does not look like Perl directory\n"
21 unless -f catfile($_, "perl.h") && -d catdir($_, "Porting");
22}
23
24my $dir2 = rel2abs($ARGV[1]);
25chdir $ARGV[0] or die "$0: chdir '$ARGV[0]' failed: $!\n";
26
88830c88
JH
27# Files to skip from the check for one reason or another,
28# usually because they pull in their version from some other file.
29my %skip;
477acd91
SH
30@skip{
31 './lib/Carp/Heavy.pm',
8adca191
SH
32 './lib/Exporter/Heavy.pm',
33 './win32/FindExt.pm'
477acd91 34} = ();
ae8d64f5 35my $skip_dirs = qr|^\./t/lib|;
88830c88 36
f1c5bace
JH
37my @wanted;
38find(
39 sub { /\.pm$/ &&
ae8d64f5 40 $File::Find::dir !~ $skip_dirs &&
88830c88
JH
41 ! exists $skip{$File::Find::name}
42 &&
f1c5bace
JH
43 do { my $file2 =
44 catfile(catdir($dir2, $File::Find::dir), $_);
780d3752
JH
45 (my $xs_file1 = $_) =~ s/\.pm$/.xs/;
46 (my $xs_file2 = $file2) =~ s/\.pm$/.xs/;
47 if (-e $xs_file1 && -e $xs_file2) {
48 return if compare($_, $file2) == 0 &&
49 compare($xs_file1, $xs_file2) == 0;
50 } else {
51 return if compare($_, $file2) == 0;
52 }
f1c5bace
JH
53 my $version1 = eval {MM->parse_version($_)};
54 my $version2 = eval {MM->parse_version($file2)};
55 push @wanted, $File::Find::name
0ac6c0fd
JH
56 if defined $version1 &&
57 defined $version2 &&
58 $version1 eq $version2
f1c5bace
JH
59 } }, curdir);
60print map { $_, "\n" } sort @wanted;
61