Skip to content

Commit

Permalink
Teach ExtUtils::CBuilder to handle mod2fname properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugmeir committed Jan 3, 2014
1 parent 90adfb5 commit 5e4a7f8
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 40 deletions.
2 changes: 1 addition & 1 deletion dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder.pm
Expand Up @@ -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.
Expand Down
21 changes: 17 additions & 4 deletions dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}


Expand Down Expand Up @@ -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 =
Expand Down
Expand Up @@ -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 {
Expand Down
18 changes: 1 addition & 17 deletions dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/VMS.pm
Expand Up @@ -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);
Expand Down Expand Up @@ -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.

Expand Down
Expand Up @@ -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
Expand Down
@@ -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) = @_;
Expand Down
@@ -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) = @_;
Expand Down
@@ -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) = @_;
Expand Down
Expand Up @@ -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 }
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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;
Expand Down
8 changes: 1 addition & 7 deletions dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/os2.pm
Expand Up @@ -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 }
Expand All @@ -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}";
Expand Down
2 changes: 1 addition & 1 deletion dist/ExtUtils-CBuilder/t/01-basic.t
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion dist/ExtUtils-CBuilder/t/03-cplusplus.t
Expand Up @@ -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,
Expand Down

0 comments on commit 5e4a7f8

Please sign in to comment.