Teach ExtUtils::CBuilder to handle mod2fname properly
authorBrian Fraser <fraserbn@gmail.com>
Wed, 27 Nov 2013 16:25:25 +0000 (13:25 -0300)
committerBrian Fraser <fraserbn@gmail.com>
Fri, 3 Jan 2014 22:45:06 +0000 (19:45 -0300)
15 files changed:
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/VMS.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/BCC.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/GCC.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Windows/MSVC.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/aix.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/cygwin.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/darwin.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/dec_osf.pm
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/os2.pm
dist/ExtUtils-CBuilder/t/01-basic.t
dist/ExtUtils-CBuilder/t/03-cplusplus.t

index 0e3e3fe..860447f 100644 (file)
@@ -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.
index 8014299..26b534c 100644 (file)
@@ -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 =
index f4d0c9d..523e9b4 100644 (file)
@@ -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 {
index 5c81593..79a7139 100644 (file)
@@ -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.
 
index 110906e..84d389f 100644 (file)
@@ -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
index f1dc3b8..2c8b196 100644 (file)
@@ -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) = @_;
index 4e1d677..bc99188 100644 (file)
@@ -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) = @_;
index 3b76757..d5d9d7b 100644 (file)
@@ -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) = @_;
index c9621b9..7f92c0c 100644 (file)
@@ -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 }
index 3da133a..d8c3cdb 100644 (file)
@@ -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
index 37d50a1..3c83c7d 100644 (file)
@@ -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 {
index 0d94a64..6246a26 100644 (file)
@@ -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;
index cc4b3ac..f813626 100644 (file)
@@ -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}";
index 70305af..c910802 100644 (file)
@@ -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,
index 589495b..e0c21e4 100644 (file)
@@ -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,