diff options
author | Yitzchak Scott-Thoennes <sthoenna@efn.org> | 2005-01-05 02:01:41 -0800 |
---|---|---|
committer | Steve Hay <SteveHay@planit.com> | 2005-01-06 11:26:12 +0000 |
commit | ca58f2aeab528ade827eb3d1af8749823f00a279 (patch) | |
tree | 8336fed6f20c277911dbf278f4eb157e95218825 | |
parent | 03f6ae0019cb1114cbf610f18c001a1250683ef8 (diff) | |
download | perl-ca58f2aeab528ade827eb3d1af8749823f00a279.tar.gz |
Fix extensions config fields on Win32 to be as they are on Unix
Subject: [PATCH] Re: lib/Config/Extensions.t fails on Win32
Message-ID: <20050105180141.GA676@efn.org>
p4raw-id: //depot/perl@23757
-rw-r--r-- | win32/FindExt.pm | 100 | ||||
-rw-r--r-- | win32/config_sh.PL | 20 |
2 files changed, 75 insertions, 45 deletions
diff --git a/win32/FindExt.pm b/win32/FindExt.pm index 8f1952fe96..62429a57a3 100644 --- a/win32/FindExt.pm +++ b/win32/FindExt.pm @@ -2,68 +2,104 @@ package FindExt; our $VERSION = '1.00'; -# We (probably) have not got a Config.pm yet -BEGIN { $INC{'Config.pm'} = __FILE__ }; - use strict; -use File::Find; -use File::Basename; -use Cwd; +use warnings; -my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File +my $no = join('|',qw(GDBM_File ODBM_File NDBM_File DB_File Syslog SysV Langinfo)); $no = qr/^(?:$no)$/i; my %ext; my $ext; +my %static; + +sub getcwd { + $ENV{'PWD'} = Win32::GetCwd(); + $ENV{'PWD'} =~ s:\\:/:g ; + return $ENV{'PWD'}; +} + +sub set_static_extensions +{ + # adjust results of scan_ext, and also save + # statics in case scan_ext hasn't been called yet. + %static = (); + for (@_) { + $static{$_} = 1; + $ext{$_} = 'static' if $ext{$_} && $ext{$_} eq 'dynamic'; + } +} + sub scan_ext { my $here = getcwd(); my $dir = shift; chdir($dir) || die "Cannot cd to $dir\n"; ($ext = getcwd()) =~ s,/,\\,g; - find(\&find_ext,'.'); + find_ext(''); chdir($here) || die "Cannot cd to $here\n"; my @ext = extensions(); } -sub dynamic_extensions +sub dynamic_ext +{ + return sort grep $ext{$_} eq 'dynamic',keys %ext; +} + +sub static_ext { - return grep $ext{$_} eq 'dynamic',keys %ext; + return sort grep $ext{$_} eq 'static',keys %ext; } -sub noxs_extensions +sub nonxs_ext { - return grep $ext{$_} eq 'nonxs',keys %ext; + return sort grep $ext{$_} eq 'nonxs',keys %ext; } sub extensions { - return keys %ext; + return sort grep $ext{$_} ne 'known',keys %ext; +} + +sub known_extensions +{ + # faithfully copy Configure in not including nonxs extensions for the nonce + return sort grep $ext{$_} ne 'nonxs',keys %ext; +} + +sub is_static +{ + return $ext{$_[0]} eq 'static' } +# Function to recursively find available extensions, ignoring DynaLoader +# NOTE: recursion limit of 10 to prevent runaway in case of symlink madness sub find_ext { - if (/^(.*)\.pm$/i || /^(.*)_pm\.PL$/i || /^(.*)\.xs$/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'; - } + for my $xxx (glob "*") { + if ($xxx ne "DynaLoader") { + if (-f "$xxx/$xxx.xs") { + $ext{"$_[0]$xxx"} = $static{"$_[0]$xxx"} ? 'static' : 'dynamic'; + } elsif (-f "$xxx/Makefile.PL") { + $ext{"$_[0]$xxx"} = 'nonxs'; + } else { + if (-d $xxx && @_ < 10) { + chdir $xxx; + find_ext("$_[0]$xxx/", @_); + chdir ".."; + } + } + $ext{"$_[0]$xxx"} = 'known' if $ext{"$_[0]$xxx"} && $xxx =~ $no; + } + } + +# Special case: Add in threads/shared since it is not picked up by the +# recursive find above (and adding in general recursive finding breaks +# SDBM_File/sdbm). A.D. 10/25/2001. + + if (!$_[0] && -d "threads/shared") { + $ext{"threads/shared"} = 'dynamic'; } - } } 1; diff --git a/win32/config_sh.PL b/win32/config_sh.PL index 3b76cd04ea..3c144f6954 100644 --- a/win32/config_sh.PL +++ b/win32/config_sh.PL @@ -34,8 +34,6 @@ sub loadopts { } } -FindExt::scan_ext("../ext"); - my %opt; my $optref = loadopts(); @@ -44,18 +42,14 @@ while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) { shift(@{$optref}); } -my @dynamic = FindExt::dynamic_extensions(); -my @noxs = FindExt::noxs_extensions(); -my @known = sort(@dynamic,split(/\s+/,$opt{'staticext'}),@noxs); -$opt{'known_extensions'} = join(' ',@known); - -@dynamic = grep(!/Thread/,@dynamic); -@known = grep(!/Thread/,@dynamic); - -$opt{'dynamic_ext'} = join(' ',@dynamic); -$opt{'nonxs_ext'} = join(' ',@noxs); +FindExt::scan_ext("../ext"); +FindExt::set_static_extensions(split ' ', $opt{'static_ext'}); -$opt{'extensions'} = join(' ',@known); +$opt{'nonxs_ext'} = join(' ',FindExt::nonxs_ext()) || ' '; +$opt{'static_ext'} = join(' ',FindExt::static_ext()) || ' '; +$opt{'dynamic_ext'} = join(' ',FindExt::dynamic_ext()) || ' '; +$opt{'extensions'} = join(' ',FindExt::extensions()) || ' '; +$opt{'known_extensions'} = join(' ',FindExt::known_extensions()) || ' '; my $pl_h = '../patchlevel.h'; |