This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate mainline - a few Devel::Peak fails.
[perl5.git] / win32 / FindExt.pm
CommitLineData
8e232993 1package FindExt;
28b605d8
JH
2
3our $VERSION = '1.00';
4
8e232993
NIS
5use strict;
6use File::Find;
7use File::Basename;
8use Cwd;
9
86c8d741
GS
10my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File
11 Syslog SysV Langinfo));
8e232993
NIS
12$no = qr/^(?:$no)$/i;
13
14my %ext;
15my $ext;
16sub scan_ext
17{
18 my $here = getcwd();
19 my $dir = shift;
20 chdir($dir) || die "Cannot cd to $dir\n";
21 ($ext = getcwd()) =~ s,/,\\,g;
22 find(\&find_ext,'.');
23 chdir($here) || die "Cannot cd to $here\n";
24 my @ext = extensions();
25}
26
27sub dynamic_extensions
28{
29 return grep $ext{$_} eq 'dynamic',keys %ext;
30}
31
32sub noxs_extensions
33{
6b29183e 34 return grep $ext{$_} eq 'nonxs',keys %ext;
8e232993
NIS
35}
36
37sub extensions
38{
39 return keys %ext;
40}
41
42sub find_ext
43{
6b29183e 44 if (/^(.*)\.pm$/i || /^(.*)_pm\.PL$/i || /^(.*)\.xs$/i)
8e232993
NIS
45 {
46 my $name = $1;
47 return if $name =~ $no;
48 my $dir = $File::Find::dir;
49 $dir =~ s,./,,;
50 return if exists $ext{$dir};
51 return unless -f "$ext/$dir/Makefile.PL";
52 if ($dir =~ /$name$/i)
53 {
54 if (-f "$ext/$dir/$name.xs")
55 {
56 $ext{$dir} = 'dynamic';
57 }
58 else
59 {
60 $ext{$dir} = 'nonxs';
61 }
62 }
63 }
64}
65
661;