diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-04-07 11:39:45 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-04-07 11:39:45 +0000 |
commit | 8e2329934bcca9c59680f6d478c3c2bc3ef7c649 (patch) | |
tree | d3828afeb910666ce7ae57b739670767c1bc0326 /win32/FindExt.pm | |
parent | 267cbce72d0da7af102852e6d7e0bb5c1ce41da6 (diff) | |
download | perl-8e2329934bcca9c59680f6d478c3c2bc3ef7c649.tar.gz |
Split out extension finding code from buildext.pl into FindExt.pm
Use it to get Config.pm's idea of available extensions in line
with what is built.
p4raw-id: //depot/perlio@9604
Diffstat (limited to 'win32/FindExt.pm')
-rw-r--r-- | win32/FindExt.pm | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/win32/FindExt.pm b/win32/FindExt.pm new file mode 100644 index 0000000000..ea5165f1c4 --- /dev/null +++ b/win32/FindExt.pm @@ -0,0 +1,62 @@ +package FindExt; +use strict; +use File::Find; +use File::Basename; +use Cwd; + +my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File Syslog Sysv)); +$no = qr/^(?:$no)$/i; + +my %ext; +my $ext; +sub scan_ext +{ + my $here = getcwd(); + my $dir = shift; + chdir($dir) || die "Cannot cd to $dir\n"; + ($ext = getcwd()) =~ s,/,\\,g; + find(\&find_ext,'.'); + chdir($here) || die "Cannot cd to $here\n"; + my @ext = extensions(); +} + +sub dynamic_extensions +{ + return grep $ext{$_} eq 'dynamic',keys %ext; +} + +sub noxs_extensions +{ + return grep $ext{$_} eq 'noxs',keys %ext; +} + +sub extensions +{ + return keys %ext; +} + +sub find_ext +{ + if (/^(.*)\.pm$/i || /^(.*)_pm.PL$/i) + { + my $name = $1; + return if $name =~ $no; + my $dir = $File::Find::dir; + $dir =~ s,./,,; + return if exists $ext{$dir}; + return unless -f "$ext/$dir/Makefile.PL"; + if ($dir =~ /$name$/i) + { + if (-f "$ext/$dir/$name.xs") + { + $ext{$dir} = 'dynamic'; + } + else + { + $ext{$dir} = 'nonxs'; + } + } + } +} + +1; |