blib/lib/Affix/Platform/BSD.pm

filter: Statementstmt 37.5% 12 / 32 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 1 totaltotal 26.7% 15 / 56 CC 11 SCAR 46.4
CC
11
Cov
24%
find_library
132.0
BEGIN
1.0
BEGIN
1.0
CRAP 103.9
« builder/Affix/Builder.pm ↑ Summary blib/lib/Affix/Wrap.pm »
1 1 package Affix::Platform::BSD v1.3.0 {
2 1 ▶ use v5.40;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶ use parent 'Affix::Platform::Unix';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶ use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 our @EXPORT_OK = qw[find_library];
6 1 our %EXPORT_TAGS = ( all => \@EXPORT_OK );
7  
8 0 ▶ sub find_library ( $name, $version //= '' ) { # TODO: actually feed version to diff methods
Subroutine find_library: not called CC=11 SCAR=48.8
Pod undocumented
9 0 ▶ if ( -f $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $name) 0 0 0
10 0 ▶ $name = readlink $name if -l $name; # Handle symbolic links
Branch: 1 branch
BranchTrueFalseTotal
if -l $name 0 0 0
11 0 return $name # if is_elf($name);
12 }
13 0 CORE::state $cache;
14 0 ▶ return $cache->{$name}{$version} if defined $cache->{$name}{$version};
Branch: 1 branch
BranchTrueFalseTotal
if defined $cache->{$name}{$version} 0 0 0
15 0 my $regex = qr[-l\Q$name\E\.[^\s]+.+\s*=>\s*(.+)$];
16  
17 # ldconfig lives in different places per BSD (and NetBSD may not ship it
18 # at all), so probe the common locations before giving up.
19 0 my $ldconfig = '';
20 0 for my $cmd (qw[/sbin/ldconfig /usr/sbin/ldconfig ldconfig]) {
21 0 my $out = `export LC_ALL 'C'; export LANG 'C'; $cmd -r 2>/dev/null`;
22 0 ▶ if ( defined $out && $out =~ /\S/ ) { $ldconfig = $out; last; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $out and $out =~ /\S/u) 0 0 0
Condition0%0/3
defined $out and $out =~ /\S/u
!ll&&!rl&&r
000
MC/DC0%0/2
defined $out and $out =~ /\S/u
defined $out $out =~ /\S/u
Truth table0%0/3
A and B
A= defined $outB= $out =~ /\S/u
ABresult
0X0
100
111
23 }
24 0 ▶ my @found = grep {-e} map { -l $_ ? readlink($_) : $_ } map { $_ =~ $regex; defined $1 ? $1 : () } split /\n\s*/, $ldconfig;
Branch: 2 branches
BranchTrueFalseTotal
-l $_ ? : 0 0 0
defined $1 ? : 0 0 0
25 0 ▶ return $cache->{$name}{$version} = $found[0] if @found;
Branch: 1 branch
BranchTrueFalseTotal
if @found 0 0 0
26  
27 # No ldconfig (or it doesn't know this library) -- fall back to the
28 # portable Unix probes (DynaLoader, gcc, ld).
29 0 $cache->{$name}{$version} = Affix::Platform::Unix::find_library( $name, $version );
30 }
31 };
32 1 1;
« builder/Affix/Builder.pm ↑ Summary blib/lib/Affix/Wrap.pm »