[Reproducible-commits] [libextutils-depends-perl] 36/187: - On MSWin32 and cygwin, find the link libraries of dependencies and put them into LIBS. - Add tests. - Correct typos in the documentation. - Remove debug spew.
Maria Valentina Marin Rodrigues
akira-guest at moszumanska.debian.org
Wed Jan 21 21:16:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
akira-guest pushed a commit to branch pu/reproducible_builds
in repository libextutils-depends-perl.
commit ff87a9e323fb259dd7d0d22ba3bc251e76cd5f90
Author: Torsten Schönfeld <tsch at src.gnome.org>
Date: Sun Mar 30 15:31:11 2008 +0000
- On MSWin32 and cygwin, find the link libraries of dependencies and
put them into LIBS.
- Add tests.
- Correct typos in the documentation.
- Remove debug spew.
svn path=/trunk/; revision=52
---
Changes | 8 +++-
lib/ExtUtils/Depends.pm | 64 +++++++++++++------------------
t/01_load.t | 8 ++--
t/02_save_load.t | 85 ++++++++++++++++++++++++++++++++++++++++++
t/03_deps.t | 31 +++++++++++++++
t/04_extra_libs.t | 26 +++++++++++++
t/inc/DepTest/DepTest.lib | 0
t/inc/DepTest/Install/.keep | 0
t/inc/DepTest/libDepTest.dll.a | 0
9 files changed, 179 insertions(+), 43 deletions(-)
diff --git a/Changes b/Changes
index fb1214b..91ae472 100644
--- a/Changes
+++ b/Changes
@@ -1,11 +1,15 @@
Revision history for Perl extension ExtUtils::Depends.
-0.--- Mon Apr 4 22:49:35 EDT 2005
- - Correct a typo in the synopsis.
+0.--- Sun Mar 30 17:29:35 CEST 2008
+ - On MSWin32 and cygwin, find the link libraries of dependencies and
+ put them into LIBS.
+ - Add tests.
+ - Correct typos in the documentation.
- In get_makefile_vars, comment out the code that put the installed
libraries into @OBJECT, which caused them to get deleted on
realclean.
- In Makefile.PL, don't use the bogus package "MAIN".
+ - Remove debug spew.
0.205 Sun Jan 23 13:20:14 EST 2005
- Disable the RPM-related postamble on Win32. The 'date' command
diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm
index 2df269b..fade176 100644
--- a/lib/ExtUtils/Depends.pm
+++ b/lib/ExtUtils/Depends.pm
@@ -7,6 +7,7 @@ package ExtUtils::Depends;
use strict;
use warnings;
use Carp;
+use File::Find;
use File::Spec;
use Data::Dumper;
@@ -114,7 +115,6 @@ sub save_config {
use IO::File;
my ($self, $filename) = @_;
- warn "Writing $filename\n";
my $file = IO::File->new (">".$filename)
or croak "can't open '$filename' for writing: $!\n";
@@ -182,10 +182,7 @@ sub load {
croak "No dependency information found for $dep"
unless $instpath;
- warn "Found $dep in $instpath\n";
-
if (not File::Spec->file_name_is_absolute ($instpath)) {
- warn "instpath is not absolute; using cwd...\n";
$instpath = File::Spec->rel2abs ($instpath);
}
@@ -281,11 +278,10 @@ sub get_makefile_vars {
my %vars = (
INC => join (' ', uniquify @incbits),
- LIBS => join (' ', uniquify @libsbits),
- #LIBS => join (' ', uniquify $self->find_extra_libs, @libsbits),
+ LIBS => join (' ', uniquify $self->find_extra_libs, @libsbits),
TYPEMAPS => [@typemaps],
);
- #push @OBJECT, $self->find_extra_libs;
+
# we don't want to provide these if there is no data in them;
# that way, the caller can still get default behavior out of
# MakeMaker when INC, LIBS and TYPEMAPS are all that are required.
@@ -301,39 +297,36 @@ sub get_makefile_vars {
%vars;
}
-# %Config linux win32 darwin
-# lib_ext .a .a .a
-# so so dll dylib
-# dlext so dll bundle
sub find_extra_libs {
my $self = shift;
- use File::Find;
- use Config;
- my @ret = ();
- my $ext = $Config{so};
- warn "on $^O, looking for extra '$ext\'s with which to link\n";
- #my $ext = $Config{dlext};
- # XXX what about linkage order? these should be in the most-dependent
- # first order, for old-style linkers... but when we get the dep names
- # from the hash, we have no idea about order.
+
+ my %mappers = (
+ MSWin32 => sub { $_[0] . '.lib' },
+ cygwin => sub { 'lib' . $_[0] . '.dll.a'},
+ );
+ my $mapper = $mappers{$^O};
+ return () unless defined $mapper;
+
+ my @found_libs = ();
foreach my $name (keys %{ $self->{deps} }) {
- my $dep = $self->{deps}{$name};
- (my $dllname = $name) =~ s/^.*:://;
- my $match = qr/$dllname\.$ext$/;
- my $l;
+ (my $stem = $name) =~ s/^.*:://;
+ my $lib = $mapper->($stem);
+ my $pattern = qr/$lib$/;
+
+ my $matching_file;
find (sub {
- $l = $File::Find::name
- if (not $l) && /$match/;
+ if ((not $matching_file) && /$pattern/) {;
+ $matching_file = $File::Find::name;
+ }
}, map { -d $_ ? ($_) : () } @INC); # only extant dirs
- if ($l && -f $l) {
- warn "found $l\n";
- push @ret, $l;
+
+ if ($matching_file && -f $matching_file) {
+ push @found_libs, $matching_file;
next;
}
- warn "can't find $dllname\.$ext for $name\n";
}
- #print Dumper(\@ret);
- return @ret;
+
+ return @found_libs;
}
1;
@@ -446,7 +439,7 @@ Add xs files to be compiled.
Add C files to be compiled.
-=item $depends->typemaps (@typemaps)
+=item $depends->add_typemaps (@typemaps)
Add typemap files to be used and installed.
@@ -529,11 +522,6 @@ C<get_deps> after calling C<add_deps> manually.
=head1 BUGS
-As written, this module expects that RTLD_GLOBAL works on your platform,
-which is not always true, most notably, on win32. We need to include a
-way to find the actual shared libraries created for extension modules
-so new extensions may be linked explicitly with them.
-
Version 0.2 discards some of the more esoteric features provided by the
older versions. As they were completely undocumented, and this module
has yet to reach 1.0, this may not exactly be a bug.
diff --git a/t/01_load.t b/t/01_load.t
index d2a1dd8..2004925 100644
--- a/t/01_load.t
+++ b/t/01_load.t
@@ -1,4 +1,6 @@
-use Test;
-BEGIN { plan tests => 1 }
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 1;
-use ExtUtils::Depends; ok(1);
+use_ok ('ExtUtils::Depends');
diff --git a/t/02_save_load.t b/t/02_save_load.t
new file mode 100644
index 0000000..b08010f
--- /dev/null
+++ b/t/02_save_load.t
@@ -0,0 +1,85 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More tests => 24;
+use ExtUtils::Depends;
+
+my $dep_info = ExtUtils::Depends->new ('DepTest');
+
+my $inc = '-Iinclude -I/usr/local/include -W -Wall -Werror -ansi';
+$dep_info->set_inc ($inc);
+
+my $libs = '-L/usr/local/lib -lfoobar';
+$dep_info->set_libs ($libs);
+
+my %pm_mapping = ('DepTest.pm' => 'build/DepTest.pm',
+ 'DepTest/Helper.pm' => 'build/DepTest/Helper.pm');
+$dep_info->add_pm (%pm_mapping);
+
+my @xs_files = qw(DepTestFoo.xs
+ DepTestBar.xs);
+$dep_info->add_xs (@xs_files);
+
+my @c_files = qw(dep-test-foo.c
+ dep-test-bar.c);
+$dep_info->add_c (@c_files);
+
+my @typemaps = qw(build/foo.typemap
+ build/bar.typemap);
+$dep_info->add_typemaps (@typemaps);
+
+my @installed_files = qw(dep.h
+ dep-private.h);
+$dep_info->install (@installed_files);
+
+$dep_info->save_config ('t/inc/DepTest/Install/Files.pm');
+
+# --------------------------------------------------------------------------- #
+
+my %vars = $dep_info->get_makefile_vars;
+is_deeply ($vars{TYPEMAPS}, \@typemaps);
+is ($vars{INC}, $inc);
+is ($vars{LIBS}, $libs);
+
+foreach my $pm (keys %pm_mapping) {
+ like ($vars{PM}{$pm}, qr/\Q$pm_mapping{$pm}\E/);
+}
+
+ok (exists $vars{PM}{'t/inc/DepTest/Install/Files.pm'});
+
+foreach my $file (@installed_files) {
+ like ($vars{PM}{$file}, qr/\Q$file\E/);
+}
+
+foreach my $xs_file (@xs_files) {
+ ok (exists $vars{XS}{$xs_file});
+}
+
+foreach my $file (@c_files, @xs_files) {
+ (my $stem = $file) =~ s/\.(?:c|xs)\z//;
+ like ($vars{OBJECT}, qr/\Q$stem\E/);
+ like ($vars{clean}{FILES}, qr/\Q$stem\E/);
+}
+
+# --------------------------------------------------------------------------- #
+
+use lib qw(t/inc);
+
+my $info = ExtUtils::Depends::load ('DepTest');
+
+my $install_part = qr|DepTest.Install|;
+like ($info->{inc}, $install_part);
+ok (-1 != index $info->{inc}, $inc);
+
+isa_ok ($info->{typemaps}, 'ARRAY');
+
+like ($info->{instpath}, $install_part);
+
+is_deeply ($info->{deps}, []);
+
+is ($info->{libs}, $libs);
+
+# --------------------------------------------------------------------------- #
+
+unlink 't/inc/DepTest/Install/Files.pm';
diff --git a/t/03_deps.t b/t/03_deps.t
new file mode 100644
index 0000000..51e9566
--- /dev/null
+++ b/t/03_deps.t
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+use ExtUtils::Depends;
+
+my $dep_info = ExtUtils::Depends->new ('DepTest');
+$dep_info->save_config ('t/inc/DepTest/Install/Files.pm');
+
+# --------------------------------------------------------------------------- #
+
+use lib qw(t/inc);
+
+my $info = ExtUtils::Depends->new ('UseTest', 'DepTest');
+
+my %deps = $info->get_deps;
+ok (exists $deps{DepTest});
+
+# --------------------------------------------------------------------------- #
+
+$info = ExtUtils::Depends->new ('UseTest');
+$info->add_deps ('DepTest');
+$info->load_deps;
+
+%deps = $info->get_deps;
+ok (exists $deps{DepTest});
+
+# --------------------------------------------------------------------------- #
+
+unlink 't/inc/DepTest/Install/Files.pm';
diff --git a/t/04_extra_libs.t b/t/04_extra_libs.t
new file mode 100644
index 0000000..90700f4
--- /dev/null
+++ b/t/04_extra_libs.t
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More;
+use ExtUtils::Depends;
+
+plan (($^O eq 'MSWin32' || $^O eq 'cygwin') ?
+ (tests => 1) :
+ (skip_all => 'test only applicable to MSWin32 and cygwin'));
+
+my $dep_info = ExtUtils::Depends->new ('DepTest');
+$dep_info->save_config ('t/inc/DepTest/Install/Files.pm');
+
+# --------------------------------------------------------------------------- #
+
+use lib qw(t/inc);
+
+my $use_info = ExtUtils::Depends->new ('UseTest', 'DepTest');
+my %vars = $use_info->get_makefile_vars;
+
+like ($vars{LIBS}, qr/DepTest/);
+
+# --------------------------------------------------------------------------- #
+
+unlink 't/inc/DepTest/Install/Files.pm';
diff --git a/t/inc/DepTest/DepTest.lib b/t/inc/DepTest/DepTest.lib
new file mode 100644
index 0000000..e69de29
diff --git a/t/inc/DepTest/Install/.keep b/t/inc/DepTest/Install/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/t/inc/DepTest/libDepTest.dll.a b/t/inc/DepTest/libDepTest.dll.a
new file mode 100644
index 0000000..e69de29
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/libextutils-depends-perl.git
More information about the Reproducible-commits
mailing list