From 5e4a7f813da751856f841bf7729a625911972885 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Wed, 27 Nov 2013 13:25:25 -0300 Subject: Teach ExtUtils::CBuilder to handle mod2fname properly --- dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm | 2 +- .../ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm | 21 +++++++++++++++++---- .../lib/ExtUtils/CBuilder/Platform/Unix.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/VMS.pm | 18 +----------------- .../lib/ExtUtils/CBuilder/Platform/Windows.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/Windows/BCC.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/Windows/GCC.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/Windows/MSVC.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/aix.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/cygwin.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/darwin.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/dec_osf.pm | 2 +- .../lib/ExtUtils/CBuilder/Platform/os2.pm | 8 +------- dist/ExtUtils-CBuilder/t/01-basic.t | 2 +- dist/ExtUtils-CBuilder/t/03-cplusplus.t | 2 +- 15 files changed, 31 insertions(+), 40 deletions(-) diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm index 0e3e3fe5b8..860447fb33 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm @@ -6,7 +6,7 @@ use File::Basename (); use Perl::OSType qw/os_type/; use vars qw($VERSION @ISA); -$VERSION = '0.280212'; +$VERSION = '0.280213'; $VERSION = eval $VERSION; # We only use this once - don't waste a symbol table entry on it. diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm index 8014299dbb..26b534ca3b 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm @@ -10,7 +10,7 @@ use IPC::Cmd qw(can_run); use File::Temp qw(tempfile); use vars qw($VERSION); -$VERSION = '0.280212'; +$VERSION = '0.280213'; # More details about C/C++ compilers: # http://developers.sun.com/sunstudio/documentation/product/compiler.jsp @@ -222,10 +222,23 @@ sub have_cplusplus { } sub lib_file { - my ($self, $dl_file) = @_; + my ($self, $dl_file, %args) = @_; $dl_file =~ s/\.[^.]+$//; $dl_file =~ tr/"//d; - return "$dl_file.$self->{config}{dlext}"; + + if (defined $args{module_name} and length $args{module_name}) { + # Need to create with the same name as DynaLoader will load with. + require DynaLoader; + if (defined &DynaLoader::mod2fname) { + my $lib = DynaLoader::mod2fname([split /::/, $args{module_name}]); + my ($dev, $lib_dir, undef) = File::Spec->splitpath($dl_file); + $dl_file = File::Spec->catpath($dev, $lib_dir, $lib); + } + } + + $dl_file .= ".$self->{config}{dlext}"; + + return $dl_file; } @@ -287,7 +300,7 @@ sub _do_link { my $objects = delete $args{objects}; $objects = [$objects] unless ref $objects; - my $out = $args{$type} || $self->$type($objects->[0]); + my $out = $args{$type} || $self->$type($objects->[0], %args); my @temp_files; @temp_files = diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm index f4d0c9d9ab..523e9b4732 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm @@ -4,7 +4,7 @@ use strict; use ExtUtils::CBuilder::Base; use vars qw($VERSION @ISA); -$VERSION = '0.280212'; +$VERSION = '0.280213'; @ISA = qw(ExtUtils::CBuilder::Base); sub link_executable { diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/VMS.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/VMS.pm index 5c8159333b..79a7139630 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/VMS.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/VMS.pm @@ -4,7 +4,7 @@ use strict; use ExtUtils::CBuilder::Base; use vars qw($VERSION @ISA); -$VERSION = '0.280212'; +$VERSION = '0.280213'; @ISA = qw(ExtUtils::CBuilder::Base); use File::Spec::Functions qw(catfile catdir); @@ -118,22 +118,6 @@ sub arg_share_object_file { return ("$self->{config}{lddlflags}=$file"); } - -sub lib_file { - my ($self, $dl_file) = @_; - $dl_file =~ s/\.[^.]+$//; - $dl_file =~ tr/"//d; - $dl_file = $dl_file .= '.' . $self->{config}{dlext}; - - # Need to create with the same name as DynaLoader will load with. - if (defined &DynaLoader::mod2fname) { - my ($dev,$dir,$file) = File::Spec->splitpath($dl_file); - $file = DynaLoader::mod2fname([$file]); - $dl_file = File::Spec->catpath($dev,$dir,$file); - } - return $dl_file; -} - # The following is reproduced almost verbatim from ExtUtils::Liblist::Kid::_vms_ext. # We can't just call that because it's tied up with the MakeMaker object hierarchy. diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows.pm index 110906e521..84d389ff3c 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows.pm @@ -10,7 +10,7 @@ use ExtUtils::CBuilder::Base; use IO::File; use vars qw($VERSION @ISA); -$VERSION = '0.280212'; +$VERSION = '0.280213'; @ISA = qw(ExtUtils::CBuilder::Base); =begin comment diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/BCC.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/BCC.pm index f1dc3b8fc8..2c8b196a17 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/BCC.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/BCC.pm @@ -1,7 +1,7 @@ package ExtUtils::CBuilder::Platform::Windows::BCC; use vars qw($VERSION); -$VERSION = '0.280212'; +$VERSION = '0.280213'; sub format_compiler_cmd { my ($self, %spec) = @_; diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/GCC.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/GCC.pm index 4e1d67783e..bc991883b7 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/GCC.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/GCC.pm @@ -1,7 +1,7 @@ package ExtUtils::CBuilder::Platform::Windows::GCC; use vars qw($VERSION); -$VERSION = '0.280212'; +$VERSION = '0.280213'; sub format_compiler_cmd { my ($self, %spec) = @_; diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/MSVC.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/MSVC.pm index 3b767575da..d5d9d7b4c5 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/MSVC.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/MSVC.pm @@ -1,7 +1,7 @@ package ExtUtils::CBuilder::Platform::Windows::MSVC; use vars qw($VERSION); -$VERSION = '0.280212'; +$VERSION = '0.280213'; sub arg_exec_file { my ($self, $file) = @_; diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/aix.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/aix.pm index c9621b946c..7f92c0cd4b 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/aix.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/aix.pm @@ -5,7 +5,7 @@ use ExtUtils::CBuilder::Platform::Unix; use File::Spec; use vars qw($VERSION @ISA); -$VERSION = '0.280212'; +$VERSION = '0.280213'; @ISA = qw(ExtUtils::CBuilder::Platform::Unix); sub need_prelink { 1 } diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/cygwin.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/cygwin.pm index 3da133a031..d8c3cdb039 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/cygwin.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/cygwin.pm @@ -5,7 +5,7 @@ use File::Spec; use ExtUtils::CBuilder::Platform::Unix; use vars qw($VERSION @ISA); -$VERSION = '0.280212'; +$VERSION = '0.280213'; @ISA = qw(ExtUtils::CBuilder::Platform::Unix); # TODO: If a specific exe_file name is requested, if the exe created diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/darwin.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/darwin.pm index 37d50a1b0d..3c83c7d139 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/darwin.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/darwin.pm @@ -4,7 +4,7 @@ use strict; use ExtUtils::CBuilder::Platform::Unix; use vars qw($VERSION @ISA); -$VERSION = '0.280212'; +$VERSION = '0.280213'; @ISA = qw(ExtUtils::CBuilder::Platform::Unix); sub compile { diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/dec_osf.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/dec_osf.pm index 0d94a6455d..6246a26d3b 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/dec_osf.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/dec_osf.pm @@ -6,7 +6,7 @@ use File::Spec; use vars qw($VERSION @ISA); @ISA = qw(ExtUtils::CBuilder::Platform::Unix); -$VERSION = '0.280212'; +$VERSION = '0.280213'; sub link_executable { my $self = shift; diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/os2.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/os2.pm index cc4b3acce9..f813626d79 100644 --- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/os2.pm +++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/os2.pm @@ -4,7 +4,7 @@ use strict; use ExtUtils::CBuilder::Platform::Unix; use vars qw($VERSION @ISA); -$VERSION = '0.280212'; +$VERSION = '0.280213'; @ISA = qw(ExtUtils::CBuilder::Platform::Unix); sub need_prelink { 1 } @@ -29,18 +29,12 @@ sub _do_link { if ($how eq 'lib_file' and (defined $args{module_name} and length $args{module_name})) { - # DynaLoader::mod2fname() is a builtin func - my $lib = DynaLoader::mod2fname([split /::/, $args{module_name}]); - # Now know the basename, find directory parts via lib_file, or objects my $objs = ( (ref $args{objects}) ? $args{objects} : [$args{objects}] ); my $near_obj = $self->lib_file(@$objs); - my $ref_file = ( defined $args{lib_file} ? $args{lib_file} : $near_obj ); - my $lib_dir = ($ref_file =~ m,(.*)[/\\],s ? "$1/" : '' ); my $exp_dir = ($near_obj =~ m,(.*)[/\\],s ? "$1/" : '' ); $args{dl_file} = $1 if $near_obj =~ m,(.*)\.,s; # put ExportList near OBJ - $args{lib_file} = "$lib_dir$lib.$self->{config}{dlext}"; # DLL file # XXX _do_link does not have place to put libraries? push @$objs, $self->perl_inc() . "/libperl$self->{config}{lib_ext}"; diff --git a/dist/ExtUtils-CBuilder/t/01-basic.t b/dist/ExtUtils-CBuilder/t/01-basic.t index 70305afb70..c910802902 100644 --- a/dist/ExtUtils-CBuilder/t/01-basic.t +++ b/dist/ExtUtils-CBuilder/t/01-basic.t @@ -44,7 +44,7 @@ ok 1; is $object_file, $b->compile(source => $source_file); -$lib_file = $b->lib_file($object_file); +$lib_file = $b->lib_file($object_file, module_name => 'basict'); ok 1; my ($lib, @temps) = $b->link(objects => $object_file, diff --git a/dist/ExtUtils-CBuilder/t/03-cplusplus.t b/dist/ExtUtils-CBuilder/t/03-cplusplus.t index 589495b7d2..e0c21e4126 100644 --- a/dist/ExtUtils-CBuilder/t/03-cplusplus.t +++ b/dist/ExtUtils-CBuilder/t/03-cplusplus.t @@ -43,7 +43,7 @@ ok 1; is $object_file, $b->compile(source => $source_file, 'C++' => 1); -$lib_file = $b->lib_file($object_file); +$lib_file = $b->lib_file($object_file, module_name => 'cplust'); ok 1; my ($lib, @temps) = $b->link(objects => $object_file, -- cgit v1.2.1