blib/lib/Alien/Build/Interpolate/Default.pm

filter: Statementstmt 47.3% 62 / 131 Branchbran 13.6% 6 / 44 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 37.5% 15 / 40 Podpod 100% 1 / 1 totaltotal 35.5% 84 / 236 CC 29 SCAR 40.2
CC
29
Cov
36%
__ANON__
240.0
__ANON__
12.0
__ANON__
6.0
CRAP 55.5
« blib/lib/Alien/Build/Plugin/Build/SearchDep.pm ↑ Summary blib/lib/Alien/Build/Plugin/Probe/Vcpkg.pm »
1 package Alien::Build::Interpolate::Default;
2  
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use parent qw( Alien::Build::Interpolate );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use File::chdir;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use File::Which qw( which );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use Capture::Tiny qw( capture );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ABSTRACT: Default interpolator for Alien::Build
12 13 our $VERSION = '2.88'; # VERSION
13  
14 sub _config
15 6 ▶{
Subroutine _config: called CC=1 SCAR=0.0
16 6 $Config::Config{$_[0]};
17 }
18  
19  
20 sub new
21 60 ▶{
Subroutine new: called CC=2 SCAR=12.6
Pod documented
22 60 my($class) = @_;
23 60 my $self = $class->SUPER::new(@_);
24  
25  
26 0 ▶ $self->add_helper( ar => sub { _config 'ar' }, 'Config' );
Subroutine __ANON__: not called CC=1 SCAR=1.2
27  
28  
29 2 ▶ $self->add_helper( bison => undef, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
30 2 my $helper = shift;
31 2 ▶ if(which 'bison')
Branch: 1 branch
BranchTrueFalseTotal
if (which('bison')) { } 1 1 2
32 {
33 1 ▶ $helper->code(sub { 'bison' });
Subroutine __ANON__: called CC=1 SCAR=0.0
34 1 return ();
35 }
36 else
37 {
38 1 return 'Alien::bison' => '0.17';
39 }
40 60 });
41  
42  
43 0 ▶ $self->add_helper( bzip2 => undef, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
44 0 my $helper = shift;
45 0 ▶ if(which 'bzip2')
Branch: 1 branch
BranchTrueFalseTotal
if (which('bzip2')) { } 0 0 0
46 {
47 0 ▶ $helper->code( sub { 'bzip2' });
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 0 return ();
49 }
50 else
51 {
52 0 return 'Alien::Libbz2' => '0.04';
53 }
54 60 });
55  
56  
57 0 ▶ $self->add_helper( cc => sub { _config 'cc' }, 'Config' );
Subroutine __ANON__: not called CC=1 SCAR=1.2
58  
59  
60 0 ▶ $self->add_helper( cmake => sub { 'cmake' }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=2 SCAR=17.9
61 0 ▶ if(which 'cmake')
Branch: 1 branch
BranchTrueFalseTotal
if (which('cmake')) { } 0 0 0
62 {
63 0 return ();
64 }
65 else
66 {
67 0 return 'Alien::CMake' => '0.07';
68 }
69 60 });
70  
71  
72 0 ▶ $self->add_helper( cp => sub { _config 'cp' }, 'Config' );
Subroutine __ANON__: not called CC=1 SCAR=1.2
73  
74  
75 0 ▶ $self->add_helper( devnull => sub { $^O eq 'MSWin32' ? 'NUL' : '/dev/null' });
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 0 0
76  
77  
78 0 ▶ $self->add_helper( flex => undef, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
79 0 my $helper = shift;
80 0 ▶ if(which 'flex')
Branch: 1 branch
BranchTrueFalseTotal
if (which('flex')) { } 0 0 0
81 {
82 0 ▶ $helper->code(sub { 'flex' });
Subroutine __ANON__: not called CC=1 SCAR=6.9
83 0 return ();
84 }
85 else
86 {
87 0 return 'Alien::flex' => '0.08';
88 }
89 60 });
90  
91  
92 60 $self->add_helper( gmake => undef, 'Alien::gmake' => '0.11' );
93  
94  
95 0 ▶ $self->add_helper( install => sub { 'install' });
Subroutine __ANON__: not called CC=1 SCAR=1.2
96  
97  
98 0 ▶ $self->add_helper( ld => sub { _config 'ld' }, 'Config' );
Subroutine __ANON__: not called CC=1 SCAR=1.2
99  
100  
101 60 $self->add_helper( m4 => undef, 'Alien::m4' => '0.08' );
102  
103  
104 60 ▶ if($^O eq 'MSWin32')
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 60 60
105 {
106 # TL;DR: dmake is bad, and shouldn't be used to build anything but older
107 # versions of Windows Perl that don't support gmake.
108 0 my $perl_make = _config 'make';
109 0 my $my_make;
110 0 ▶ $self->add_helper( make => sub {
Subroutine __ANON__: not called CC=15 SCAR=54.8
111 0 ▶ return $my_make if defined $my_make;
Branch: 1 branch
BranchTrueFalseTotal
if defined $my_make 0 0 0
112  
113 0 ▶ if( $perl_make ne 'dmake' && which $perl_make )
Branch: 1 branch
BranchTrueFalseTotal
if ($perl_make ne "dmake" and which($perl_make)) 0 0 0
Condition0%0/3
$perl_make ne "dmake" and which($perl_make)
!ll&&!rl&&r
000
MC/DC0%0/2
$perl_make ne "dmake" and which($perl_make)
$perl_make ne "dmake" which($perl_make)
Truth table0%0/3
A and B
A= $perl_make ne "dmake"B= which($perl_make)
ABresult
0X0
100
111
114 {
115 # assume if it is called nmake or gmake that it really is what it
116 # says it is.
117 0 ▶ if( $perl_make eq 'nmake' || $perl_make eq 'gmake' )
Branch: 1 branch
BranchTrueFalseTotal
if ($perl_make eq "nmake" or $perl_make eq "gmake") 0 0 0
Condition0%0/3
$perl_make eq "nmake" or $perl_make eq "gmake"
l!l&&r!l&&!r
000
MC/DC0%0/2
$perl_make eq "nmake" or $perl_make eq "gmake"
$perl_make eq "nmake" $perl_make eq "gmake"
Truth table0%0/3
A or B
A= $perl_make eq "nmake"B= $perl_make eq "gmake"
ABresult
1X1
011
000
118 {
119 0 return $my_make = $perl_make;
120 }
121  
122 0 ▶ my $out = capture { system $perl_make, '--version' };
Subroutine __ANON__: not called CC=1 SCAR=6.9
123 0 ▶ if( $out =~ /GNU make/i || $out =~ /Microsoft \(R\) Program Maintenance/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($out =~ /GNU make/i or $out =~ /Microsoft \(R\) Program Maintenance/) 0 0 0
Condition0%0/3
$out =~ /GNU make/i or $out =~ /Microsoft \(R\) Program Maintenance/
l!l&&r!l&&!r
000
MC/DC0%0/2
$out =~ /GNU make/i or $out =~ /Microsoft \(R\) Program Maintenance/
$out =~ /GNU make/i $out =~ /Microsoft \(R\) Program Maintenance/
Truth table0%0/3
A or B
A= $out =~ /GNU make/iB= $out =~ /Microsoft \(R\) Program Maintenance/
ABresult
1X1
011
000
124 {
125 0 return $my_make = $perl_make;
126 }
127  
128 }
129  
130 # if we see something that looks like it might be gmake, use that.
131 0 foreach my $try (qw( gmake mingw32-make ))
132 {
133 0 ▶ return $my_make = $try if which $try;
Branch: 1 branch
BranchTrueFalseTotal
if which($try) 0 0 0
134 }
135  
136 0 ▶ if( which 'make' )
Branch: 1 branch
BranchTrueFalseTotal
if (which("make")) 0 0 0
137 {
138 0 ▶ my $out = capture { system 'make', '--version' };
Subroutine __ANON__: not called CC=1 SCAR=6.9
139 0 ▶ if( $out =~ /GNU make/i || $out =~ /Microsoft \(R\) Program Maintenance/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($out =~ /GNU make/i or $out =~ /Microsoft \(R\) Program Maintenance/) 0 0 0
Condition0%0/3
$out =~ /GNU make/i or $out =~ /Microsoft \(R\) Program Maintenance/
l!l&&r!l&&!r
000
MC/DC0%0/2
$out =~ /GNU make/i or $out =~ /Microsoft \(R\) Program Maintenance/
$out =~ /GNU make/i $out =~ /Microsoft \(R\) Program Maintenance/
Truth table0%0/3
A or B
A= $out =~ /GNU make/iB= $out =~ /Microsoft \(R\) Program Maintenance/
ABresult
1X1
011
000
140 {
141 0 return $my_make = 'make';
142 }
143 }
144  
145 # if we see something that looks like it might be nmake, use that.
146 0 foreach my $try (qw( nmake ))
147 {
148 0 ▶ return $my_make = $try if which $try;
Branch: 1 branch
BranchTrueFalseTotal
if which($try) 0 0 0
149 }
150  
151 0 $my_make = $perl_make;
152 0 });
153 }
154 else
155 {
156 60 ▶ $self->add_helper( make => sub { _config 'make' }, 'Config' );
Subroutine __ANON__: called CC=1 SCAR=0.0
157 }
158  
159  
160 60 ▶ $self->add_helper( mkdir_deep => sub { $^O eq 'MSWin32' ? 'md' : 'mkdir -p'}, 'Alien::Build' => '1.04' );
Subroutine __ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 1 1
161 60 ▶ $self->add_helper( make_path => sub { $^O eq 'MSWin32' ? 'md' : 'mkdir -p'}, 'Alien::Build' => '1.05' );
Subroutine __ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 4 4
162  
163  
164 0 ▶ $self->add_helper( nasm => undef, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
165 0 my $helper = shift;
166 0 ▶ if(which 'nasm')
Branch: 1 branch
BranchTrueFalseTotal
if (which('nasm')) { } 0 0 0
167 {
168 0 ▶ $helper->code(sub { 'nasm' });
Subroutine __ANON__: not called CC=1 SCAR=6.9
169 0 return ();
170 }
171 else
172 {
173 0 return 'Alien::nasm' => '0.11';
174 }
175 60 });
176  
177  
178 0 ▶ $self->add_helper( patch => undef, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
179 0 my $helper = shift;
180 0 ▶ if(which 'patch')
Branch: 1 branch
BranchTrueFalseTotal
if (which('patch')) { } 0 0 0
181 {
182 0 ▶ if($^O eq 'MSWin32')
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 0 0
183 {
184 0 ▶ $helper->code(sub { 'patch --binary' });
Subroutine __ANON__: not called CC=1 SCAR=6.9
185 }
186 else
187 {
188 0 ▶ $helper->code(sub { 'patch' });
Subroutine __ANON__: not called CC=1 SCAR=6.9
189 }
190 0 return ();
191 }
192 else
193 {
194 0 return 'Alien::patch' => '0.09';
195 }
196 60 });
197  
198  
199 0 ▶ $self->add_helper( perl => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
200 0 my $perl = Devel::FindPerl::find_perl_interpreter();
201 0 ▶ $perl =~ s{\\}{/}g if $^O eq 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 0 0
202 0 $perl;
203 60 }, 'Devel::FindPerl' );
204  
205  
206 60 $self->add_helper( pkgconf => undef, 'Alien::pkgconf' => 0.06 );
207  
208  
209 1 ▶ $self->add_helper( cwd => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
210 1 my $cwd = "$CWD";
211 1 ▶ $cwd =~ s{\\}{/}g if $^O eq 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 1 1
212 1 $cwd;
213 60 } );
214  
215  
216 0 ▶ $self->add_helper( sh => sub { 'sh' }, 'Alien::MSYS' => '0.07' );
Subroutine __ANON__: not called CC=1 SCAR=1.2
217  
218  
219 0 ▶ $self->add_helper( rm => sub { _config 'rm' }, 'Config' );
Subroutine __ANON__: not called CC=1 SCAR=1.2
220  
221  
222  
223 0 ▶ $self->add_helper( xz => undef, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
224 0 my $helper = shift;
225 0 ▶ if(which 'xz')
Branch: 1 branch
BranchTrueFalseTotal
if (which('xz')) { } 0 0 0
226 {
227 0 ▶ $helper->code(sub { 'xz' });
Subroutine __ANON__: not called CC=1 SCAR=6.9
228 0 return ();
229 }
230 else
231 {
232 0 return 'Alien::xz' => '0.02';
233 }
234 60 });
235  
236 60 $self;
237 }
238  
239 13 1;
240  
241 __END__
« blib/lib/Alien/Build/Plugin/Build/SearchDep.pm ↑ Summary blib/lib/Alien/Build/Plugin/Probe/Vcpkg.pm »