Skip to content

Stop inheriting from File::Spec #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ExtUtils/Liblist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ our $VERSION = '7.05_07';

use File::Spec;
require ExtUtils::Liblist::Kid;
our @ISA = qw(ExtUtils::Liblist::Kid File::Spec);
our @ISA = qw(ExtUtils::Liblist::Kid);

# Backwards compatibility with old interface.
sub ext {
Expand Down
8 changes: 4 additions & 4 deletions lib/ExtUtils/Liblist/Kid.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ sub _unix_os2_ext {
}
unless ( File::Spec->file_name_is_absolute( $thislib ) ) {
warn "Warning: $ptype$thislib changed to $ptype$pwd/$thislib\n";
$thislib = $self->catdir( $pwd, $thislib );
$thislib = File::Spec->catdir( $pwd, $thislib );
}
push( @searchpath, $thislib );
push( @extralibs, "$ptype$thislib" );
Expand Down Expand Up @@ -318,7 +318,7 @@ sub _win32_ext {
elsif ( -d ) {
unless ( File::Spec->file_name_is_absolute( $_ ) ) {
warn "Warning: '$thislib' changed to '-L$pwd/$_'\n";
$_ = $self->catdir( $pwd, $_ );
$_ = File::Spec->catdir( $pwd, $_ );
}
push( @searchpath, $_ );
next;
Expand Down Expand Up @@ -475,7 +475,7 @@ sub _vms_ext {
if ( lc $type eq '/share' ) { $locspec .= $Config{'exe_ext'}; }
elsif ( lc $type eq '/library' ) { $locspec .= $Config{'lib_ext'}; }
else { $locspec .= $Config{'obj_ext'}; }
$locspec = $self->catfile( $self->{PERL_SRC}, $locspec );
$locspec = File::Spec->catfile( $self->{PERL_SRC}, $locspec );
$lib = "$locspec$type" if -e $locspec;
}
}
Expand Down Expand Up @@ -539,7 +539,7 @@ sub _vms_ext {
$dir = VMS::Filespec::vmspath( $dir );
}
else {
$dir = $self->catdir( $cwd, $dir );
$dir = File::Spec->catdir( $cwd, $dir );
}
}
@dirs = grep { length( $_ ) } @dirs;
Expand Down
55 changes: 27 additions & 28 deletions lib/ExtUtils/MM_Any.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ use ExtUtils::MakeMaker qw($Verbose write_file_via_tmp neatvalue);

use ExtUtils::MakeMaker::Config;


# So we don't have to keep calling the methods over and over again,
# we have these globals to cache the values. Faster and shrtr.
my $Curdir = __PACKAGE__->curdir;
my $Rootdir = __PACKAGE__->rootdir;
my $Updir = __PACKAGE__->updir;
my $Curdir = File::Spec->curdir;
my $Rootdir = File::Spec->rootdir;
my $Updir = File::Spec->updir;

my $METASPEC_URL = 'https://metacpan.org/pod/CPAN::Meta::Spec';
my $METASPEC_V = 2;
Expand Down Expand Up @@ -212,7 +211,7 @@ sub _clear_maketype_cache { %maketype2true = () }
sub is_make_type {
my($self, $type) = @_;
return $maketype2true{$type} if defined $maketype2true{$type};
(undef, undef, my $make_basename) = $self->splitpath($self->make);
(undef, undef, my $make_basename) = File::Spec->splitpath($self->make);
return $maketype2true{$type} = 1
if $make_basename =~ /\b$type\b/i; # executable's filename
return $maketype2true{$type} = 0
Expand Down Expand Up @@ -678,7 +677,7 @@ sub blibdirs_target {
my ($v, $d, $f) = File::Spec->splitpath($ext);
my @d = File::Spec->splitdir($d);
shift @d if $d[0] eq 'lib';
push @dirs, $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f);
push @dirs, File::Spec->catdir('$(INST_ARCHLIB)', 'auto', @d, $f);
}
}

Expand Down Expand Up @@ -755,8 +754,8 @@ clean :: clean_subdirs
$(BASEEXT).exp $(BASEEXT).x
]);

