blib/lib/Alien/Build/Plugin/Gather/IsolateDynamic.pm

filter: Statementstmt 100% 46 / 46 Branchbran 70.0% 7 / 10 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 95.7% 68 / 71 CC 9 SCAR 16.6
CC
9
Cov
95%
__ANON__
9.1
init
1.0
BEGIN
1.0
CRAP 5.3
« blib/lib/Alien/Build/Plugin/Decode/Mojo.pm ↑ Summary blib/lib/Alien/Build/Plugin/Core/Gather.pm »
1 package Alien::Build::Plugin::Gather::IsolateDynamic;
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 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Alien::Build::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Path::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Alien::Build::Util qw( _destdir_prefix );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use File::Copy ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ABSTRACT: Plugin to gather dynamic libraries into a separate directory
12 4 our $VERSION = '2.88'; # VERSION
13  
14  
15 sub init
16 11 ▶{
Subroutine init: called CC=1 SCAR=0.0
Pod documented
17 11 my($self, $meta) = @_;
18  
19 # plugin was introduced in 0.42, but had a bug which was fixed in 0.48
20 11 $meta->add_requires('share' => 'Alien::Build::Plugin::Gather::IsolateDynamic' => '0.48' );
21  
22 $meta->after_hook(
23 4 ▶ gather_share => sub {
Subroutine __ANON__: called CC=9 SCAR=22.0
24 4 my($build) = @_;
25 4 $build->log("Isolating dynamic libraries ...");
26  
27 4 my $install_root;
28 4 ▶ if($build->meta_prop->{destdir})
Branch: 1 branch
BranchTrueFalseTotal
if ($build->meta_prop->{'destdir'}) { } 3 1 4
29 {
30 3 my $destdir = $ENV{DESTDIR};
31 3 $install_root = Path::Tiny->new(_destdir_prefix($ENV{DESTDIR}, $build->install_prop->{prefix}));
32 }
33 else
34 {
35 1 $install_root = Path::Tiny->new($build->install_prop->{stage});
36 }
37  
38 4 foreach my $dir (map { $install_root->child($_) } qw( bin lib ))
39 {
40 8 ▶ next unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 8 8
41 8 foreach my $from ($dir->children)
42 {
43 22 ▶ next unless $from->basename =~ /\.so/
Branch: 1 branch
BranchTrueFalseTotal
unless $from->basename =~ /\.so/ or $from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/ 10 12 22
Condition100%3/3
$from->basename =~ /\.so/ or $from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/
l!l&&r!l&&!r
21010
MC/DC100%2/2
$from->basename =~ /\.so/ or $from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/
$from->basename =~ /\.so/ $from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/
Truth table100%3/3
A or B
A= $from->basename =~ /\.so/B= $from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/
ABresult
1X1
011
000
44 || $from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/;
45 12 my $to = $install_root->child('dynamic', $from->basename);
46 12 $to->parent->mkpath;
47 12 ▶ unlink "$to" if -e $to;
Branch: 1 branch
BranchTrueFalseTotal
if -e $to 0 12 12
48 12 $build->log("move @{[ $from->parent->basename ]}/@{[ $from->basename ]} => dynamic/@{[ $to->basename ]}");
49 12 ▶ File::Copy::move("$from", "$to") || die "unable to move $from => $to $!";
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::move("$from", "$to") or die "unable to move $from => $to $!" 12 0 12
50 }
51 }
52  
53 4 $build->log(" Done!");
54 },
55 11 );
56 }
57  
58 4 1;
59  
60 __END__
« blib/lib/Alien/Build/Plugin/Decode/Mojo.pm ↑ Summary blib/lib/Alien/Build/Plugin/Core/Gather.pm »