From: Brian Fraser Date: Wed, 27 Nov 2013 16:25:25 +0000 (-0300) Subject: Teach ExtUtils::CBuilder to handle mod2fname properly X-Git-Tag: upstream/5.20.0~860 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e4a7f813da751856f841bf7729a625911972885;p=platform%2Fupstream%2Fperl.git Teach ExtUtils::CBuilder to handle mod2fname properly --- diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm index 0e3e3fe..860447f 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 8014299..26b534c 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 f4d0c9d..523e9b4 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 5c815933..79a7139 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 110906e..84d389f 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 f1dc3b8..2c8b196 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 4e1d677..bc99188 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 3b76757..d5d9d7b 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 c9621b9..7f92c0c 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 3da133a..d8c3cdb 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 37d50a1..3c83c7d 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 0d94a64..6246a26 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 cc4b3ac..f813626 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 70305af..c910802 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 589495b..e0c21e4 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,