push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.ld'));
push(@files, File::Spec->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
push(@files, File::Spec->catfile('$(INST_ARCHAUTODIR)','extralibs.ld'));

# core files
if ($^O eq 'vos') {
Expand Down Expand Up @@ -1922,8 +1921,8 @@ to XS code. Those are handled in init_xs.
sub init_INST {
my($self) = shift;

$self->{INST_ARCHLIB} ||= $self->catdir($Curdir,"blib","arch");
$self->{INST_BIN} ||= $self->catdir($Curdir,'blib','bin');
$self->{INST_ARCHLIB} ||= File::Spec->catdir($Curdir,"blib","arch");
$self->{INST_BIN} ||= File::Spec->catdir($Curdir,'blib','bin');

# INST_LIB typically pre-set if building an extension after
# perl has been built and installed. Setting INST_LIB allows
Expand All @@ -1932,22 +1931,22 @@ sub init_INST {
if ($self->{PERL_CORE}) {
$self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
} else {
$self->{INST_LIB} = $self->catdir($Curdir,"blib","lib");
$self->{INST_LIB} = File::Spec->catdir($Curdir,"blib","lib");
}
}

my @parentdir = split(/::/, $self->{PARENT_NAME});
$self->{INST_LIBDIR} = $self->catdir('$(INST_LIB)', @parentdir);
$self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB)', @parentdir);
$self->{INST_AUTODIR} = $self->catdir('$(INST_LIB)', 'auto',
$self->{INST_LIBDIR} = File::Spec->catdir('$(INST_LIB)', @parentdir);
$self->{INST_ARCHLIBDIR} = File::Spec->catdir('$(INST_ARCHLIB)', @parentdir);
$self->{INST_AUTODIR} = File::Spec->catdir('$(INST_LIB)', 'auto',
'$(FULLEXT)');
$self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)', 'auto',
$self->{INST_ARCHAUTODIR} = File::Spec->catdir('$(INST_ARCHLIB)', 'auto',
'$(FULLEXT)');

$self->{INST_SCRIPT} ||= $self->catdir($Curdir,'blib','script');
$self->{INST_SCRIPT} ||= File::Spec->catdir($Curdir,'blib','script');

$self->{INST_MAN1DIR} ||= $self->catdir($Curdir,'blib','man1');
$self->{INST_MAN3DIR} ||= $self->catdir($Curdir,'blib','man3');
$self->{INST_MAN1DIR} ||= File::Spec->catdir($Curdir,'blib','man1');
$self->{INST_MAN3DIR} ||= File::Spec->catdir($Curdir,'blib','man3');

return 1;
}
Expand Down Expand Up @@ -2157,7 +2156,7 @@ sub init_INSTALL_from_PREFIX {

if( $var =~ /arch/ ) {
$self->{$Installvar} ||=
$self->catdir($self->{LIB}, $Config{archname});
File::Spec->catdir($self->{LIB}, $Config{archname});
}
else {
$self->{$Installvar} ||= $self->{LIB};
Expand Down Expand Up @@ -2224,7 +2223,7 @@ sub init_INSTALL_from_INSTALL_BASE {
my $key = "INSTALL".$dir.$uc_thing;

$install{$key} ||=
$self->catdir('$(INSTALL_BASE)', @{$map{$thing}});
File::Spec->catdir('$(INSTALL_BASE)', @{$map{$thing}});
}
}

Expand Down Expand Up @@ -2745,11 +2744,11 @@ sub arch_check {

return 1 if $self->{PERL_SRC};

my($pvol, $pthinks) = $self->splitpath($pconfig);
my($cvol, $cthinks) = $self->splitpath($cconfig);
my($pvol, $pthinks) = File::Spec->splitpath($pconfig);
my($cvol, $cthinks) = File::Spec->splitpath($cconfig);

$pthinks = $self->canonpath($pthinks);
$cthinks = $self->canonpath($cthinks);
$pthinks = File::Spec->canonpath($pthinks);
$cthinks = File::Spec->canonpath($cthinks);

my $ret = 1;
if ($pthinks ne $cthinks) {
Expand All @@ -2758,7 +2757,7 @@ sub arch_check {

$ret = 0;

my $arch = (grep length, $self->splitdir($pthinks))[-1];
my $arch = (grep length, File::Spec->splitdir($pthinks))[-1];

print <<END unless $self->{UNINSTALLED_PERL};
Your perl and your Config.pm seem to have different ideas about the
Expand Down Expand Up @@ -2904,9 +2903,9 @@ installation.

sub libscan {
my($self,$path) = @_;
my($dirs,$file) = ($self->splitpath($path))[1,2];
my($dirs,$file) = (File::Spec->splitpath($path))[1,2];
return '' if grep /^(?:RCS|CVS|SCCS|\.svn|_darcs)$/,
$self->splitdir($dirs), $file;
File::Spec->splitdir($dirs), $file;

return $path;
}
Expand Down Expand Up @@ -3034,7 +3033,7 @@ Used by perldepend() in MM_Unix and MM_VMS via _perl_header_files_fragment()
sub _perl_header_files {
my $self = shift;

my $header_dir = $self->{PERL_SRC} || $ENV{PERL_SRC} || $self->catdir($Config{archlibexp}, 'CORE');
my $header_dir = $self->{PERL_SRC} || $ENV{PERL_SRC} || File::Spec->catdir($Config{archlibexp}, 'CORE');
opendir my $dh, $header_dir
or die "Failed to opendir '$header_dir' to find header files: $!";

Expand Down
29 changes: 15 additions & 14 deletions lib/ExtUtils/MM_Unix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use Carp;
use ExtUtils::MakeMaker::Config;
use File::Basename qw(basename dirname);
use DirHandle;
use File::Spec ();

our %Config_Override;

Expand Down Expand Up @@ -97,9 +98,9 @@ something that used to be in here, look in MM_Any.

# So we don't have to keep calling the methods over and over again,
# we have these globals to cache the values. Faster and shrtr.
my $Curdir = __PACKAGE__->curdir;
my $Rootdir = __PACKAGE__->rootdir;
my $Updir = __PACKAGE__->updir;
my $Curdir = File::Spec->curdir;
my $Rootdir = File::Spec->rootdir;
my $Updir = File::Spec->updir;


=head2 Methods
Expand Down Expand Up @@ -1106,10 +1107,10 @@ WARNING
foreach my $dir (@$dirs){
next unless defined $dir; # $self->{PERL_SRC} may be undefined
my ($abs, $val);
if ($self->file_name_is_absolute($name)) { # /foo/bar
if (File::Spec->file_name_is_absolute($name)) { # /foo/bar
$abs = $name;
} elsif ($self->canonpath($name) eq
$self->canonpath(basename($name))) { # foo
} elsif (File::Spec->canonpath($name) eq
File::Spec->canonpath(basename($name))) { # foo
$abs = File::Spec->catfile($dir, $name);
} else { # foo/bar
$abs = File::Spec->catfile($Curdir, $name);
Expand Down Expand Up @@ -1241,7 +1242,7 @@ sub _fixin_replace_shebang {
}
else {
my (@absdirs)
= reverse grep { $self->file_name_is_absolute($_) } $self->path;
= reverse grep { File::Spec->file_name_is_absolute($_) } File::Spec->path;
$interpreter = '';

foreach my $dir (@absdirs) {
Expand Down Expand Up @@ -1962,21 +1963,21 @@ sub init_PERL {
my($self) = shift;

my @defpath = ();
foreach my $component ($self->{PERL_SRC}, $self->path(),
foreach my $component ($self->{PERL_SRC}, File::Spec->path(),
$Config{binexp})
{
push @defpath, $component if defined $component;
}

# Build up a set of file names (not command names).
my $thisperl = $self->canonpath($^X);
my $thisperl = File::Spec->canonpath($^X);
$thisperl .= $Config{exe_ext} unless
# VMS might have a file version # at the end
$Is{VMS} ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i
: $thisperl =~ m/$Config{exe_ext}$/i;

# We need a relative path to perl when in the core.
$thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
$thisperl = File::Spec->abs2rel($thisperl) if $self->{PERL_CORE};

my @perls = ($thisperl);
push @perls, map { "$_$Config{exe_ext}" }
Expand Down Expand Up @@ -2029,11 +2030,11 @@ sub init_PERL {
# sometimes.
$self->{ABSPERL} = $self->{PERL};
$has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//;
if( $self->file_name_is_absolute($self->{ABSPERL}) ) {
if( File::Spec->file_name_is_absolute($self->{ABSPERL}) ) {
$self->{ABSPERL} = '$(PERL)';
}
else {
$self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
$self->{ABSPERL} = File::Spec->rel2abs($self->{ABSPERL});

# Quote the perl command if it contains whitespace
$self->{ABSPERL} = $self->quote_literal($self->{ABSPERL})
Expand Down Expand Up @@ -3429,8 +3430,8 @@ sub static_lib {
my ($v, $d, $f) = File::Spec->splitpath($ext);
my @d = File::Spec->splitdir($d);
shift @d if $d[0] eq 'lib';
my $instdir = $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f);
my $instfile = $self->catfile($instdir, "$f\$(LIB_EXT)");
my $instdir = File::Spec->catdir('$(INST_ARCHLIB)', 'auto', @d, $f);
my $instfile = File::Spec->catfile($instdir, "$f\$(LIB_EXT)");
my $objfile = "$ext\$(OBJ_EXT)";
push @libs, [ $objfile, $instfile, $instdir ];
}
Expand Down
Loading