From: Nick Ing-Simmons Date: Sat, 7 Apr 2001 11:39:45 +0000 (+0000) Subject: Split out extension finding code from buildext.pl into FindExt.pm X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8e2329934bcca9c59680f6d478c3c2bc3ef7c649;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/MANIFEST b/MANIFEST index e358010..b6dab2e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1880,6 +1880,7 @@ win32/config_sh.PL Perl code to update Win32 config.sh from Makefile win32/des_fcrypt.patch Win32 port win32/distclean.bat Remove _ALL_ files not listed here in MANIFEST win32/dl_win32.xs Win32 port +win32/FindExt.pm Scan for extensions win32/genmk95.pl Perl code to generate command.com-usable makefile.95 win32/include/arpa/inet.h Win32 port win32/include/dirent.h Win32 port diff --git a/win32/FindExt.pm b/win32/FindExt.pm new file mode 100644 index 0000000..ea5165f --- /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; diff --git a/win32/buildext.pl b/win32/buildext.pl index 6e40bb9..5800750 100644 --- a/win32/buildext.pl +++ b/win32/buildext.pl @@ -1,6 +1,6 @@ -use File::Find; use File::Basename; use Cwd; +use FindExt; my $here = getcwd(); my $perl = $^X; $here =~ s,/,\\,g; @@ -15,12 +15,11 @@ my $dmod = -M $dep; my $dir = shift; chdir($dir) || die "Cannot cd to $dir\n"; (my $ext = getcwd()) =~ s,/,\\,g; -my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File Syslog Sysv)); -$no = qr/^(?:$no)$/i; -my %ext; -find(\&find_xs,'.'); +FindExt::scan_ext($ext); -foreach my $dir (sort keys %ext) +my @ext = FindExt::extensions(); + +foreach my $dir (sort @ext) { if (chdir("$ext\\$dir")) { @@ -46,19 +45,3 @@ foreach my $dir (sort keys %ext) } } -sub find_xs -{ - 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) - { - $ext{$dir} = $name; - } - } -} diff --git a/win32/config_sh.PL b/win32/config_sh.PL index 0e1d351..9757e52 100644 --- a/win32/config_sh.PL +++ b/win32/config_sh.PL @@ -1,3 +1,4 @@ +use FindExt; # take a semicolon separated path list and turn it into a quoted # list of paths that Text::Parsewords will grok sub mungepath { @@ -33,13 +34,19 @@ sub loadopts { } } +FindExt::scan_ext("../ext"); + my %opt; + my $optref = loadopts(); while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) { $opt{$1}=$2; shift(@{$optref}); } +$opt{'dynamic_ext'} = join(' ',FindExt::dynamic_extensions()); +$opt{'nonxs_ext'} = join(' ',FindExt::noxs_extensions()); + my $pl_h = '../patchlevel.h'; if (-e $pl_h) { diff --git a/win32/makefile.mk b/win32/makefile.mk index 5333ce6..25ec97d 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -800,8 +800,6 @@ CFG_VARS = \ _o=$(o) obj_ext=$(o) ~ \ _a=$(a) lib_ext=$(a) ~ \ static_ext=$(STATIC_EXT) ~ \ - dynamic_ext=$(DYNAMIC_EXT) ~ \ - nonxs_ext=$(NONXS_EXT) ~ \ use5005threads=$(USE_5005THREADS) ~ \ useithreads=$(USE_ITHREADS) ~ \ usethreads=$(USE_5005THREADS) ~ \ @@ -902,7 +900,7 @@ config.w32 : $(CFGSH_TMPL) -del /f config.h copy $(CFGH_TMPL) config.h -..\config.sh : config.w32 $(MINIPERL) config_sh.PL +..\config.sh : config.w32 $(MINIPERL) config_sh.PL FindExt.pm $(MINIPERL) -I..\lib config_sh.PL --cfgsh-option-file \ $(mktmp $(CFG_VARS)) config.w32 > ..\config.sh