blib/lib/Alien/Build/Plugin/PkgConfig/Negotiate.pm

filter: Statementstmt 96.7% 59 / 61 Branchbran 93.7% 15 / 16 Conditioncond 91.6% 11 / 12 MC/DCmcdc 85.7% 6 / 7 Subroutinesub 91.6% 11 / 12 Podpod 100% 2 / 2 totaltotal 94.5% 104 / 110 CC 14 SCAR 16.1
CC
14
Cov
96%
pick
8.1
init
7.0
__ANON__
2.0
CRAP 5.0
« blib/lib/Alien/Build/Plugin/Build/MSYS.pm ↑ Summary blib/lib/Alien/Build/Plugin/Extract/ArchiveTar.pm »
1 package Alien::Build::Plugin::PkgConfig::Negotiate;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Alien::Build::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use Alien::Build::Plugin::PkgConfig::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Alien::Build::Plugin::PkgConfig::LibPkgConf;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use Alien::Build::Plugin::PkgConfig::CommandLine;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Alien::Build::Util qw( _perl_config );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # ABSTRACT: Package configuration negotiation plugin
14 6 our $VERSION = '2.88'; # VERSION
15  
16  
17 0 ▶has '+pkg_name' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 0 Carp::croak "pkg_name is a required property";
19 6 };
20  
21  
22 6 has atleast_version => undef;
23  
24  
25 6 has exact_version => undef;
26  
27  
28 6 has max_version => undef;
29  
30  
31 6 has minimum_version => undef;
32  
33  
34 sub pick
35 27 ▶{
Subroutine pick: called CC=8 SCAR=20.9
Pod documented
36 27 my($class) = @_;
37  
38 27 ▶ return $ENV{ALIEN_BUILD_PKG_CONFIG} if $ENV{ALIEN_BUILD_PKG_CONFIG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"ALIEN_BUILD_PKG_CONFIG"} 7 20 27
39  
40 20 ▶ if(Alien::Build::Plugin::PkgConfig::LibPkgConf->available)
Branch: 1 branch
BranchTrueFalseTotal
if ("Alien::Build::Plugin::PkgConfig::LibPkgConf"->available) 1 19 20
41 {
42 1 return 'PkgConfig::LibPkgConf';
43 }
44  
45 19 ▶ if(Alien::Build::Plugin::PkgConfig::CommandLine->available)
Branch: 1 branch
BranchTrueFalseTotal
if ("Alien::Build::Plugin::PkgConfig::CommandLine"->available) 5 14 19
46 {
47 # TODO: determine environment or flags necessary for using pkg-config
48 # on solaris 64 bit.
49 # Some advice on pkg-config and 64 bit Solaris
50 # https://docs.oracle.com/cd/E53394_01/html/E61689/gplhi.html
51 5 ▶ my $is_solaris64 = (_perl_config('osname') eq 'solaris' && _perl_config('ptrsize') == 8);
Condition66%2/3
_perl_config('osname') eq 'solaris' && _perl_config('ptrsize') == 8
!ll&&!rl&&r
401
MC/DC50%1/2
_perl_config('osname') eq 'solaris' && _perl_config('ptrsize') == 8
_perl_config('osname') eq 'solaris' _perl_config('ptrsize') == 8
Truth table66%2/3
A && B
A= _perl_config('osname') eq 'solaris'B= _perl_config('ptrsize') == 8
ABresult
0X0
100
111
52  
53 # PkgConfig.pm is more reliable on windows
54 5 my $is_windows = _perl_config('osname') eq 'MSWin32';
55  
56 5 ▶ if(!$is_solaris64 && !$is_windows)
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_solaris64 or $is_windows) 3 2 5
Condition100%3/3
$is_solaris64 or $is_windows
l!l&&r!l&&!r
113
MC/DC100%2/2
$is_solaris64 or $is_windows
$is_solaris64 $is_windows
Truth table100%3/3
A or B
A= $is_solaris64B= $is_windows
ABresult
1X1
011
000
57 {
58 3 return 'PkgConfig::CommandLine';
59 }
60 }
61  
62 16 ▶ if(Alien::Build::Plugin::PkgConfig::PP->available)
Branch: 1 branch
BranchTrueFalseTotal
if ('Alien::Build::Plugin::PkgConfig::PP'->available) { } 16 0 16
63 {
64 16 return 'PkgConfig::PP';
65 }
66 else
67 {
68 # this is a fata error. because we check for a pkg-config implementation
69 # at configure time, we expect at least one of these to work. (and we
70 # fallback on installing PkgConfig.pm as a prereq if nothing else is avail).
71 # we therefore expect at least one of these to work, if not, then the configuration
72 # of the system has shifted from underneath us.
73 0 Carp::croak("Could not find an appropriate pkg-config or pkgconf implementation, please install PkgConfig.pm, PkgConfig::LibPkgConf, pkg-config or pkgconf");
74 }
75 }
76  
77 sub init
78 16 ▶{
Subroutine init: called CC=7 SCAR=19.5
Pod documented
79 16 my($self, $meta) = @_;
80  
81 16 my $plugin = $self->pick;
82 16 Alien::Build->log("Using PkgConfig plugin: $plugin");
83  
84 16 ▶ if(ref($self->pkg_name) eq 'ARRAY')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->pkg_name eq "ARRAY") 1 15 16
85 {
86 1 $meta->add_requires('configure', 'Alien::Build::Plugin::PkgConfig::Negotiate' => '0.79');
87 }
88  
89 16 ▶ if($self->atleast_version || $self->exact_version || $self->max_version)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->atleast_version or $self->exact_version or $self->max_version) 3 13 16
Condition100%6/6
$self->atleast_version or $self->exact_version or $self->max_version
l!l&&r!l&&!r
2113
$self->atleast_version or $self->exact_version
l!l&&r!l&&!r
1114
MC/DC100%3/3
$self->atleast_version or $self->exact_version or $self->max_version
$self->atleast_version $self->exact_version $self->max_version
Truth table100%4/4
A or B or C
A= $self->atleast_versionB= $self->exact_versionC= $self->max_version
ABCresult
1XX1
01X1
0011
0000
90 {
91 3 $meta->add_requires('configure', 'Alien::Build::Plugin::PkgConfig::Negotiate' => '1.53');
92 }
93  
94 16 my @args;
95 16 push @args, pkg_name => $self->pkg_name;
96 16 push @args, register_prereqs => 0;
97  
98 16 foreach my $method (map { "${_}_version" } qw( minimum atleast exact max ))
99 {
100 64 ▶ push @args, $method => $self->$method if defined $self->$method;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->$method 7 57 64
101 }
102  
103 16 $meta->apply_plugin($plugin, @args);
104  
105 16 $self;
106 }
107  
108 6 1;
109  
110 __END__
« blib/lib/Alien/Build/Plugin/Build/MSYS.pm ↑ Summary blib/lib/Alien/Build/Plugin/Extract/ArchiveTar.pm »