diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2002-05-31 21:42:12 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-05-31 21:42:12 +0000 |
commit | d5201bd266fe42b2df8b480183c08be291a1ad06 (patch) | |
tree | e7f719e75b91b93f6b813831b273f6d3dca6c15e /lib/lib_pm.PL | |
parent | 83943eac2433a9cd52f114532df2a61529f109a2 (diff) | |
download | perl-d5201bd266fe42b2df8b480183c08be291a1ad06.tar.gz |
Integrate macperl patches #16926 and #16938;
Big MacPerl Testing Patch No. 2
Big MacPerl Testing Patch No. 3
p4raw-id: //depot/perl@16942
p4raw-integrated: from //depot/macperl@16937 'copy in'
lib/Devel/SelfStubber.pm lib/Devel/SelfStubber.t
lib/File/DosGlob.t lib/File/Path.t lib/File/Spec/t/Spec.t
lib/File/Temp.pm lib/FindBin.t lib/Tie/File/t/09_gen_rs.t
lib/lib.t t/comp/use.t utils/dprofpp.PL utils/splain.PL
(@16123..) t/lib/MakeMaker/Test/Utils.pm (@16230..)
lib/diagnostics.t (@16646..) lib/ExtUtils/t/00setup_dummy.t
lib/ExtUtils/t/Command.t (@16730..) lib/lib_pm.PL (@16926..)
lib/ExtUtils/MM_MacOS.pm lib/Test/Harness/Straps.pm
lib/Test/Harness/t/callback.t
lib/Test/Harness/t/strap-analyze.t
lib/Test/Harness/t/test-harness.t (@16929..)
p4raw-integrated: from //depot/macperl@16926 'merge in' lib/English.t
(@16123..) ext/DynaLoader/DynaLoader_pm.PL (@16868..)
Diffstat (limited to 'lib/lib_pm.PL')
-rw-r--r-- | lib/lib_pm.PL | 78 |
1 files changed, 67 insertions, 11 deletions
diff --git a/lib/lib_pm.PL b/lib/lib_pm.PL index d7786732b7..daca494b75 100644 --- a/lib/lib_pm.PL +++ b/lib/lib_pm.PL @@ -57,6 +57,12 @@ print OUT <<'!NO!SUBS!'; our @ORIG_INC = @INC; # take a handy copy of 'original' value our $VERSION = '0.5564'; +my $Is_MacOS = $^O eq 'MacOS'; +my $Mac_FS; +if ($Is_MacOS) { + require File::Spec; + $Mac_FS = eval { require Mac::FileSpec::Unixish }; +} sub import { shift; @@ -67,21 +73,29 @@ sub import { require Carp; Carp::carp("Empty compile time value given to use lib"); } + + local $_ = _nativize($_); + if (-e && ! -d _) { require Carp; Carp::carp("Parameter to use lib must be directory, not file"); } unshift(@INC, $_); - # Add any previous version directories we found at configure time - foreach my $incver (@inc_version_list) - { - unshift(@INC, "$_/$incver") if -d "$_/$incver"; - } + # Add any previous version directories we found at configure time + foreach my $invcer (@inc_version_list) + { + my $dir = $Is_MacOS + ? File::Spec->catdir( $_, $incver ) + : "$_/$incver"; + unshift(@INC, $dir) if -d $dir; + } # Put a corresponding archlib directory infront of $_ if it # looks like $_ has an archlib directory below it. - unshift(@INC, "$_/$archname") if -d "$_/$archname/auto"; - unshift(@INC, "$_/$version") if -d "$_/$version"; - unshift(@INC, "$_/$version/$archname") if -d "$_/$version/$archname"; + my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir) + = _get_dirs($_); + unshift(@INC, $arch_dir) if -d $arch_auto_dir; + unshift(@INC, $version_dir) if -d $version_dir; + unshift(@INC, $version_arch_dir) if -d $version_arch_dir; } # remove trailing duplicates @@ -95,10 +109,14 @@ sub unimport { my %names; foreach (@_) { + local $_ = _nativize($_); + + my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir) + = _get_dirs($_); ++$names{$_}; - ++$names{"$_/$archname"} if -d "$_/$archname/auto"; - ++$names{"$_/$version"} if -d "$_/$version"; - ++$names{"$_/$version/$archname"} if -d "$_/$version/$archname"; + ++$names{$arch_dir} if -d $arch_auto_dir; + ++$names{$version_dir} if -d $version_dir; + ++$names{$version_arch_dir} if -d $version_arch_dir; } # Remove ALL instances of each named directory. @@ -106,6 +124,37 @@ sub unimport { return; } +sub _get_dirs { + my($dir) = @_; + my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir); + + # we could use this for all platforms in the future, but leave it + # Mac-only for now, until there is more time for testing it. + if ($Is_MacOS) { + $arch_auto_dir = File::Spec->catdir( $_, $archname, 'auto' ); + $arch_dir = File::Spec->catdir( $_, $archname, ); + $version_dir = File::Spec->catdir( $_, $version ); + $version_arch_dir = File::Spec->catdir( $_, $version, $archname ); + } else { + $arch_auto_dir = "$_/$archname/auto"; + $arch_dir = "$_/$archname"; + $version_dir = "$_/$version"; + $version_arch_dir = "$_/$version/$archname"; + } + return($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir); +} + +sub _nativize { + my($dir) = @_; + + if ($Is_MacOS && $Mac_FS) { + $dir = Mac::FileSpec::Unixish::nativize($dir); + $dir .= ":" unless $dir =~ /:$/; + } + + return $dir; +} + 1; __END__ @@ -181,6 +230,13 @@ users must first translate their file paths to Unix conventions. # their @INC would write use lib 'stuff/moo'; +=head1 NOTES + +In the future, this module will likely use File::Spec for determining +paths, as it does now for Mac OS (where Unix-style or Mac-style paths +work, and Unix-style paths are converted properly to Mac-style paths +before being added to @INC). + =head1 SEE ALSO FindBin - optional module which deals with paths relative to the source file. |