blib/lib/Alien/Build/MM.pm

filter: Statementstmt 77.8% 137 / 176 Branchbran 52.5% 21 / 40 Conditioncond 56.0% 14 / 25 MC/DCmcdc 25.0% 3 / 12 Subroutinesub 80.0% 20 / 25 Podpod 100% 7 / 7 totaltotal 70.8% 202 / 285 CC 34 SCAR 24.3
CC
34
Cov
71%
mm_args
27.9
__ANON__
11.2
__ANON__
6.0
CRAP 11.4
« blib/lib/Alien/Build/Plugin/Probe/CommandLine.pm ↑ Summary blib/lib/Alien/Util.pm »
1 package Alien::Build::MM;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Alien::Build;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Path::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Capture::Tiny qw( capture );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ABSTRACT: Alien::Build installer code for ExtUtils::MakeMaker
12 2 our $VERSION = '2.88'; # VERSION
13  
14  
15 sub new
16 9 ▶{
Subroutine new: called CC=4 SCAR=14.6
Pod documented
17 9 my($class, %prop) = @_;
18  
19 9 my $self = bless {}, $class;
20  
21 0 my %meta = map { $_ => $prop{$_} } grep /^my_/, keys %prop;
22  
23 my $build = $self->{build} =
24 9 ▶ Alien::Build->load('alienfile',
Branch: 1 branch
BranchTrueFalseTotal
-d 'patch' ? : 1 8 9
25 root => "_alien",
26 (-d 'patch' ? (patch => 'patch') : ()),
27 meta_prop => \%meta,
28 )
29 ;
30  
31 9 ▶ if(%meta)
Branch: 1 branch
BranchTrueFalseTotal
if (%meta) 0 9 9
32 {
33 0 $build->meta->add_requires(configure => 'Alien::Build::MM' => '1.20');
34 0 $build->meta->add_requires(configure => 'Alien::Build' => '1.20');
35 }
36  
37 9 ▶ if(defined $prop{alienfile_meta})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $prop{'alienfile_meta'}) { } 0 9 9
38 {
39 0 $self->{alienfile_meta} = $prop{alienfile_meta};
40 }
41 else
42 {
43 9 $self->{alienfile_meta} = 1;
44 }
45  
46 9 $self->{clean_install} = $prop{clean_install};
47  
48 9 $self->build->load_requires('configure');
49 9 $self->build->root;
50 9 $self->build->checkpoint;
51  
52 9 $self;
53 }
54  
55  
56 sub build
57 104 ▶{
Subroutine build: called CC=1 SCAR=0.0
Pod documented
58 104 shift->{build};
59 }
60  
61  
62 sub alienfile_meta
63 8 ▶{
Subroutine alienfile_meta: called CC=1 SCAR=0.0
Pod documented
64 8 shift->{alienfile_meta};
65 }
66  
67  
68 sub clean_install
69 9 ▶{
Subroutine clean_install: called CC=1 SCAR=0.0
Pod documented
70 9 shift->{clean_install};
71 }
72  
73  
74 sub mm_args
75 8 ▶{
Subroutine mm_args: called CC=18 SCAR=33.3
Pod documented
76 8 my($self, %args) = @_;
77  
78 8 ▶ if($args{DISTNAME})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'DISTNAME'}) { } 8 0 8
79 {
80 8 $self->build->set_stage(Path::Tiny->new("blib/lib/auto/share/dist/$args{DISTNAME}")->absolute->stringify);
81 8 $self->build->install_prop->{mm}->{distname} = $args{DISTNAME};
82 8 my $module = $args{DISTNAME};
83 8 $module =~ s/-/::/g;
84 # See if there is an existing version installed, without pulling it into this process
85 8 ▶ my($old_prefix, $err, $ret) = capture { system $^X, "-M$module", -e => "print $module->dist_dir"; $? };
Subroutine __ANON__: called CC=1 SCAR=0.0
86 8 ▶ if($ret == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($ret == 0) 0 8 8
87 {
88 0 chomp $old_prefix;
89 0 my $file = Path::Tiny->new($old_prefix, qw( _alien alien.json ));
90 0 ▶ if(-r $file)
Branch: 1 branch
BranchTrueFalseTotal
if (-r $file) 0 0 0
91 {
92 0 my $old_runtime = eval {
93 0 require JSON::PP;
94 0 JSON::PP::decode_json($file->slurp);
95 };
96 0 ▶ unless($@)
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 0 0 0
97 {
98 0 $self->build->install_prop->{old}->{runtime} = $old_runtime;
99 0 $self->build->install_prop->{old}->{prefix} = $old_prefix;
100 }
101 }
102 }
103 }
104 else
105 {
106 0 Carp::croak "DISTNAME is required";
107 }
108  
109 8 my $ab_version = '0.25';
110  
111 8 ▶ if($self->clean_install)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->clean_install) 1 7 8
112 {
113 1 $ab_version = '1.74';
114 }
115  
116 $args{CONFIGURE_REQUIRES} = Alien::Build::_merge(
117 'Alien::Build::MM' => $ab_version,
118 8 ▶ %{ $args{CONFIGURE_REQUIRES} || {} },
Condition100%2/2
$args{'CONFIGURE_REQUIRES'} || {}
l!l
26
MC/DC100%1/1
$args{'CONFIGURE_REQUIRES'} || {}
$args{'CONFIGURE_REQUIRES'}
Truth table100%2/2
A
A= $args{'CONFIGURE_REQUIRES'}
Aresult
11
00
119 8 ▶ %{ $self->build->requires('configure') || {} },
Condition50%1/2
$self->build->requires('configure') || {}
l!l
80
MC/DC0%0/1
$self->build->requires('configure') || {}
$self->build->requires('configure')
Truth table50%1/2
A
A= $self->build->requires('configure')
Aresult
11
00
120 );
121  
122 8 ▶ if($self->build->install_type eq 'system')
Branch: 2 branches
BranchTrueFalseTotal
if ($self->build->install_type eq 'system') { } 2 6 8
elsif ($self->build->install_type eq 'share') { } 6 0 6
123 {
124 $args{BUILD_REQUIRES} = Alien::Build::_merge(
125 'Alien::Build::MM' => $ab_version,
126 2 ▶ %{ $args{BUILD_REQUIRES} || {} },
Condition100%2/2
$args{'BUILD_REQUIRES'} || {}
l!l
11
MC/DC100%1/1
$args{'BUILD_REQUIRES'} || {}
$args{'BUILD_REQUIRES'}
Truth table100%2/2
A
A= $args{'BUILD_REQUIRES'}
Aresult
11
00
127 2 ▶ %{ $self->build->requires('system') || {} },
Condition50%1/2
$self->build->requires('system') || {}
l!l
20
MC/DC0%0/1
$self->build->requires('system') || {}
$self->build->requires('system')
Truth table50%1/2
A
A= $self->build->requires('system')
Aresult
11
00
128 );
129 }
130 elsif($self->build->install_type eq 'share')
131 {
132 $args{BUILD_REQUIRES} = Alien::Build::_merge(
133 'Alien::Build::MM' => $ab_version,
134 6 ▶ %{ $args{BUILD_REQUIRES} || {} },
Condition100%2/2
$args{'BUILD_REQUIRES'} || {}
l!l
15
MC/DC100%1/1
$args{'BUILD_REQUIRES'} || {}
$args{'BUILD_REQUIRES'}
Truth table100%2/2
A
A= $args{'BUILD_REQUIRES'}
Aresult
11
00
135 6 ▶ %{ $self->build->requires('share') || {} },
Condition50%1/2
$self->build->requires('share') || {}
l!l
60
MC/DC0%0/1
$self->build->requires('share') || {}
$self->build->requires('share')
Truth table50%1/2
A
A= $self->build->requires('share')
Aresult
11
00
136 );
137 }
138 else
139 {
140 0 die "unknown install type: @{[ $self->build->install_type ]}"
141 }
142  
143 $args{PREREQ_PM} = Alien::Build::_merge(
144 'Alien::Build' => $ab_version,
145 8 ▶ %{ $args{PREREQ_PM} || {} },
Condition50%1/2
$args{'PREREQ_PM'} || {}
l!l
08
MC/DC0%0/1
$args{'PREREQ_PM'} || {}
$args{'PREREQ_PM'}
Truth table50%1/2
A
A= $args{'PREREQ_PM'}
Aresult
11
00
146 );
147  
148 #$args{META_MERGE}->{'meta-spec'}->{version} = 2;
149 8 $args{META_MERGE}->{dynamic_config} = 1;
150  
151 8 ▶ if($self->alienfile_meta)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->alienfile_meta) 8 0 8
152 {
153 $args{META_MERGE}->{x_alienfile} = {
154 8 ▶ generated_by => "@{[ __PACKAGE__ ]} version @{[ __PACKAGE__->VERSION || 'dev' ]}",
Condition50%1/2
__PACKAGE__->VERSION || 'dev'
l!l
80
MC/DC0%0/1
__PACKAGE__->VERSION || 'dev'
__PACKAGE__->VERSION
Truth table50%1/2
A
A= __PACKAGE__->VERSION
Aresult
11
00
155 requires => {
156 map {
157 8 my %reqs = %{ $self->build->requires($_) };
158 16 $reqs{$_} = "$reqs{$_}" for keys %reqs;
159 16 $_ => \%reqs;
160 } qw( share system )
161 },
162 };
163 }
164  
165 8 $self->build->checkpoint;
166 8 %args;
167 }
168  
169  
170 sub mm_postamble
171 1 ▶{
Subroutine mm_postamble: called CC=2 SCAR=6.9
Pod documented
172 # NOTE: older versions of the Alien::Build::MM documentation
173 # didn't include $mm and @rest args, so anything that this
174 # method uses them for has to be optional.
175 # (as of this writing they are unused, but are being added
176 # to match the way mm_install works).
177  
178 1 my($self, $mm, @rest) = @_;
179  
180 1 my $postamble = '';
181  
182 # remove the _alien directory on a make realclean:
183 1 $postamble .= "realclean :: alien_realclean\n" .
184 "\n" .
185 "alien_realclean:\n" .
186 "\t\$(RM_RF) _alien\n\n";
187  
188 # remove the _alien directory on a make clean:
189 1 $postamble .= "clean :: alien_clean\n" .
190 "\n" .
191 "alien_clean:\n" .
192 "\t\$(RM_RF) _alien\n\n";
193  
194 my $dirs = $self->build->meta_prop->{arch}
195 1 ▶ ? '$(INSTALLARCHLIB) $(INSTALLSITEARCH) $(INSTALLVENDORARCH)'
Branch: 1 branch
BranchTrueFalseTotal
$self->build->meta_prop->{'arch'} ? : 1 0 1
196 : '$(INSTALLPRIVLIB) $(INSTALLSITELIB) $(INSTALLVENDORLIB)'
197 ;
198  
199 # set prefix
200 1 $postamble .= "alien_prefix : _alien/mm/prefix\n\n" .
201 "_alien/mm/prefix :\n" .
202 "\t\$(FULLPERL) -MAlien::Build::MM=cmd -e prefix \$(INSTALLDIRS) $dirs\n\n";
203  
204 # set version
205 1 $postamble .= "alien_version : _alien/mm/version\n\n" .
206 "_alien/mm/version : _alien/mm/prefix\n" .
207 "\t\$(FULLPERL) -MAlien::Build::MM=cmd -e version \$(VERSION)\n\n";
208  
209 # download
210 1 $postamble .= "alien_download : _alien/mm/download\n\n" .
211 "_alien/mm/download : _alien/mm/prefix _alien/mm/version\n" .
212 "\t\$(FULLPERL) -MAlien::Build::MM=cmd -e download\n\n";
213  
214 # build
215 1 $postamble .= "alien_build : _alien/mm/build\n\n" .
216 "_alien/mm/build : _alien/mm/download\n" .
217 "\t\$(FULLPERL) -MAlien::Build::MM=cmd -e build\n\n";
218  
219 # append to all
220 1 $postamble .= "pure_all :: _alien/mm/build\n\n";
221  
222 1 $postamble .= "subdirs-test_dynamic subdirs-test_static subdirs-test :: alien_test\n\n";
223 1 $postamble .= "alien_test :\n" .
224 "\t\$(FULLPERL) -MAlien::Build::MM=cmd -e test\n\n";
225  
226 # prop
227 1 $postamble .= "alien_prop :\n" .
228 "\t\$(FULLPERL) -MAlien::Build::MM=cmd -e dumpprop\n\n";
229 1 $postamble .= "alien_prop_meta :\n" .
230 "\t\$(FULLPERL) -MAlien::Build::MM=cmd -e dumpprop meta\n\n";
231 1 $postamble .= "alien_prop_install :\n" .
232 "\t\$(FULLPERL) -MAlien::Build::MM=cmd -e dumpprop install\n\n";
233 1 $postamble .= "alien_prop_runtime :\n" .
234 "\t\$(FULLPERL) -MAlien::Build::MM=cmd -e dumpprop runtime\n\n";
235  
236 # install
237 1 $postamble .= "alien_clean_install : _alien/mm/prefix\n" .
238 "\t\$(FULLPERL) -MAlien::Build::MM=cmd -e clean_install\n\n";
239  
240 1 $postamble;
241 }
242  
243  
244 sub mm_install
245 0 ▶{
Subroutine mm_install: not called CC=1 SCAR=6.9
Pod documented
246 # NOTE: older versions of the Alien::Build::MM documentation
247 # didn't include this method, so anything that this method
248 # does has to be optional
249  
250 0 my($self, $mm, @rest) = @_;
251  
252 0 my $section = do {
253 package
254 MY;
255 0 $mm->SUPER::install(@rest);
256 };
257  
258 return
259 0 ".NOTPARALLEL : \n\n"
260 . ".NO_PARALLEL : \n\n"
261 . "install :: alien_clean_install\n\n"
262 . $section;
263 }
264  
265 sub import
266 1 ▶{
Subroutine import: called CC=3 SCAR=12.4
267 1 my(undef, @args) = @_;
268 1 foreach my $arg (@args)
269 {
270 1 ▶ if($arg eq 'cmd')
Branch: 1 branch
BranchTrueFalseTotal
if ($arg eq "cmd") 1 0 1
271 {
272 package main;
273  
274 *_args = sub
275 8 ▶ {
Subroutine __ANON__: called CC=1 SCAR=0.0
276 8 my $build = Alien::Build->resume('alienfile', '_alien');
277 8 $build->load_requires('configure');
278 8 $build->load_requires($build->install_type);
279 8 ($build, @ARGV)
280 1 };
281  
282 6 ▶ *_touch = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
283 6 my($name) = @_;
284 6 my $path = Path::Tiny->new("_alien/mm/$name");
285 6 $path->parent->mkpath;
286 6 $path->touch;
287 1 };
288  
289 *prefix = sub
290 4 ▶ {
Subroutine __ANON__: called CC=4 SCAR=13.9
291 4 my($build, $type, $perl, $site, $vendor) = _args();
292  
293 4 my $distname = $build->install_prop->{mm}->{distname};
294  
295 4 ▶ my $prefix = $type eq 'perl'
Branch: 3 branches
BranchTrueFalseTotal
$type eq 'perl' ? : 2 2 4
$type eq 'site' ? : 1 1 2
$type eq 'vendor' ? : 1 0 1
296 ? $perl
297 : $type eq 'site'
298 ? $site
299 : $type eq 'vendor'
300 ? $vendor
301 : die "unknown INSTALLDIRS ($type)";
302 4 $prefix = Path::Tiny->new($prefix)->child("auto/share/dist/$distname")->absolute->stringify;
303  
304 4 $build->log("prefix $prefix");
305 4 $build->set_prefix($prefix);
306 4 $build->checkpoint;
307 4 _touch('prefix');
308 1 };
309  
310 *version = sub
311 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
312 0 my($build, $version) = _args();
313  
314 0 $build->runtime_prop->{perl_module_version} = $version;
315 0 $build->checkpoint;
316 0 _touch('version');
317 1 };
318  
319 *download = sub
320 1 ▶ {
Subroutine __ANON__: called CC=1 SCAR=0.0
321 1 my($build) = _args();
322 1 $build->download;
323 1 $build->checkpoint;
324 1 _touch('download');
325 1 };
326  
327 *build = sub
328 1 ▶ {
Subroutine __ANON__: called CC=7 SCAR=24.2
329 1 my($build) = _args();
330  
331 1 $build->build;
332  
333 1 my $distname = $build->install_prop->{mm}->{distname};
334  
335 1 ▶ if($build->meta_prop->{arch})
Branch: 1 branch
BranchTrueFalseTotal
if ($build->meta_prop->{"arch"}) 1 0 1
336 {
337 1 my $archdir = Path::Tiny->new("blib/arch/auto/@{[ join '/', split /-/, $distname ]}");
338 1 $archdir->mkpath;
339 1 my $archfile = $archdir->child($archdir->basename . '.txt');
340 1 $archfile->spew('Alien based distribution with architecture specific file in share');
341 }
342  
343 1 my $cflags = $build->runtime_prop->{cflags};
344 1 my $libs = $build->runtime_prop->{libs};
345  
346 1 ▶ if(($cflags && $cflags !~ /^\s*$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($cflags and not $cflags =~ /^\s*$/ or $libs and not $libs =~ /^\s*$/) 0 1 1
Condition33%3/9
$cflags and not $cflags =~ /^\s*$/ or $libs and not $libs =~ /^\s*$/
l!l&&r!l&&!r
001
$cflags and not $cflags =~ /^\s*$/
!ll&&!rl&&r
100
$libs and not $libs =~ /^\s*$/
!ll&&!rl&&r
100
MC/DC0%0/4
$cflags and not $cflags =~ /^\s*$/ or $libs and not $libs =~ /^\s*$/
$cflags not $cflags =~ /^\s*$/ $libs not $libs =~ /^\s*$/
Truth table14%1/7
A and not(B) or C and not(D)
A= $cflagsB= not $cflags =~ /^\s*$/C= $libsD= not $libs =~ /^\s*$/
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
347 || ($libs && $libs !~ /^\s*$/))
348 {
349 0 my $mod = join '::', split /-/, $distname;
350 0 my $install_files_pm = Path::Tiny->new("blib/lib/@{[ join '/', split /-/, $distname ]}/Install/Files.pm");
351 0 $install_files_pm->parent->mkpath;
352 0 ▶ $install_files_pm->spew(
Branch: 1 branch
BranchTrueFalseTotal
unless -f "$install_files_pm" 0 0 0
353 "package ${mod}::Install::Files;\n",
354 "use strict;\n",
355 "use warnings;\n",
356 "require ${mod};\n",
357 "sub Inline { shift; ${mod}->Inline(\@_) }\n",
358 "1;\n",
359 "\n",
360 "=begin Pod::Coverage\n",
361 "\n",
362 " Inline\n",
363 "\n",
364 "=cut\n",
365 ) unless -f "$install_files_pm";
366 }
367  
368 1 $build->checkpoint;
369 1 _touch('build');
370 1 };
371  
372 *test = sub
373 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
374 0 my($build) = _args();
375 0 $build->test;
376 0 $build->checkpoint;
377 1 };
378  
379 *clean_install = sub
380 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
381 0 my($build) = _args();
382 0 $build->clean_install;
383 0 $build->checkpoint;
384 1 };
385  
386 *dumpprop = sub
387 0 ▶ {
Subroutine __ANON__: not called CC=2 SCAR=17.9
388 0 my($build, $type) = _args();
389  
390 0 my %h = (
391 meta => $build->meta_prop,
392 install => $build->install_prop,
393 runtime => $build->runtime_prop,
394 );
395  
396 0 require Alien::Build::Util;
397 0 ▶ print Alien::Build::Util::_dump($type ? $h{$type} : \%h);
Branch: 1 branch
BranchTrueFalseTotal
$type ? : 0 0 0
398 }
399 1 }
400 }
401 }
402  
403 2 1;
404  
405 __END__
« blib/lib/Alien/Build/Plugin/Probe/CommandLine.pm ↑ Summary blib/lib/Alien/Util.pm »