| 1 | package ExtUtils::Depends; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use File::Find; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | our $VERSION = '0.8000'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | sub import { | ||||||||||||||||||||||||||||
| 14 | 4 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=15.4
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | return unless @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | die "$class version $_[0] is required--this is only version $VERSION" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | if $VERSION < $_[0]; | ||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub new { | ||||||||||||||||||||||||||||
| 21 | 4 | ▶ | my ($class, $name, @deps) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | 4 | my $self = bless { | |||||||||||||||||||||||||||
| 23 | name => $name, | ||||||||||||||||||||||||||||
| 24 | deps => {}, | ||||||||||||||||||||||||||||
| 25 | inc => [], | ||||||||||||||||||||||||||||
| 26 | libs => '', | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | pm => {}, | ||||||||||||||||||||||||||||
| 29 | typemaps => [], | ||||||||||||||||||||||||||||
| 30 | xs => [], | ||||||||||||||||||||||||||||
| 31 | c => [], | ||||||||||||||||||||||||||||
| 32 | }, $class; | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 4 | $self->add_deps (@deps); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # attempt to load these now, so we'll find out as soon as possible | ||||||||||||||||||||||||||||
| 37 | # whether the dependencies are valid. we'll load them again in | ||||||||||||||||||||||||||||
| 38 | # get_makefile_vars to catch any added between now and then. | ||||||||||||||||||||||||||||
| 39 | 4 | $self->load_deps; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 4 | return $self; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | sub add_deps { | ||||||||||||||||||||||||||||
| 45 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_deps: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | 5 | foreach my $d (@_) { | |||||||||||||||||||||||||||
| 47 | $self->{deps}{$d} = undef | ||||||||||||||||||||||||||||
| 48 | 2 | ▶ | unless $self->{deps}{$d}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | sub get_deps { | ||||||||||||||||||||||||||||
| 53 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_deps: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | 2 | $self->load_deps; # just in case | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 2 | return %{$self->{deps}}; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub set_inc { | ||||||||||||||||||||||||||||
| 60 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
set_inc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 61 | 1 | push @{ $self->{inc} }, @_; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub set_libs { | ||||||||||||||||||||||||||||
| 65 | 1 | ▶ | my ($self, $newlibs) = @_; | ||||||||||||||||||||||||||
|
Subroutine
set_libs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 1 | $self->{libs} = $newlibs; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | sub add_pm { | ||||||||||||||||||||||||||||
| 70 | 7 | ▶ | my ($self, %pm) = @_; | ||||||||||||||||||||||||||
|
Subroutine
add_pm: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 7 | ▶ | while (my ($key, $value) = each %pm) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 8 | $self->{pm}{$key} = $value; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | sub _listkey_add_list { | ||||||||||||||||||||||||||||
| 77 | 3 | ▶ | my ($self, $key, @list) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_listkey_add_list: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 78 | 3 | ▶ | $self->{$key} = [] unless $self->{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 3 | push @{ $self->{$key} }, @list; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1 | ▶ | sub add_xs { shift->_listkey_add_list ('xs', @_) } | ||||||||||||||||||||||||||
|
Subroutine
add_xs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 1 | ▶ | sub add_c { shift->_listkey_add_list ('c', @_) } | ||||||||||||||||||||||||||
|
Subroutine
add_c: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | sub add_typemaps { | ||||||||||||||||||||||||||||
| 85 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_typemaps: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 1 | $self->_listkey_add_list ('typemaps', @_); | |||||||||||||||||||||||||||
| 87 | 1 | $self->install (@_); | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | # no-op, only used for source back-compat | ||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub add_headers { carp "add_headers() is a no-op" } | ||||||||||||||||||||||||||
|
Subroutine
add_headers: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | ####### PRIVATE | ||||||||||||||||||||||||||||
| 94 | 8 | ▶ | sub basename { (File::Spec->splitdir ($_[0]))[-1] } | ||||||||||||||||||||||||||
|
Subroutine
basename: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | # get the name in Makefile syntax. | ||||||||||||||||||||||||||||
| 96 | sub installed_filename { | ||||||||||||||||||||||||||||
| 97 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
installed_filename: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 98 | 6 | return '$(INST_ARCHLIB)/$(FULLEXT)/Install/'.basename ($_[0]); | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | sub install { | ||||||||||||||||||||||||||||
| 102 | # install things by adding them to the hash of pm files that gets | ||||||||||||||||||||||||||||
| 103 | # passed through WriteMakefile's PM key. | ||||||||||||||||||||||||||||
| 104 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
install: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 105 | 2 | foreach my $f (@_) { | |||||||||||||||||||||||||||
| 106 | 4 | $self->add_pm ($f, $self->installed_filename ($f)); | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | sub save_config { | ||||||||||||||||||||||||||||
| 111 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 112 | 2 | ▶ | local $Data::Dumper::Terse = 0; | ||||||||||||||||||||||||||
|
Subroutine
save_config: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 113 | 2 | local $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||
| 114 | 4 | ▶ | use IO::File; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 2 | my ($self, $filename) = @_; | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 2 | ▶ | my $file = IO::File->new (">".$filename) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | or croak "can't open '$filename' for writing: $!\n"; | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 2 | print $file "package $self->{name}\::Install::Files;\n\n"; | |||||||||||||||||||||||||||
| 122 | print $file "".Data::Dumper->Dump([{ | ||||||||||||||||||||||||||||
| 123 | 2 | inc => join (" ", @{ $self->{inc} }), | |||||||||||||||||||||||||||
| 124 | libs => $self->{libs}, | ||||||||||||||||||||||||||||
| 125 | 2 | typemaps => [ map { basename $_ } @{ $self->{typemaps} } ], | |||||||||||||||||||||||||||
| 126 | 2 | deps => [sort keys %{ $self->{deps} }], | |||||||||||||||||||||||||||
| 127 | }], ['self']); | ||||||||||||||||||||||||||||
| 128 | 2 | print $file <<'EOF'; | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | @deps = @{ $self->{deps} }; | ||||||||||||||||||||||||||||
| 131 | @typemaps = @{ $self->{typemaps} }; | ||||||||||||||||||||||||||||
| 132 | $libs = $self->{libs}; | ||||||||||||||||||||||||||||
| 133 | $inc = $self->{inc}; | ||||||||||||||||||||||||||||
| 134 | EOF | ||||||||||||||||||||||||||||
| 135 | # this is ridiculous, but old versions of ExtUtils::Depends take | ||||||||||||||||||||||||||||
| 136 | # first $loadedmodule::CORE and then $INC{$file} --- the fallback | ||||||||||||||||||||||||||||
| 137 | # includes the Filename.pm, which is not useful. so we must add | ||||||||||||||||||||||||||||
| 138 | # this crappy code. we don't worry about portable pathnames, | ||||||||||||||||||||||||||||
| 139 | # as the old code didn't either. | ||||||||||||||||||||||||||||
| 140 | 2 | (my $mdir = $self->{name}) =~ s{::}{/}g; | |||||||||||||||||||||||||||
| 141 | 2 | print $file <<"EOT"; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | \$CORE = undef; | ||||||||||||||||||||||||||||
| 144 | foreach (\@INC) { | ||||||||||||||||||||||||||||
| 145 | if ( -f \$_ . "/$mdir/Install/Files.pm") { | ||||||||||||||||||||||||||||
| 146 | \$CORE = \$_ . "/$mdir/Install/"; | ||||||||||||||||||||||||||||
| 147 | last; | ||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | sub deps { \@{ \$self->{deps} }; } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | sub Inline { | ||||||||||||||||||||||||||||
| 154 | my (\$class, \$lang) = \@_; | ||||||||||||||||||||||||||||
| 155 | if (\$lang ne 'C') { | ||||||||||||||||||||||||||||
| 156 | warn "Warning: Inline hints not available for \$lang language\n"; | ||||||||||||||||||||||||||||
| 157 | return; | ||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | +{ map { (uc(\$_) => \$self->{\$_}) } qw(inc libs typemaps) }; | ||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | EOT | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 2 | print $file "\n1;\n"; | |||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 2 | close $file; | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | # we need to ensure that the file we just created gets put into | ||||||||||||||||||||||||||||
| 168 | # the install dir with everything else. | ||||||||||||||||||||||||||||
| 169 | #$self->install ($filename); | ||||||||||||||||||||||||||||
| 170 | 2 | $self->add_pm ($filename, $self->installed_filename ('Files.pm')); | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | sub load { | ||||||||||||||||||||||||||||
| 174 | 5 | ▶ | my $dep = shift; | ||||||||||||||||||||||||||
|
Subroutine
load: called CC=12 SCAR=25.0
Pod
documented
| |||||||||||||||||||||||||||||
| 175 | 5 | my @pieces = split /::/, $dep; | |||||||||||||||||||||||||||
| 176 | 5 | my @suffix = qw/ Install Files /; | |||||||||||||||||||||||||||
| 177 | # not File::Spec - see perldoc -f require | ||||||||||||||||||||||||||||
| 178 | 5 | my $relpath = join('/', @pieces, @suffix) . '.pm'; | |||||||||||||||||||||||||||
| 179 | 5 | my $depinstallfiles = join "::", @pieces, @suffix; | |||||||||||||||||||||||||||
| 180 | 5 | ▶ | eval { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 5 | require $relpath | |||||||||||||||||||||||||||
| 182 | } or die " *** Can't load dependency information for $dep:\n $@\n"; | ||||||||||||||||||||||||||||
| 183 | #print Dumper(\%INC); | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | # effectively $instpath = dirname($INC{$relpath}) | ||||||||||||||||||||||||||||
| 186 | 5 | @pieces = File::Spec->splitdir ($INC{$relpath}); | |||||||||||||||||||||||||||
| 187 | 5 | pop @pieces; | |||||||||||||||||||||||||||
| 188 | 5 | my $instpath = File::Spec->catdir (@pieces); | |||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 4 | ▶ | no strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 5 | ▶ | croak "No dependency information found for $dep" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | unless $instpath; | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 5 | ▶ | if (not File::Spec->file_name_is_absolute ($instpath)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | 0 | $instpath = File::Spec->rel2abs ($instpath); | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 5 | my (@typemaps, $inc, $libs, @deps); | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | # this will not exist when loading files from old versions | ||||||||||||||||||||||||||||
| 202 | # of ExtUtils::Depends. | ||||||||||||||||||||||||||||
| 203 | 5 | @deps = eval { $depinstallfiles->deps }; | |||||||||||||||||||||||||||
| 204 | 1 | @deps = @{"$depinstallfiles\::deps"} | |||||||||||||||||||||||||||
| 205 | 5 | ▶ | if $@ and exists ${"$depinstallfiles\::"}{deps}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$@ and exists do {
"${depinstallfiles}::"
}->{"deps"}
MC/DC50%1/2
$@ and exists do {
"${depinstallfiles}::"
}->{"deps"}
$@
exists do {
"${depinstallfiles}::"
}->{"deps"}
Truth table66%2/3
A and B
A= $@B= exists do {
"${depinstallfiles}::"
}->{"deps"}
| |||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 5 | my $inline = eval { $depinstallfiles->Inline('C') }; | |||||||||||||||||||||||||||
| 208 | 5 | ▶ | if (!$@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 4 | ▶ | $inc = $inline->{INC} || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$inline->{'INC'} || ''
MC/DC100%1/1
$inline->{'INC'} || ''
$inline->{'INC'}
Truth table100%2/2
A
A= $inline->{'INC'}
| |||||||||||||||||||||||||||||
| 210 | 4 | ▶ | $libs = $inline->{LIBS} || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$inline->{'LIBS'} || ''
MC/DC100%1/1
$inline->{'LIBS'} || ''
$inline->{'LIBS'}
Truth table100%2/2
A
A= $inline->{'LIBS'}
| |||||||||||||||||||||||||||||
| 211 | 4 | ▶ | @typemaps = @{ $inline->{TYPEMAPS} || [] }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | } else { | ||||||||||||||||||||||||||||
| 213 | 1 | ▶ | $inc = ${"$depinstallfiles\::inc"} || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
${"${depinstallfiles}::inc";} || ''
MC/DC0%0/1
${"${depinstallfiles}::inc";} || ''
${"${depinstallfiles}::inc";}
Truth table50%1/2
A
A= ${"${depinstallfiles}::inc";}
| |||||||||||||||||||||||||||||
| 214 | 1 | ▶ | $libs = ${"$depinstallfiles\::libs"} || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
${"${depinstallfiles}::libs";} || ''
MC/DC0%0/1
${"${depinstallfiles}::libs";} || ''
${"${depinstallfiles}::libs";}
Truth table50%1/2
A
A= ${"${depinstallfiles}::libs";}
| |||||||||||||||||||||||||||||
| 215 | 1 | @typemaps = @{"$depinstallfiles\::typemaps"}; | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | 5 | @typemaps = map { File::Spec->rel2abs ($_, $instpath) } @typemaps; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||
| 220 | 5 | instpath => $instpath, | |||||||||||||||||||||||||||
| 221 | typemaps => \@typemaps, | ||||||||||||||||||||||||||||
| 222 | inc => "-I". _quote_if_space($instpath) ." $inc", | ||||||||||||||||||||||||||||
| 223 | libs => $libs, | ||||||||||||||||||||||||||||
| 224 | deps => \@deps, | ||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 5 | ▶ | sub _quote_if_space { $_[0] =~ / / ? qq{"$_[0]"} : $_[0] } | ||||||||||||||||||||||||||
|
Subroutine
_quote_if_space: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | sub load_deps { | ||||||||||||||||||||||||||||
| 231 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
load_deps: called CC=6 SCAR=21.6
Pod
documented
| |||||||||||||||||||||||||||||
| 232 | 8 | my @load = grep { not $self->{deps}{$_} } keys %{ $self->{deps} }; | |||||||||||||||||||||||||||
| 233 | 8 | foreach my $d (@load) { | |||||||||||||||||||||||||||
| 234 | 2 | my $dep = load ($d); | |||||||||||||||||||||||||||
| 235 | 2 | $self->{deps}{$d} = $dep; | |||||||||||||||||||||||||||
| 236 | 2 | ▶ | if ($dep->{deps}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 2 | foreach my $childdep (@{ $dep->{deps} }) { | |||||||||||||||||||||||||||
| 238 | push @load, $childdep | ||||||||||||||||||||||||||||
| 239 | unless | ||||||||||||||||||||||||||||
| 240 | $self->{deps}{$childdep} | ||||||||||||||||||||||||||||
| 241 | or | ||||||||||||||||||||||||||||
| 242 | 0 | ▶ | grep {$_ eq $childdep} @load; | ||||||||||||||||||||||||||
|
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
| |||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | sub uniquify { | ||||||||||||||||||||||||||||
| 249 | 2 | ▶ | my %seen; | ||||||||||||||||||||||||||
|
Subroutine
uniquify: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 250 | # we use a seen hash, but also keep indices to preserve | ||||||||||||||||||||||||||||
| 251 | # first-seen order. | ||||||||||||||||||||||||||||
| 252 | 2 | my $i = 0; | |||||||||||||||||||||||||||
| 253 | 2 | foreach (@_) { | |||||||||||||||||||||||||||
| 254 | $seen{$_} = ++$i | ||||||||||||||||||||||||||||
| 255 | 8 | ▶ | unless exists $seen{$_}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | #warn "stripped ".(@_ - (keys %seen))." redundant elements\n"; | ||||||||||||||||||||||||||||
| 258 | 2 | sort { $seen{$a} <=> $seen{$b} } keys %seen; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | sub get_makefile_vars { | ||||||||||||||||||||||||||||
| 263 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_makefile_vars: called CC=13 SCAR=29.9
Pod
documented
| |||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | # collect and uniquify things from the dependencies. | ||||||||||||||||||||||||||||
| 266 | # first, ensure they are completely loaded. | ||||||||||||||||||||||||||||
| 267 | 1 | $self->load_deps; | |||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | ##my @defbits = map { split } @{ $self->{defines} }; | ||||||||||||||||||||||||||||
| 270 | 1 | my @incbits = map { split } @{ $self->{inc} }; | |||||||||||||||||||||||||||
| 271 | 1 | my @libsbits = split /\s+/, $self->{libs}; | |||||||||||||||||||||||||||
| 272 | 1 | my @typemaps = @{ $self->{typemaps} }; | |||||||||||||||||||||||||||
| 273 | 1 | foreach my $d (sort keys %{ $self->{deps} }) { | |||||||||||||||||||||||||||
| 274 | 0 | my $dep = $self->{deps}{$d}; | |||||||||||||||||||||||||||
| 275 | #push @defbits, @{ $dep->{defines} }; | ||||||||||||||||||||||||||||
| 276 | 0 | ▶ | push @incbits, @{ $dep->{defines} } if $dep->{defines}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 277 | 0 | ▶ | push @incbits, split /\s+/, $dep->{inc} if $dep->{inc}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 278 | 0 | ▶ | push @libsbits, split /\s+/, $dep->{libs} if $dep->{libs}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | 0 | ▶ | push @typemaps, @{ $dep->{typemaps} } if $dep->{typemaps}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | # we have a fair bit of work to do for the xs files... | ||||||||||||||||||||||||||||
| 283 | 1 | my @clean = (); | |||||||||||||||||||||||||||
| 284 | 1 | my @OBJECT = (); | |||||||||||||||||||||||||||
| 285 | 1 | my %XS = (); | |||||||||||||||||||||||||||
| 286 | 1 | foreach my $xs (@{ $self->{xs} }) { | |||||||||||||||||||||||||||
| 287 | 2 | (my $c = $xs) =~ s/\.xs$/\.c/i; | |||||||||||||||||||||||||||
| 288 | 2 | (my $o = $xs) =~ s/\.xs$/\$(OBJ_EXT)/i; | |||||||||||||||||||||||||||
| 289 | 2 | $XS{$xs} = $c; | |||||||||||||||||||||||||||
| 290 | 2 | push @OBJECT, $o; | |||||||||||||||||||||||||||
| 291 | # according to the MakeMaker manpage, the C files listed in | ||||||||||||||||||||||||||||
| 292 | # XS will be added automatically to the list of cleanfiles. | ||||||||||||||||||||||||||||
| 293 | 2 | push @clean, $o; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | # we may have C files, as well: | ||||||||||||||||||||||||||||
| 297 | 1 | foreach my $c (@{ $self->{c} }) { | |||||||||||||||||||||||||||
| 298 | 2 | (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i; | |||||||||||||||||||||||||||
| 299 | 2 | push @OBJECT, $o; | |||||||||||||||||||||||||||
| 300 | 2 | push @clean, $o; | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 1 | my %vars = ( | |||||||||||||||||||||||||||
| 304 | INC => join (' ', uniquify @incbits), | ||||||||||||||||||||||||||||
| 305 | LIBS => join (' ', uniquify $self->find_extra_libs, @libsbits), | ||||||||||||||||||||||||||||
| 306 | TYPEMAPS => [@typemaps], | ||||||||||||||||||||||||||||
| 307 | ); | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 1 | ▶ | $self->build_dll_lib(\%vars) if $^O =~ /MSWin32/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | # we don't want to provide these if there is no data in them; | ||||||||||||||||||||||||||||
| 312 | # that way, the caller can still get default behavior out of | ||||||||||||||||||||||||||||
| 313 | # MakeMaker when INC, LIBS and TYPEMAPS are all that are required. | ||||||||||||||||||||||||||||
| 314 | $vars{PM} = $self->{pm} | ||||||||||||||||||||||||||||
| 315 | 1 | ▶ | if %{ $self->{pm} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 316 | 1 | ▶ | $vars{clean} = { FILES => join (" ", @clean), } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 317 | if @clean; | ||||||||||||||||||||||||||||
| 318 | 1 | ▶ | $vars{OBJECT} = join (" ", @OBJECT) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | if @OBJECT; | ||||||||||||||||||||||||||||
| 320 | 1 | ▶ | $vars{XS} = \%XS | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 321 | if %XS; | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 1 | %vars; | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | sub build_dll_lib { | ||||||||||||||||||||||||||||
| 327 | 0 | ▶ | my ($self, $vars) = @_; | ||||||||||||||||||||||||||
|
Subroutine
build_dll_lib: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 328 | 0 | ▶ | $vars->{macro} ||= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$vars->{"macro"} ||= {}
MC/DC0%0/1
$vars->{"macro"} ||= {}
$vars->{"macro"}
Truth table0%0/2
A
A= $vars->{"macro"}
| |||||||||||||||||||||||||||||
| 329 | 0 | $vars->{macro}{'INST_DYNAMIC_LIB'} = | |||||||||||||||||||||||||||
| 330 | '$(INST_ARCHAUTODIR)/$(DLBASE)$(LIB_EXT)'; | ||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | # Search for extra library files to link against on Windows (either native | ||||||||||||||||||||||||||||
| 334 | # Windows library # files, or Cygwin library files) | ||||||||||||||||||||||||||||
| 335 | # NOTE: not meant to be called publicly, so no POD documentation | ||||||||||||||||||||||||||||
| 336 | sub find_extra_libs { | ||||||||||||||||||||||||||||
| 337 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
find_extra_libs: called CC=8 SCAR=39.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | my %mappers = ( | ||||||||||||||||||||||||||||
| 340 | 0 | ▶ | MSWin32 => sub { $_[0] . '\.(?:lib|a)' }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 341 | 0 | ▶ | cygwin => sub { $_[0] . '\.dll'}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 342 | 0 | ▶ | android => sub { $_[0] . '\.' . $Config{dlext} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 343 | 1 | ); | |||||||||||||||||||||||||||
| 344 | 1 | my $mapper = $mappers{$^O}; | |||||||||||||||||||||||||||
| 345 | 1 | ▶ | return () unless defined $mapper; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | 0 | my @found_libs = (); | |||||||||||||||||||||||||||
| 348 | 0 | foreach my $name (keys %{ $self->{deps} }) { | |||||||||||||||||||||||||||
| 349 | 0 | (my $stem = $name) =~ s/^.*:://; | |||||||||||||||||||||||||||
| 350 | 0 | ▶ | if ( defined &DynaLoader::mod2fname ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 0 | my @parts = split /::/, $name; | |||||||||||||||||||||||||||
| 352 | 0 | $stem = DynaLoader::mod2fname([@parts]); | |||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | 0 | my $lib = $mapper->($stem); | |||||||||||||||||||||||||||
| 355 | 0 | my $pattern = qr/$lib$/; | |||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | 0 | my $matching_dir; | |||||||||||||||||||||||||||
| 358 | my $matching_file; | ||||||||||||||||||||||||||||
| 359 | find (sub { | ||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if ((not $matching_file) && /$pattern/) {; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
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/
| |||||||||||||||||||||||||||||
| 361 | 0 | $matching_dir = $File::Find::dir; | |||||||||||||||||||||||||||
| 362 | 0 | $matching_file = $File::Find::name; | |||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | 0 | ▶ | }, map { -d $_ ? ($_) : () } @INC); # only extant dirs | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if ($matching_file && -f $matching_file) { | ||||||||||||||||||||||||||
|
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
| |||||||||||||||||||||||||||||
| 367 | 0 | push @found_libs, | |||||||||||||||||||||||||||
| 368 | '-L' . _quote_if_space($matching_dir), | ||||||||||||||||||||||||||||
| 369 | '-l' . $stem; | ||||||||||||||||||||||||||||
| 370 | # Android's linker ignores the RTLD_GLOBAL flag | ||||||||||||||||||||||||||||
| 371 | # and loads everything as if under RTLD_LOCAL. | ||||||||||||||||||||||||||||
| 372 | # What this means in practice is that modules need | ||||||||||||||||||||||||||||
| 373 | # to explicitly link to their dependencies, | ||||||||||||||||||||||||||||
| 374 | # because otherwise they won't be able to locate any | ||||||||||||||||||||||||||||
| 375 | # functions they define. | ||||||||||||||||||||||||||||
| 376 | # We use the -l:foo.so flag to indicate that the | ||||||||||||||||||||||||||||
| 377 | # actual library name to look for is foo.so, not | ||||||||||||||||||||||||||||
| 378 | # libfoo.so | ||||||||||||||||||||||||||||
| 379 | 0 | ▶ | if ( $^O eq 'android' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 380 | 0 | $found_libs[-1] = "-l:$stem.$Config{dlext}"; | |||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||
| 382 | 0 | next; | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 0 | return @found_libs; | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | # Hook into ExtUtils::MakeMaker to create an import library on MSWin32 when gcc | ||||||||||||||||||||||||||||
| 390 | # is used. FIXME: Ideally, this should be done in EU::MM itself. | ||||||||||||||||||||||||||||
| 391 | package # wrap to fool the CPAN indexer | ||||||||||||||||||||||||||||
| 392 | ExtUtils::MM; | ||||||||||||||||||||||||||||
| 393 | 4 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 394 | sub static_lib { | ||||||||||||||||||||||||||||
| 395 | 0 | ▶ | my $base = shift->SUPER::static_lib(@_); | ||||||||||||||||||||||||||
|
Subroutine
static_lib: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | 0 | ▶ | return $base unless $^O =~ /MSWin32/ && $Config{cc} =~ /\bgcc\b/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O =~ /MSWin32/ and $ExtUtils::MM::Config{"cc"} =~ /\bgcc\b/i
MC/DC0%0/2
$^O =~ /MSWin32/ and $ExtUtils::MM::Config{"cc"} =~ /\bgcc\b/i
$^O =~ /MSWin32/
$ExtUtils::MM::Config{"cc"} =~ /\bgcc\b/i
Truth table0%0/3
A and B
A= $^O =~ /MSWin32/B= $ExtUtils::MM::Config{"cc"} =~ /\bgcc\b/i
| |||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | 0 | ▶ | my $DLLTOOL = $Config{'dlltool'} || 'dlltool'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ExtUtils::MM::Config{'dlltool'} || 'dlltool'
MC/DC0%0/1
$ExtUtils::MM::Config{'dlltool'} || 'dlltool'
$ExtUtils::MM::Config{'dlltool'}
Truth table0%0/2
A
A= $ExtUtils::MM::Config{'dlltool'}
| |||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | return <<"__EOM__" | ||||||||||||||||||||||||||||
| 402 | # This isn't actually a static lib, it just has the same name on Win32. | ||||||||||||||||||||||||||||
| 403 | \$(INST_DYNAMIC_LIB): \$(INST_DYNAMIC) | ||||||||||||||||||||||||||||
| 404 | $DLLTOOL --def \$(EXPORT_LIST) --output-lib \$\@ --dllname \$(DLBASE).\$(DLEXT) \$(INST_DYNAMIC) | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | dynamic:: \$(INST_DYNAMIC_LIB) | ||||||||||||||||||||||||||||
| 407 | __EOM__ | ||||||||||||||||||||||||||||
| 408 | 0 | } | |||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 4 | 1; | |||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | __END__ | ||||||||||||||||||||||||||||