| 1 | #line 1 | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/ExtUtils-Depends/lib/ExtUtils/Depends.pm,v 1.20 2008/09/06 18:13:47 kaffeetisch Exp $ | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | package ExtUtils::Depends; | ||||||||||||||||||||||||||||
| 7 | 1 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use File::Find; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | use Data::Dumper; | ||||||||||||||||||||||||||||
| 14 | 1 | ||||||||||||||||||||||||||||
| 15 | our $VERSION = '0.301'; | ||||||||||||||||||||||||||||
| 16 | 1 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=15.4
| |||||||||||||||||||||||||||||
| 17 | 1 | sub import { | |||||||||||||||||||||||||||
| 18 | 1 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 0 | ▶ | return unless @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | die "$class version $_[0] is required--this is only version $VERSION" | ||||||||||||||||||||||||||||
| 21 | if $VERSION < $_[0]; | ||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 1 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 1 | sub new { | |||||||||||||||||||||||||||
| 25 | 1 | my ($class, $name, @deps) = @_; | |||||||||||||||||||||||||||
| 26 | my $self = bless { | ||||||||||||||||||||||||||||
| 27 | name => $name, | ||||||||||||||||||||||||||||
| 28 | deps => {}, | ||||||||||||||||||||||||||||
| 29 | inc => [], | ||||||||||||||||||||||||||||
| 30 | libs => '', | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | pm => {}, | ||||||||||||||||||||||||||||
| 33 | typemaps => [], | ||||||||||||||||||||||||||||
| 34 | xs => [], | ||||||||||||||||||||||||||||
| 35 | c => [], | ||||||||||||||||||||||||||||
| 36 | }, $class; | ||||||||||||||||||||||||||||
| 37 | 1 | ||||||||||||||||||||||||||||
| 38 | $self->add_deps (@deps); | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # attempt to load these now, so we'll find out as soon as possible | ||||||||||||||||||||||||||||
| 41 | # whether the dependencies are valid. we'll load them again in | ||||||||||||||||||||||||||||
| 42 | 1 | # get_makefile_vars to catch any added between now and then. | |||||||||||||||||||||||||||
| 43 | $self->load_deps; | ||||||||||||||||||||||||||||
| 44 | 1 | ||||||||||||||||||||||||||||
| 45 | return $self; | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 1 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
add_deps: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | 1 | sub add_deps { | |||||||||||||||||||||||||||
| 49 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 50 | foreach my $d (@_) { | ||||||||||||||||||||||||||||
| 51 | 1 | ▶ | $self->{deps}{$d} = undef | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | unless $self->{deps}{$d}; | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 0 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
get_deps: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 0 | sub get_deps { | |||||||||||||||||||||||||||
| 57 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 58 | $self->load_deps; # just in case | ||||||||||||||||||||||||||||
| 59 | 0 | ||||||||||||||||||||||||||||
| 60 | return %{$self->{deps}}; | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | 1 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
set_inc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | 1 | sub set_inc { | |||||||||||||||||||||||||||
| 64 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 65 | push @{ $self->{inc} }, @_; | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
set_libs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | 0 | sub set_libs { | |||||||||||||||||||||||||||
| 69 | 0 | my ($self, $newlibs) = @_; | |||||||||||||||||||||||||||
| 70 | $self->{libs} = $newlibs; | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | 0 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
add_pm: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 0 | sub add_pm { | |||||||||||||||||||||||||||
| 74 | 0 | ▶ | my ($self, %pm) = @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | while (my ($key, $value) = each %pm) { | |||||||||||||||||||||||||||
| 76 | $self->{pm}{$key} = $value; | ||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | 0 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
_listkey_add_list: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 80 | 0 | sub _listkey_add_list { | |||||||||||||||||||||||||||
| 81 | 0 | ▶ | my ($self, $key, @list) = @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | $self->{$key} = [] unless $self->{$key}; | |||||||||||||||||||||||||||
| 83 | push @{ $self->{$key} }, @list; | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | 0 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
add_xs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub add_xs { shift->_listkey_add_list ('xs', @_) } | ||||||||||||||||||||||||||
|
Subroutine
add_c: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub add_c { shift->_listkey_add_list ('c', @_) } | ||||||||||||||||||||||||||
|
Subroutine
add_typemaps: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 88 | 0 | sub add_typemaps { | |||||||||||||||||||||||||||
| 89 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 90 | 0 | $self->_listkey_add_list ('typemaps', @_); | |||||||||||||||||||||||||||
| 91 | $self->install (@_); | ||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | # no-op, only used for source back-compat | ||||||||||||||||||||||||||
|
Subroutine
add_headers: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | sub add_headers { carp "add_headers() is a no-op" } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | ####### PRIVATE | ||||||||||||||||||||||||||
|
Subroutine
basename: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 98 | sub basename { (File::Spec->splitdir ($_[0]))[-1] } | ||||||||||||||||||||||||||||
| 99 | 0 | ▶ | # get the name in Makefile syntax. | ||||||||||||||||||||||||||
|
Subroutine
installed_filename: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 100 | 0 | sub installed_filename { | |||||||||||||||||||||||||||
| 101 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 102 | return '$(INST_ARCHLIB)/$(FULLEXT)/Install/'.basename ($_[0]); | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | 0 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
install: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 105 | sub install { | ||||||||||||||||||||||||||||
| 106 | # install things by adding them to the hash of pm files that gets | ||||||||||||||||||||||||||||
| 107 | 0 | # passed through WriteMakefile's PM key. | |||||||||||||||||||||||||||
| 108 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 109 | 0 | foreach my $f (@_) { | |||||||||||||||||||||||||||
| 110 | $self->add_pm ($f, $self->installed_filename ($f)); | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | 0 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
save_config: not called CC=2 SCAR=13.4
Pod
documented
| |||||||||||||||||||||||||||||
| 114 | 1 | ▶ | sub save_config { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 115 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 116 | use IO::File; | ||||||||||||||||||||||||||||
| 117 | 0 | ||||||||||||||||||||||||||||
| 118 | my ($self, $filename) = @_; | ||||||||||||||||||||||||||||
| 119 | 0 | ▶ | |||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | my $file = IO::File->new (">".$filename) | ||||||||||||||||||||||||||||
| 121 | or croak "can't open '$filename' for writing: $!\n"; | ||||||||||||||||||||||||||||
| 122 | 0 | ||||||||||||||||||||||||||||
| 123 | print $file "package $self->{name}\::Install::Files;\n\n"; | ||||||||||||||||||||||||||||
| 124 | # for modern stuff | ||||||||||||||||||||||||||||
| 125 | 0 | print $file "".Data::Dumper->Dump([{ | |||||||||||||||||||||||||||
| 126 | inc => join (" ", @{ $self->{inc} }), | ||||||||||||||||||||||||||||
| 127 | 0 | libs => $self->{libs}, | |||||||||||||||||||||||||||
| 128 | 0 | typemaps => [ map { basename $_ } @{ $self->{typemaps} } ], | |||||||||||||||||||||||||||
| 129 | deps => [keys %{ $self->{deps} }], | ||||||||||||||||||||||||||||
| 130 | }], ['self']); | ||||||||||||||||||||||||||||
| 131 | 0 | # for ancient stuff | |||||||||||||||||||||||||||
| 132 | 0 | print $file "\n\n# this is for backwards compatiblity\n"; | |||||||||||||||||||||||||||
| 133 | 0 | print $file "\@deps = \@{ \$self->{deps} };\n"; | |||||||||||||||||||||||||||
| 134 | 0 | print $file "\@typemaps = \@{ \$self->{typemaps} };\n"; | |||||||||||||||||||||||||||
| 135 | 0 | print $file "\$libs = \$self->{libs};\n"; | |||||||||||||||||||||||||||
| 136 | print $file "\$inc = \$self->{inc};\n"; | ||||||||||||||||||||||||||||
| 137 | # this is riduculous, but old versions of ExtUtils::Depends take | ||||||||||||||||||||||||||||
| 138 | # first $loadedmodule::CORE and then $INC{$file} --- the fallback | ||||||||||||||||||||||||||||
| 139 | # includes the Filename.pm, which is not useful. so we must add | ||||||||||||||||||||||||||||
| 140 | # this crappy code. we don't worry about portable pathnames, | ||||||||||||||||||||||||||||
| 141 | 0 | # as the old code didn't either. | |||||||||||||||||||||||||||
| 142 | 0 | (my $mdir = $self->{name}) =~ s{::}{/}g; | |||||||||||||||||||||||||||
| 143 | print $file <<"EOT"; | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | \$CORE = undef; | ||||||||||||||||||||||||||||
| 146 | foreach (\@INC) { | ||||||||||||||||||||||||||||
| 147 | if ( -f \$_ . "/$mdir/Install/Files.pm") { | ||||||||||||||||||||||||||||
| 148 | \$CORE = \$_ . "/$mdir/Install/"; | ||||||||||||||||||||||||||||
| 149 | last; | ||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | EOT | ||||||||||||||||||||||||||||
| 153 | 0 | ||||||||||||||||||||||||||||
| 154 | print $file "\n1;\n"; | ||||||||||||||||||||||||||||
| 155 | 0 | ||||||||||||||||||||||||||||
| 156 | close $file; | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | # we need to ensure that the file we just created gets put into | ||||||||||||||||||||||||||||
| 159 | # the install dir with everything else. | ||||||||||||||||||||||||||||
| 160 | 0 | #$self->install ($filename); | |||||||||||||||||||||||||||
| 161 | $self->add_pm ($filename, $self->installed_filename ('Files.pm')); | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | 1 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
load: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||
| 164 | 1 | sub load { | |||||||||||||||||||||||||||
| 165 | 1 | my $dep = shift; | |||||||||||||||||||||||||||
| 166 | 1 | my @pieces = split /::/, $dep; | |||||||||||||||||||||||||||
| 167 | 1 | my @suffix = qw/ Install Files /; | |||||||||||||||||||||||||||
| 168 | 1 | my $relpath = File::Spec->catfile (@pieces, @suffix) . '.pm'; | |||||||||||||||||||||||||||
| 169 | 1 | ▶ | my $depinstallfiles = join "::", @pieces, @suffix; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 1 | eval { | |||||||||||||||||||||||||||
| 171 | require $relpath | ||||||||||||||||||||||||||||
| 172 | } or die " *** Can't load dependency information for $dep:\n $@\n"; | ||||||||||||||||||||||||||||
| 173 | # | ||||||||||||||||||||||||||||
| 174 | #print Dumper(\%INC); | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 1 | # effectively $instpath = dirname($INC{$relpath}) | |||||||||||||||||||||||||||
| 177 | 1 | @pieces = File::Spec->splitdir ($INC{$relpath}); | |||||||||||||||||||||||||||
| 178 | 1 | pop @pieces; | |||||||||||||||||||||||||||
| 179 | my $instpath = File::Spec->catdir (@pieces); | ||||||||||||||||||||||||||||
| 180 | 1 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 181 | no strict; | ||||||||||||||||||||||||||||
| 182 | 1 | ▶ | |||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | croak "No dependency information found for $dep" | ||||||||||||||||||||||||||||
| 184 | unless $instpath; | ||||||||||||||||||||||||||||
| 185 | 1 | ▶ | |||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 0 | if (not File::Spec->file_name_is_absolute ($instpath)) { | |||||||||||||||||||||||||||
| 187 | $instpath = File::Spec->rel2abs ($instpath); | ||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 0 | my @typemaps = map { | |||||||||||||||||||||||||||
| 191 | 1 | File::Spec->rel2abs ($_, $instpath) | |||||||||||||||||||||||||||
| 192 | } @{"$depinstallfiles\::typemaps"}; | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | { | ||||||||||||||||||||||||||||
| 195 | instpath => $instpath, | ||||||||||||||||||||||||||||
| 196 | 1 | typemaps => \@typemaps, | |||||||||||||||||||||||||||
| 197 | 1 | ▶ | inc => "-I$instpath ".${"$depinstallfiles\::inc"}, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | libs => ${"$depinstallfiles\::libs"}, | ||||||||||||||||||||||||||||
| 199 | # this will not exist when loading files from old versions | ||||||||||||||||||||||||||||
| 200 | 1 | # of ExtUtils::Depends. | |||||||||||||||||||||||||||
| 201 | 1 | (exists ${"$depinstallfiles\::"}{deps} | |||||||||||||||||||||||||||
| 202 | ? (deps => \@{"$depinstallfiles\::deps"}) | ||||||||||||||||||||||||||||
| 203 | : ()), | ||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | 2 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
load_deps: called CC=6 SCAR=21.6
Pod
documented
| |||||||||||||||||||||||||||||
| 207 | 2 | sub load_deps { | |||||||||||||||||||||||||||
| 208 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 209 | 2 | my @load = grep { not $self->{deps}{$_} } keys %{ $self->{deps} }; | |||||||||||||||||||||||||||
| 210 | 1 | foreach my $d (@load) { | |||||||||||||||||||||||||||
| 211 | 1 | my $dep = load ($d); | |||||||||||||||||||||||||||
| 212 | 1 | ▶ | $self->{deps}{$d} = $dep; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 1 | if ($dep->{deps}) { | |||||||||||||||||||||||||||
| 214 | foreach my $childdep (@{ $dep->{deps} }) { | ||||||||||||||||||||||||||||
| 215 | push @load, $childdep | ||||||||||||||||||||||||||||
| 216 | unless | ||||||||||||||||||||||||||||
| 217 | $self->{deps}{$childdep} | ||||||||||||||||||||||||||||
| 218 | 0 | ▶ | or | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"deps"}{$childdep} or grep {$_ eq $childdep;} @load
MC/DC0%0/2
$self->{"deps"}{$childdep} or grep {$_ eq $childdep;} @load
$self->{"deps"}{$childdep}
grep {$_ eq $childdep;} @load
Truth table0%0/3
A or B
A= $self->{"deps"}{$childdep}B= grep {$_ eq $childdep;} @load
| |||||||||||||||||||||||||||||
| 219 | grep {$_ eq $childdep} @load; | ||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | 2 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
uniquify: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 225 | 2 | sub uniquify { | |||||||||||||||||||||||||||
| 226 | my %seen; | ||||||||||||||||||||||||||||
| 227 | # we use a seen hash, but also keep indices to preserve | ||||||||||||||||||||||||||||
| 228 | 2 | # first-seen order. | |||||||||||||||||||||||||||
| 229 | 2 | my $i = 0; | |||||||||||||||||||||||||||
| 230 | foreach (@_) { | ||||||||||||||||||||||||||||
| 231 | 2 | ▶ | $seen{$_} = ++$i | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | unless exists $seen{$_}; | ||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | 2 | #warn "stripped ".(@_ - (keys %seen))." redundant elements\n"; | |||||||||||||||||||||||||||
| 235 | sort { $seen{$a} <=> $seen{$b} } keys %seen; | ||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 1 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
get_makefile_vars: called CC=12 SCAR=27.9
Pod
documented
| |||||||||||||||||||||||||||||
| 239 | 1 | sub get_makefile_vars { | |||||||||||||||||||||||||||
| 240 | my $self = shift; | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | # collect and uniquify things from the dependencies. | ||||||||||||||||||||||||||||
| 243 | 1 | # first, ensure they are completely loaded. | |||||||||||||||||||||||||||
| 244 | $self->load_deps; | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 1 | ##my @defbits = map { split } @{ $self->{defines} }; | |||||||||||||||||||||||||||
| 247 | 1 | my @incbits = map { split } @{ $self->{inc} }; | |||||||||||||||||||||||||||
| 248 | 1 | my @libsbits = split /\s+/, $self->{libs}; | |||||||||||||||||||||||||||
| 249 | 1 | my @typemaps = @{ $self->{typemaps} }; | |||||||||||||||||||||||||||
| 250 | 1 | foreach my $d (keys %{ $self->{deps} }) { | |||||||||||||||||||||||||||
| 251 | my $dep = $self->{deps}{$d}; | ||||||||||||||||||||||||||||
| 252 | 0 | ▶ | #push @defbits, @{ $dep->{defines} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 1 | ▶ | push @incbits, @{ $dep->{defines} } if $dep->{defines}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 1 | ▶ | push @incbits, split /\s+/, $dep->{inc} if $dep->{inc}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 1 | ▶ | push @libsbits, split /\s+/, $dep->{libs} if $dep->{libs}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | push @typemaps, @{ $dep->{typemaps} } if $dep->{typemaps}; | ||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 1 | # we have a fair bit of work to do for the xs files... | |||||||||||||||||||||||||||
| 260 | 1 | my @clean = (); | |||||||||||||||||||||||||||
| 261 | 1 | my @OBJECT = (); | |||||||||||||||||||||||||||
| 262 | 1 | my %XS = (); | |||||||||||||||||||||||||||
| 263 | 0 | foreach my $xs (@{ $self->{xs} }) { | |||||||||||||||||||||||||||
| 264 | 0 | (my $c = $xs) =~ s/\.xs$/\.c/i; | |||||||||||||||||||||||||||
| 265 | 0 | (my $o = $xs) =~ s/\.xs$/\$(OBJ_EXT)/i; | |||||||||||||||||||||||||||
| 266 | 0 | $XS{$xs} = $c; | |||||||||||||||||||||||||||
| 267 | push @OBJECT, $o; | ||||||||||||||||||||||||||||
| 268 | # according to the MakeMaker manpage, the C files listed in | ||||||||||||||||||||||||||||
| 269 | 0 | # XS will be added automatically to the list of cleanfiles. | |||||||||||||||||||||||||||
| 270 | push @clean, $o; | ||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 1 | # we may have C files, as well: | |||||||||||||||||||||||||||
| 274 | 0 | foreach my $c (@{ $self->{c} }) { | |||||||||||||||||||||||||||
| 275 | 0 | (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i; | |||||||||||||||||||||||||||
| 276 | 0 | push @OBJECT, $o; | |||||||||||||||||||||||||||
| 277 | push @clean, $o; | ||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | 1 | ||||||||||||||||||||||||||||
| 280 | my %vars = ( | ||||||||||||||||||||||||||||
| 281 | INC => join (' ', uniquify @incbits), | ||||||||||||||||||||||||||||
| 282 | LIBS => join (' ', uniquify $self->find_extra_libs, @libsbits), | ||||||||||||||||||||||||||||
| 283 | TYPEMAPS => [@typemaps], | ||||||||||||||||||||||||||||
| 284 | ); | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | # we don't want to provide these if there is no data in them; | ||||||||||||||||||||||||||||
| 287 | # that way, the caller can still get default behavior out of | ||||||||||||||||||||||||||||
| 288 | # MakeMaker when INC, LIBS and TYPEMAPS are all that are required. | ||||||||||||||||||||||||||||
| 289 | 1 | ▶ | $vars{PM} = $self->{pm} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 1 | ▶ | if %{ $self->{pm} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 291 | $vars{clean} = { FILES => join (" ", @clean), } | ||||||||||||||||||||||||||||
| 292 | 1 | ▶ | if @clean; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | $vars{OBJECT} = join (" ", @OBJECT) | ||||||||||||||||||||||||||||
| 294 | 1 | ▶ | if @OBJECT; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | $vars{XS} = \%XS | ||||||||||||||||||||||||||||
| 296 | if %XS; | ||||||||||||||||||||||||||||
| 297 | 1 | ||||||||||||||||||||||||||||
| 298 | %vars; | ||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | 1 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
find_extra_libs: called CC=6 SCAR=33.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 301 | 1 | sub find_extra_libs { | |||||||||||||||||||||||||||
| 302 | my $self = shift; | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 0 | ▶ | my %mappers = ( | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 305 | 0 | ▶ | MSWin32 => sub { $_[0] . '.lib' }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 306 | 1 | cygwin => sub { $_[0] . '.dll'}, | |||||||||||||||||||||||||||
| 307 | 1 | ); | |||||||||||||||||||||||||||
| 308 | 1 | ▶ | my $mapper = $mappers{$^O}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | return () unless defined $mapper; | ||||||||||||||||||||||||||||
| 310 | 0 | ||||||||||||||||||||||||||||
| 311 | 0 | my @found_libs = (); | |||||||||||||||||||||||||||
| 312 | 0 | foreach my $name (keys %{ $self->{deps} }) { | |||||||||||||||||||||||||||
| 313 | 0 | (my $stem = $name) =~ s/^.*:://; | |||||||||||||||||||||||||||
| 314 | 0 | my $lib = $mapper->($stem); | |||||||||||||||||||||||||||
| 315 | my $pattern = qr/$lib$/; | ||||||||||||||||||||||||||||
| 316 | 0 | ||||||||||||||||||||||||||||
| 317 | my $matching_dir; | ||||||||||||||||||||||||||||
| 318 | 0 | ▶ | my $matching_file; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 319 | 0 | ▶ | find (sub { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $matching_file and /$pattern/
MC/DC0%0/2
not $matching_file and /$pattern/
not $matching_file
/$pattern/
Truth table0%0/3
not(A) and B
A= not $matching_fileB= /$pattern/
| |||||||||||||||||||||||||||||
| 320 | 0 | if ((not $matching_file) && /$pattern/) {; | |||||||||||||||||||||||||||
| 321 | 0 | $matching_dir = $File::Find::dir; | |||||||||||||||||||||||||||
| 322 | $matching_file = $File::Find::name; | ||||||||||||||||||||||||||||
| 323 | 0 | ▶ | } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | }, map { -d $_ ? ($_) : () } @INC); # only extant dirs | ||||||||||||||||||||||||||||
| 325 | 0 | ▶ | |||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$matching_file and -f $matching_file
MC/DC0%0/2
$matching_file and -f $matching_file
$matching_file
-f $matching_file
Truth table0%0/3
A and B
A= $matching_fileB= -f $matching_file
| |||||||||||||||||||||||||||||
| 326 | 0 | if ($matching_file && -f $matching_file) { | |||||||||||||||||||||||||||
| 327 | 0 | push @found_libs, ('-L' . $matching_dir, '-l' . $stem); | |||||||||||||||||||||||||||
| 328 | next; | ||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | 0 | ||||||||||||||||||||||||||||
| 332 | return @found_libs; | ||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | 1 | ||||||||||||||||||||||||||||
| 335 | 1; | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | __END__ | ||||||||||||||||||||||||||||