Codebase list libextutils-depends-perl / 90d71be
Merge branch 'remove-hack' into 'master' Remove hack (cf https://rt.cpan.org/Ticket/Display.html?id=45224) Further to discussion on https://rt.cpan.org/Ticket/Display.html?id=45224, the hijacking of EUMM's `static_lib` method is now obsolete, as well as causing problems. This PR removes that hijacking, as well as a couple of code tidy-ups. See merge request GNOME/perl-extutils-depends!2 Torsten Schönfeld 2 years ago
3 changed file(s) with 14 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
77 'File::Spec' => 0,
88 'Data::Dumper' => 0,
99 'IO::File' => 0,
10 'ExtUtils::MakeMaker' => '7.44', # no need for Win32 static_lib hack
1011 );
1112
1213 my %meta_merge = (
151151
152152 sub Inline {
153153 my (\$class, \$lang) = \@_;
154 if (\$lang ne 'C') {
155 warn "Warning: Inline hints not available for \$lang language\n";
156 return;
157 }
158154 +{ map { (uc(\$_) => \$self->{\$_}) } qw(inc libs typemaps) };
159155 }
160156 EOT
228224
229225 sub load_deps {
230226 my $self = shift;
231 my @load = grep { not $self->{deps}{$_} } keys %{ $self->{deps} };
227 my @load = grep !$self->{deps}{$_}, keys %{ $self->{deps} };
228 my %in_load; @in_load{@load} = ();
232229 foreach my $d (@load) {
233 my $dep = load ($d);
234 $self->{deps}{$d} = $dep;
235 if ($dep->{deps}) {
236 foreach my $childdep (@{ $dep->{deps} }) {
237 push @load, $childdep
238 unless
239 $self->{deps}{$childdep}
240 or
241 grep {$_ eq $childdep} @load;
242 }
243 }
230 $self->{deps}{$d} = my $dep = load($d);
231 my @new_deps = grep !($self->{deps}{$_} || exists $in_load{$_}),
232 @{ $dep->{deps} || [] };
233 push @load, @new_deps;
234 @in_load{@new_deps} = ();
244235 }
245236 }
246237
247238 sub uniquify {
248239 my %seen;
249 # we use a seen hash, but also keep indices to preserve
250 # first-seen order.
251 my $i = 0;
252 foreach (@_) {
253 $seen{$_} = ++$i
254 unless exists $seen{$_};
255 }
256 #warn "stripped ".(@_ - (keys %seen))." redundant elements\n";
257 sort { $seen{$a} <=> $seen{$b} } keys %seen;
258 }
259
240 grep !$seen{$_}++, @_;
241 }
260242
261243 sub get_makefile_vars {
262244 my $self = shift;
385367 return @found_libs;
386368 }
387369
388 # Hook into ExtUtils::MakeMaker to create an import library on MSWin32 when gcc
389 # is used. FIXME: Ideally, this should be done in EU::MM itself.
390 package # wrap to fool the CPAN indexer
391 ExtUtils::MM;
392 use Config;
393 sub static_lib {
394 my $base = shift->SUPER::static_lib(@_);
395
396 return $base unless $^O =~ /MSWin32/ && $Config{cc} =~ /\bgcc\b/i;
397
398 my $DLLTOOL = $Config{'dlltool'} || 'dlltool';
399
400 return <<"__EOM__"
401 # This isn't actually a static lib, it just has the same name on Win32.
402 \$(INST_DYNAMIC_LIB): \$(INST_DYNAMIC)
403 $DLLTOOL --def \$(EXPORT_LIST) --output-lib \$\@ --dllname \$(DLBASE).\$(DLEXT) \$(INST_DYNAMIC)
404
405 dynamic:: \$(INST_DYNAMIC_LIB)
406 __EOM__
407 }
408
409 1;
410
411370 __END__
412371
413372 =head1 NAME
11 use strict;
22 use warnings;
33
4 use Test::More tests => 40;
4 use Test::More tests => 41;
55
66 use FindBin;
77 use lib "$FindBin::Bin/lib";
5050 open my $iffh, '>>', $IFpm or die "write $IFpm: $!";
5151 print $iffh qq{\nwarn "LOADING\\n";\n1;\n};
5252 undef $iffh;
53
54 # test utility function
55 is_deeply [ExtUtils::Depends::uniquify(qw(a c b c a b))], [qw(a c b)];
5356
5457 # --------------------------------------------------------------------------- #
5558