Linker.pm

filter: Statementstmt 74.1% 69 / 93 Branchbran 50.0% 4 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 76.1% 16 / 21 Podpod 38.4% 5 / 13 totaltotal 68.8% 95 / 138 CC 7 SCAR 6.3
CC
7
Cov
72%
pre_action
3.9
link
3.0
add_profile
2.0
CRAP 1.9
« AutoDetect/C.pm ↑ Summary Binary.pm »
1 package ExtUtils::Builder::Linker;
2 3 $ExtUtils::Builder::Linker::VERSION = '0.038';
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use parent qw/ExtUtils::Builder::ArgumentCollector ExtUtils::Builder::Binary/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use ExtUtils::Builder::Node;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use ExtUtils::Builder::Util qw/command function require_module/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use File::Basename 'dirname';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 my %allowed_export = map { $_ => 1 } qw/none some all/;
15  
16 5 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
17 5 my ($class, %args) = @_;
18 5 my $self = bless {}, $class;
19 5 $self->_init(%args);
20 5 return $self;
21 }
22  
23 5 ▶sub _init {
Subroutine _init: called CC=2 SCAR=6.9
24 5 my ($self, %args) = @_;
25 5 $self->ExtUtils::Builder::ArgumentCollector::_init(%args);
26 5 $self->ExtUtils::Builder::Binary::_init(%args);
27  
28 5 my $export = $args{export};
29 5 ▶ Carp::croak("'$export' is not an allowed export value") if not $allowed_export{$export};
Branch: 1 branch
BranchTrueFalseTotal
unless $allowed_export{$export} 0 5 5
30 5 $self->{export} = $export;
31  
32 5 $self->{ld} = $args{ld};
33 5 $self->{library_dirs} = [];
34 5 $self->{libraries} = [];
35 5 $self->{option_filters} = [];
36  
37 5 return;
38 }
39  
40 8 ▶sub export {
Subroutine export: called CC=1 SCAR=0.0
Pod documented
41 8 my $self = shift;
42 8 return $self->{export};
43 }
44  
45 5 ▶sub ld {
Subroutine ld: called CC=1 SCAR=0.0
Pod undocumented
46 5 my $self = shift;
47 5 return @{ $self->{ld} };
48 }
49  
50 5 ▶sub collect_arguments {
Subroutine collect_arguments: called CC=1 SCAR=0.0
Pod undocumented
51 5 my ($self, @args) = @_;
52 5 return ($self->SUPER::collect_arguments(@args), $self->linker_flags(@args));
53 }
54  
55 0 ▶sub add_library_dirs {
Subroutine add_library_dirs: not called CC=1 SCAR=6.9
Pod documented
56 0 my ($self, $dirs, %opts) = @_;
57 0 my $ranking = $self->fix_ranking($self->default_libdir_ranking, $opts{ranking});
58 0 push @{ $self->{library_dirs} }, map { { ranking => $ranking, value => $_ } } @{ $dirs };
59 0 return;
60 }
61  
62 0 ▶sub default_libdir_ranking {
Subroutine default_libdir_ranking: not called CC=1 SCAR=6.9
Pod undocumented
63 0 return 30;
64 }
65  
66 0 ▶sub add_libraries {
Subroutine add_libraries: not called CC=1 SCAR=6.9
Pod documented
67 0 my ($self, $dirs, %opts) = @_;
68 0 my $ranking = $self->fix_ranking($self->default_library_ranking, $opts{ranking});
69 0 push @{ $self->{libraries} }, map { { ranking => $ranking, value => $_ } } @{ $dirs };
70 0 return;
71 }
72  
73 0 ▶sub default_library_ranking {
Subroutine default_library_ranking: not called CC=1 SCAR=6.9
Pod undocumented
74 0 return 75;
75 }
76  
77 0 ▶sub add_option_filter {
Subroutine add_option_filter: not called CC=1 SCAR=6.9
Pod undocumented
78 0 my ($self, $filter) = @_;
79 0 push @{ $self->{option_filters} }, $filter;
80 0 return;
81 }
82  
83 1 ▶sub add_profile {
Subroutine add_profile: called CC=2 SCAR=7.0
Pod undocumented
84 1 my ($self, $profile, %args) = @_;
85 1 ▶ if (not ref($profile)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $profile) 1 0 1
86 1 $profile =~ s/ \A @ /ExtUtils::Builder::Profile::/xms;
87 1 require_module($profile);
88 }
89 1 return $profile->process_linker($self, \%args);
90 }
91  
92 3 my %key_for = (
93 dl_vars => 'DL_VARS',
94 dl_funcs => 'DL_FUNCS',
95 dl_func_list => 'FUNCLIST',
96 dl_imports => 'IMPORTS',
97 dl_name => 'NAME',
98 dl_base => 'DLBASE',
99 dl_file => 'FILE',
100 );
101 5 ▶sub pre_action {
Subroutine pre_action: called CC=3 SCAR=13.6
Pod undocumented
102 5 my ($self, $from, $to, %opts) = @_;
103 5 my @result;
104 5 ▶ push @result, $self->_mkdir_for($to) if $opts{mkdir};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"mkdir"} 0 5 5
105 5 ▶ if ($self->export eq 'some') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->export eq "some") 0 5 5
106 0 my %args = map { $key_for{$_} => $opts{$_} } grep { exists $key_for{$_} } keys %opts;
107 0 push @result, function(
108 module => 'ExtUtils::Mksymlists',
109 function => 'Mksymlists',
110 message => join(' ', 'prelink', $to, %args),
111 arguments => [ %args ],
112 exports => 1,
113 );
114 }
115 5 return @result;
116 }
117 5 ▶sub post_action { }
Subroutine post_action: called CC=1 SCAR=0.0
Pod undocumented
118  
119 5 ▶sub link {
Subroutine link: called CC=3 SCAR=11.0
Pod documented
120 5 my ($self, @args) = @_;
121 5 @args = $self->$_(@args) for @{ $self->{option_filters} };
122 5 my ($from, $to, %opts) = @args;
123 5 my @argv = $self->arguments(@args);
124 5 my $main = command($self->ld, @argv);
125 5 my @actions = ($self->pre_action(@args), $main, $self->post_action(@args));
126 5 ▶ my $deps = [ @{$from}, @{ $opts{dependencies} // [] } ];
Condition50%1/2
$opts{"dependencies"} // []
l!l
05
MC/DC0%0/1
$opts{"dependencies"} // []
$opts{"dependencies"}
Truth table50%1/2
A
A= $opts{"dependencies"}
Aresult
11
00
127 5 return ExtUtils::Builder::Node->new(target => $to, dependencies => $deps, actions => \@actions);
128 }
129  
130 3 1;
131  
132 # ABSTRACT: An interface around different linkers.
133  
134 __END__
« AutoDetect/C.pm ↑ Summary Binary.pm »