CBuilder/Base.pm

filter: Statementstmt 89.8% 176 / 196 Branchbran 74.4% 70 / 94 Conditioncond 79.3% 23 / 29 MC/DCmcdc 52.9% 9 / 17 Subroutinesub 94.7% 36 / 38 Podpod 0.0% 0 / 26 totaltotal 78.5% 314 / 400 CC 64 SCAR 22.4
CC
64
Cov
84%
new
31.2
compile
10.0
_do_link
8.9
CRAP 9.4
« CBuilder/Platform/os2.pm ↑ Summary CBuilder/Platform/Windows/BCC.pm »
1 package ExtUtils::CBuilder::Base;
2 5 $ExtUtils::CBuilder::Base::VERSION = '0.280224';
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Cwd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Text::ParseWords;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use IPC::Cmd qw(can_run);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use File::Temp qw(tempfile);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # More details about C/C++ compilers:
14 # http://developers.sun.com/sunstudio/documentation/product/compiler.jsp
15 # http://gcc.gnu.org/
16 # http://publib.boulder.ibm.com/infocenter/comphelp/v101v121/index.jsp
17 # http://msdn.microsoft.com/en-us/vstudio/default.aspx
18  
19 5 my %cc2cxx = (
20 # first line order is important to support wrappers like in pkgsrc
21 cc => [ 'c++', 'CC', 'aCC', 'cxx', ], # Sun Studio, HP ANSI C/C++ Compilers
22 gcc => [ 'g++' ], # GNU Compiler Collection
23 xlc => [ 'xlC' ], # IBM C/C++ Set, xlc without thread-safety
24 xlc_r => [ 'xlC_r' ], # IBM C/C++ Set, xlc with thread-safety
25 cl => [ 'cl' ], # Microsoft Visual Studio
26 );
27  
28 sub new {
29 20 ▶ my $class = shift;
Subroutine new: called CC=17 SCAR=34.4
Pod undocumented
30 20 my $self = bless {@_}, $class;
31  
32 20 ▶ $self->{properties}{perl} = $class->find_perl_interpreter
Branch: 1 branch
BranchTrueFalseTotal
$self->{"properties"}{"perl"} = $class->find_perl_interpreter or warn "Warning: Can't locate your perl binary" 0 20 20
33 or warn "Warning: Can't locate your perl binary";
34  
35 20 ▶ while (my ($k,$v) = each %Config) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %ExtUtils::CBuilder::Base::Config) 25120 20 25140
36 25120 ▶ $self->{config}{$k} = $v unless exists $self->{config}{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"config"}{$k} 25117 3 25120
37 }
38 20 ▶ $self->{config}{cc} = $ENV{CC} if defined $ENV{CC};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"CC"} 1 19 20
39 $self->{config}{ccflags} = join(" ", $self->{config}{ccflags}, $ENV{CFLAGS})
40 20 ▶ if defined $ENV{CFLAGS};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"CFLAGS"} 1 19 20
41 20 ▶ $self->{config}{cxx} = $ENV{CXX} if defined $ENV{CXX};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"CXX"} 0 20 20
42 20 ▶ $self->{config}{cxxflags} = $ENV{CXXFLAGS} if defined $ENV{CXXFLAGS};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"CXXFLAGS"} 0 20 20
43 20 ▶ $self->{config}{ld} = $ENV{LD} if defined $ENV{LD};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"LD"} 0 20 20
44 $self->{config}{ldflags} = join(" ", $self->{config}{ldflags}, $ENV{LDFLAGS})
45 20 ▶ if defined $ENV{LDFLAGS};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"LDFLAGS"} 1 19 20
46  
47 20 ▶ unless ( exists $self->{config}{cxx} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"config"}{"cxx"}) 20 0 20
48 20 my ($ccpath, $ccbase, $ccsfx ) = fileparse($self->{config}{cc}, qr/\.[^.]*/);
49 20 foreach my $cxx (@{$cc2cxx{$ccbase}}) {
50 0 ▶ if( can_run( File::Spec->catfile( $ccpath, $cxx, $ccsfx ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (can_run("File::Spec"->catfile($ccpath, $cxx, $ccsfx))) 0 0 0
51 0 $self->{config}{cxx} = File::Spec->catfile( $ccpath, $cxx, $ccsfx );
52 0 last;
53 }
54 0 ▶ if( can_run( File::Spec->catfile( $cxx, $ccsfx ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (can_run("File::Spec"->catfile($cxx, $ccsfx))) 0 0 0
55 0 $self->{config}{cxx} = File::Spec->catfile( $cxx, $ccsfx );
56 0 last;
57 }
58 0 ▶ if( can_run( $cxx ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (can_run($cxx)) 0 0 0
59 0 $self->{config}{cxx} = $cxx;
60 0 last;
61 }
62 }
63 20 ▶ unless ( exists $self->{config}{cxx} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"config"}{"cxx"}) 20 0 20
64 20 $self->{config}{cxx} = $self->{config}{cc};
65 20 my $cflags = $self->{config}{ccflags};
66 20 $self->{config}{cxxflags} = '-x c++';
67 20 ▶ $self->{config}{cxxflags} .= " $cflags" if defined $cflags;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cflags 20 0 20
68 }
69 }
70  
71 20 return $self;
72 }
73  
74 sub find_perl_interpreter {
75 22 ▶ my $perl;
Subroutine find_perl_interpreter: called CC=3 SCAR=11.4
Pod undocumented
76 File::Spec->file_name_is_absolute($perl = $^X)
77 or -f ($perl = $Config::Config{perlpath})
78 22 ▶ or ($perl = $^X); # XXX how about using IPC::Cmd::can_run here?
Branch: 1 branch
BranchTrueFalseTotal
"File::Spec"->file_name_is_absolute($perl = $^X) or -f ($perl = $Config::Config{"perlpath"}) or $perl = $^X 0 22 22
Condition66%2/3
"File::Spec"->file_name_is_absolute($perl = $^X) or -f ($perl = $Config::Config{"perlpath"})
l!l&&r!l&&!r
2110
MC/DC0%0/2
"File::Spec"->file_name_is_absolute($perl = $^X) or -f ($perl = $Config::Config{"perlpath"})
"File::Spec"->file_name_is_absolute($perl = $^X) -f ($perl = $Config::Config{"perlpath"})
Truth table66%2/3
A or B
A= "File::Spec"->file_name_is_absolute($perl = $^X)B= -f ($perl = $Config::Config{"perlpath"})
ABresult
1X1
011
000
79 22 return $perl;
80 }
81  
82 sub add_to_cleanup {
83 1 ▶ my $self = shift;
Subroutine add_to_cleanup: called CC=2 SCAR=6.9
Pod undocumented
84 1 foreach (@_) {
85 1 $self->{files_to_clean}{$_} = 1;
86 }
87 }
88  
89 sub cleanup {
90 21 ▶ my $self = shift;
Subroutine cleanup: called CC=2 SCAR=6.9
Pod undocumented
91 21 foreach my $file (keys %{$self->{files_to_clean}}) {
92 2 unlink $file;
93 }
94 }
95  
96 sub get_config {
97 0 ▶ return %{ $_[0]->{config} };
Subroutine get_config: not called CC=1 SCAR=6.9
Pod undocumented
98 }
99  
100 sub object_file {
101 13 ▶ my ($self, $filename) = @_;
Subroutine object_file: called CC=1 SCAR=0.0
Pod undocumented
102  
103 # File name, minus the suffix
104 13 (my $file_base = $filename) =~ s/\.[^.]+$//;
105 13 return "$file_base$self->{config}{obj_ext}";
106 }
107  
108 sub arg_include_dirs {
109 12 ▶ my $self = shift;
Subroutine arg_include_dirs: called CC=1 SCAR=0.0
Pod undocumented
110 12 return map {"-I$_"} @_;
111 }
112  
113 12 ▶sub arg_nolink { '-c' }
Subroutine arg_nolink: called CC=1 SCAR=0.0
Pod undocumented
114  
115 sub arg_object_file {
116 12 ▶ my ($self, $file) = @_;
Subroutine arg_object_file: called CC=1 SCAR=0.0
Pod undocumented
117 12 return ('-o', $file);
118 }
119  
120 sub arg_share_object_file {
121 6 ▶ my ($self, $file) = @_;
Subroutine arg_share_object_file: called CC=1 SCAR=0.0
Pod undocumented
122 6 return ($self->split_like_shell($self->{config}{lddlflags}), '-o', $file);
123 }
124  
125 sub arg_exec_file {
126 2 ▶ my ($self, $file) = @_;
Subroutine arg_exec_file: called CC=1 SCAR=0.0
Pod undocumented
127 2 return ('-o', $file);
128 }
129  
130 sub arg_defines {
131 13 ▶ my ($self, %args) = @_;
Subroutine arg_defines: called CC=1 SCAR=0.0
Pod undocumented
132 13 return map "-D$_=$args{$_}", sort keys %args;
133 }
134  
135 sub compile {
136 12 ▶ my ($self, %args) = @_;
Subroutine compile: called CC=10 SCAR=23.0
Pod undocumented
137 12 ▶ die "Missing 'source' argument to compile()" unless defined $args{source};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"source"} 1 11 12
138  
139 11 my $cf = $self->{config}; # For convenience
140  
141 my $object_file = $args{object_file}
142 ? $args{object_file}
143 11 ▶ : $self->object_file($args{source});
Branch: 1 branch
BranchTrueFalseTotal
$args{'object_file'} ? : 0 11 11
144  
145 my $include_dirs_ref =
146 (exists($args{include_dirs}) && ref($args{include_dirs}) ne "ARRAY")
147 ? [ $args{include_dirs} ]
148 11 ▶ : $args{include_dirs};
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'include_dirs'} && ref $args{'include_dirs'} ne 'ARRAY' ? : 1 10 11
Condition100%3/3
exists $args{"include_dirs"} and ref $args{"include_dirs"} ne "ARRAY"
!ll&&!rl&&r
911
MC/DC100%2/2
exists $args{"include_dirs"} and ref $args{"include_dirs"} ne "ARRAY"
exists $args{"include_dirs"} ref $args{"include_dirs"} ne "ARRAY"
Truth table100%3/3
A and B
A= exists $args{"include_dirs"}B= ref $args{"include_dirs"} ne "ARRAY"
ABresult
0X0
100
111
149 my @include_dirs = $self->arg_include_dirs(
150 11 ▶ @{ $include_dirs_ref || [] },
Branch: 1 branch
BranchTrueFalseTotal
$include_dirs_ref or [] 9 2 11
151 $self->perl_inc(),
152 );
153  
154 11 ▶ my @defines = $self->arg_defines( %{$args{defines} || {}} );
Branch: 1 branch
BranchTrueFalseTotal
$args{"defines"} or {} 11 0 11
155  
156 my @extra_compiler_flags =
157 11 $self->split_like_shell($args{extra_compiler_flags});
158 11 my @cccdlflags = $self->split_like_shell($cf->{cccdlflags});
159 11 ▶ my @ccflags = $self->split_like_shell($args{'C++'} ? $cf->{cxxflags} : $cf->{ccflags});
Branch: 1 branch
BranchTrueFalseTotal
$args{'C++'} ? : 3 8 11
160 11 my @optimize = $self->split_like_shell($cf->{optimize});
161 11 my @flags = (
162 @include_dirs,
163 @defines,
164 @cccdlflags,
165 @extra_compiler_flags,
166 $self->arg_nolink,
167 @ccflags,
168 @optimize,
169 $self->arg_object_file($object_file),
170 );
171 11 ▶ my @cc = $self->split_like_shell($args{'C++'} ? $cf->{cxx} : $cf->{cc});
Branch: 1 branch
BranchTrueFalseTotal
$args{'C++'} ? : 3 8 11
172  
173 $self->do_system(@cc, @flags, $args{source})
174 11 ▶ or die "error building $object_file from '$args{source}'";
Branch: 1 branch
BranchTrueFalseTotal
$self->do_system(@cc, @flags, $args{"source"}) or die qq[error building $object_file from '$args{"source"}'] 3 8 11
175  
176 8 return $object_file;
177 }
178  
179 sub have_compiler {
180 8 ▶ my ($self, $is_cplusplus) = @_;
Subroutine have_compiler: called CC=8 SCAR=20.8
Pod undocumented
181 8 ▶ my $have_compiler_flag = $is_cplusplus ? "have_cxx" : "have_cc";
Branch: 1 branch
BranchTrueFalseTotal
$is_cplusplus ? : 3 5 8
182 8 ▶ my $suffix = $is_cplusplus ? ".cc" : ".c";
Branch: 1 branch
BranchTrueFalseTotal
$is_cplusplus ? : 3 5 8
183 8 ▶ return $self->{$have_compiler_flag} if defined $self->{$have_compiler_flag};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{$have_compiler_flag} 1 7 8
184  
185 7 my $result;
186 7 my $attempts = 3;
187 # tmpdir has issues for some people so fall back to current dir
188  
189 # don't clobber existing files (rare, but possible)
190 7 my ( $FH, $tmpfile ) = tempfile( "compilet-XXXXX", SUFFIX => $suffix );
191 7 binmode $FH;
192  
193 7 ▶ if ( $is_cplusplus ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_cplusplus) { } 3 4 7
194 3 print $FH "class Bogus { public: int boot_compilet() { return 1; } };\n";
195 }
196 else {
197 4 print $FH "int boot_compilet() { return 1; }\n";
198 }
199 7 close $FH;
200  
201 7 my ($obj_file, @lib_files);
202 7 eval {
203 7 local $^W = 0;
204 7 local $self->{quiet} = 1;
205 7 $obj_file = $self->compile('C++' => $is_cplusplus, source => $tmpfile);
206 4 @lib_files = $self->link(objects => $obj_file, module_name => 'compilet');
207 };
208 7 ▶ $result = $@ ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 3 4 7
209  
210 7 foreach (grep defined, $tmpfile, $obj_file, @lib_files) {
211 15 ▶ 1 while unlink;
Branch: 1 branch
BranchTrueFalseTotal
unlink $_ and do { '???' } 11 15 26
212 }
213  
214 7 return $self->{$have_compiler_flag} = $result;
215 }
216  
217 sub have_cplusplus {
218 3 ▶ push @_, 1;
Subroutine have_cplusplus: called CC=1 SCAR=0.0
Pod undocumented
219 3 goto &have_compiler;
220 }
221  
222 sub lib_file {
223 6 ▶ my ($self, $dl_file, %args) = @_;
Subroutine lib_file: called CC=4 SCAR=16.0
Pod undocumented
224 6 $dl_file =~ s/\.[^.]+$//;
225 6 $dl_file =~ tr/"//d;
226  
227 6 ▶ if (defined $args{module_name} and length $args{module_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"module_name"} and length $args{"module_name"}) 6 0 6
Condition33%1/3
defined $args{"module_name"} and length $args{"module_name"}
!ll&&!rl&&r
006
MC/DC0%0/2
defined $args{"module_name"} and length $args{"module_name"}
defined $args{"module_name"} length $args{"module_name"}
Truth table33%1/3
A and B
A= defined $args{"module_name"}B= length $args{"module_name"}
ABresult
0X0
100
111
228 # Need to create with the same name as DynaLoader will load with.
229 6 require DynaLoader;
230 6 ▶ if (defined &DynaLoader::mod2fname) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined &DynaLoader::mod2fname) 0 6 6
231 0 my $lib = DynaLoader::mod2fname([split /::/, $args{module_name}]);
232 0 my ($dev, $lib_dir, undef) = File::Spec->splitpath($dl_file);
233 0 $dl_file = File::Spec->catpath($dev, $lib_dir, $lib);
234 }
235 }
236  
237 6 $dl_file .= ".$self->{config}{dlext}";
238  
239 6 return $dl_file;
240 }
241  
242  
243 sub exe_file {
244 1 ▶ my ($self, $dl_file) = @_;
Subroutine exe_file: called CC=1 SCAR=0.0
Pod undocumented
245 1 $dl_file =~ s/\.[^.]+$//;
246 1 $dl_file =~ tr/"//d;
247 1 return "$dl_file$self->{config}{_exe}";
248 }
249  
250 5 ▶sub need_prelink { 0 }
Subroutine need_prelink: called CC=1 SCAR=0.0
Pod undocumented
251  
252 6 ▶sub extra_link_args_after_prelink { return }
Subroutine extra_link_args_after_prelink: called CC=1 SCAR=0.0
Pod undocumented
253  
254 sub prelink {
255 0 ▶ my ($self, %args) = @_;
Subroutine prelink: not called CC=1 SCAR=6.9
Pod undocumented
256  
257 0 my ($dl_file_out, $mksymlists_args) = _prepare_mksymlists_args(\%args);
258  
259 0 require ExtUtils::Mksymlists;
260 # dl. abbrev for dynamic library
261 0 ExtUtils::Mksymlists::Mksymlists( %{ $mksymlists_args } );
262  
263 # Mksymlists will create one of these files
264 0 return grep -e, map "$dl_file_out.$_", qw(ext def opt);
265 }
266  
267 sub _prepare_mksymlists_args {
268 2 ▶ my $args = shift;
Subroutine _prepare_mksymlists_args: called CC=7 SCAR=19.5
269 2 ▶ ($args->{dl_file} = $args->{dl_name}) =~ s/.*::// unless $args->{dl_file};
Branch: 1 branch
BranchTrueFalseTotal
unless $args->{"dl_file"} 1 1 2
270  
271 my %mksymlists_args = (
272 DL_VARS => $args->{dl_vars} || [],
273 DL_FUNCS => $args->{dl_funcs} || {},
274 FUNCLIST => $args->{dl_func_list} || [],
275 IMPORTS => $args->{dl_imports} || {},
276 NAME => $args->{dl_name}, # Name of the Perl module
277 DLBASE => $args->{dl_base}, # Basename of DLL file
278 FILE => $args->{dl_file}, # Dir + Basename of symlist file
279 2 ▶ VERSION => (defined $args->{dl_version} ? $args->{dl_version} : '0.0'),
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'dl_version'} ? : 1 1 2
Condition100%8/8
$args->{'dl_vars'} || []
l!l
11
$args->{'dl_funcs'} || {}
l!l
11
$args->{'dl_func_list'} || []
l!l
11
$args->{'dl_imports'} || {}
l!l
11
MC/DC100%1/1
$args->{'dl_vars'} || []
$args->{'dl_vars'}
MC/DC100%1/1
$args->{'dl_funcs'} || {}
$args->{'dl_funcs'}
MC/DC100%1/1
$args->{'dl_func_list'} || []
$args->{'dl_func_list'}
MC/DC100%1/1
$args->{'dl_imports'} || {}
$args->{'dl_imports'}
Truth table100%2/2
A
A= $args->{'dl_vars'}
Aresult
11
00
Truth table100%2/2
A
A= $args->{'dl_funcs'}
Aresult
11
00
Truth table100%2/2
A
A= $args->{'dl_func_list'}
Aresult
11
00
Truth table100%2/2
A
A= $args->{'dl_imports'}
Aresult
11
00
280 );
281 2 return ($args->{dl_file}, \%mksymlists_args);
282 }
283  
284 sub link {
285 5 ▶ my ($self, %args) = @_;
Subroutine link: called CC=1 SCAR=0.0
Pod undocumented
286 5 return $self->_do_link('lib_file', lddl => 1, %args);
287 }
288  
289 sub link_executable {
290 1 ▶ my ($self, %args) = @_;
Subroutine link_executable: called CC=1 SCAR=0.0
Pod undocumented
291 1 return $self->_do_link('exe_file', lddl => 0, %args);
292 }
293  
294 sub _do_link {
295 6 ▶ my ($self, $type, %args) = @_;
Subroutine _do_link: called CC=8 SCAR=21.9
296  
297 6 my $cf = $self->{config}; # For convenience
298  
299 6 my $objects = delete $args{objects};
300 6 ▶ $objects = [$objects] unless ref $objects;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $objects 6 0 6
301 6 ▶ my $out = $args{$type} || $self->$type($objects->[0], %args);
Condition33%1/3
$args{$type} || $self->$type($objects->[0], %args)
l!l&&r!l&&!r
060
MC/DC0%0/2
$args{$type} || $self->$type($objects->[0], %args)
$args{$type} $self->$type($objects->[0], %args)
Truth table33%1/3
A || B
A= $args{$type}B= $self->$type($objects->[0], %args)
ABresult
1X1
011
000
302  
303 6 my @temp_files;
304 @temp_files =
305 $self->prelink(%args, dl_name => $args{module_name})
306 6 ▶ if $args{lddl} && $self->need_prelink;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"lddl"} and $self->need_prelink 0 6 6
Condition66%2/3
$args{"lddl"} and $self->need_prelink
!ll&&!rl&&r
150
MC/DC0%0/2
$args{"lddl"} and $self->need_prelink
$args{"lddl"} $self->need_prelink
Truth table66%2/3
A and B
A= $args{"lddl"}B= $self->need_prelink
ABresult
0X0
100
111
307  
308 my @linker_flags = (
309 $self->split_like_shell($args{extra_linker_flags}),
310 $self->extra_link_args_after_prelink(
311 6 %args, dl_name => $args{module_name}, prelink_res => \@temp_files
312 )
313 );
314  
315 my @output = $args{lddl}
316 6 ▶ ? $self->arg_share_object_file($out)
Branch: 1 branch
BranchTrueFalseTotal
$args{'lddl'} ? : 5 1 6
317 : $self->arg_exec_file($out);
318 6 my @shrp = $self->split_like_shell($cf->{shrpenv});
319 6 my @ld = $self->split_like_shell($cf->{ld});
320  
321 6 ▶ $self->do_system(@shrp, @ld, @output, @$objects, @linker_flags)
Branch: 1 branch
BranchTrueFalseTotal
$self->do_system(@shrp, @ld, @output, @$objects, @linker_flags) or die "error building $out from @$objects" 0 6 6
322 or die "error building $out from @$objects";
323  
324 6 ▶ return wantarray ? ($out, @temp_files) : $out;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 6 0 6
325 }
326  
327  
328 sub do_system {
329 15 ▶ my ($self, @cmd) = @_;
Subroutine do_system: called CC=2 SCAR=6.9
Pod undocumented
330 15 ▶ print "@cmd\n" if !$self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 4 11 15
331 15 return !system(@cmd);
332 }
333  
334 sub split_like_shell {
335 83 ▶ my ($self, $string) = @_;
Subroutine split_like_shell: called CC=5 SCAR=16.1
Pod undocumented
336  
337 83 ▶ return () unless defined($string);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $string 18 65 83
338 65 ▶ return @$string if UNIVERSAL::isa($string, 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($string, "ARRAY") 1 64 65
339 64 $string =~ s/^\s+|\s+$//g;
340 64 ▶ return () unless length($string);
Branch: 1 branch
BranchTrueFalseTotal
unless length $string 6 58 64
341  
342 # Text::ParseWords replaces all 'escaped' characters with themselves, which completely
343 # breaks paths under windows. As such, we forcibly replace backwards slashes with forward
344 # slashes on windows.
345 58 ▶ $string =~ s@\\@/@g if $^O eq 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 58 58
346  
347 58 return Text::ParseWords::shellwords($string);
348 }
349  
350 # if building perl, perl's main source directory
351 sub perl_src {
352 # N.B. makemaker actually searches regardless of PERL_CORE, but
353 # only squawks at not finding it if PERL_CORE is set
354  
355 16 ▶ return unless $ENV{PERL_CORE};
Subroutine perl_src: called CC=6 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"PERL_CORE"} 12 4 16
356  
357 4 my $Updir = File::Spec->updir;
358 4 my $dir = File::Spec->curdir;
359  
360 # Try up to 5 levels upwards
361 4 for (0..10) {
362 34 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (-f "File::Spec"->catfile($dir, "config_h.SH") and -f "File::Spec"->catfile($dir, "perl.h") and -f "File::Spec"->catfile($dir, "lib", "Exporter.pm")) 1 33 34
Condition100%6/6
-f "File::Spec"->catfile($dir, "config_h.SH") and -f "File::Spec"->catfile($dir, "perl.h") and -f "File::Spec"->catfile($dir, "lib", "Exporter.pm")
!ll&&!rl&&r
3211
-f "File::Spec"->catfile($dir, "config_h.SH") and -f "File::Spec"->catfile($dir, "perl.h")
!ll&&!rl&&r
3112
MC/DC100%3/3
-f "File::Spec"->catfile($dir, "config_h.SH") and -f "File::Spec"->catfile($dir, "perl.h") and -f "File::Spec"->catfile($dir, "lib", "Exporter.pm")
-f "File::Spec"->catfile($dir, "config_h.SH") -f "File::Spec"->catfile($dir, "perl.h") -f "File::Spec"->catfile($dir, "lib", "Exporter.pm")
Truth table100%4/4
A and B and C
A= -f "File::Spec"->catfile($dir, "config_h.SH")B= -f "File::Spec"->catfile($dir, "perl.h")C= -f "File::Spec"->catfile($dir, "lib", "Exporter.pm")
ABCresult
0XX0
10X0
1100
1111
363 -f File::Spec->catfile($dir,"config_h.SH")
364 &&
365 -f File::Spec->catfile($dir,"perl.h")
366 &&
367 -f File::Spec->catfile($dir,"lib","Exporter.pm")
368 ) {
369 1 return Cwd::realpath( $dir );
370 }
371  
372 33 $dir = File::Spec->catdir($dir, $Updir);
373 }
374  
375 3 warn "PERL_CORE is set but I can't find your perl source!\n";
376 3 return ''; # return empty string if $ENV{PERL_CORE} but can't find dir ???
377 }
378  
379 # directory of perl's include files
380 sub perl_inc {
381 12 ▶ my $self = shift;
Subroutine perl_inc: called CC=2 SCAR=7.2
Pod undocumented
382  
383 12 ▶ $self->perl_src() || File::Spec->catdir($self->{config}{archlibexp},"CORE");
Branch: 1 branch
BranchTrueFalseTotal
$self->perl_src or "File::Spec"->catdir($self->{"config"}{"archlibexp"}, "CORE") 12 0 12
384 }
385  
386 sub DESTROY {
387 20 ▶ my $self = shift;
Subroutine DESTROY: called CC=1 SCAR=0.0
388 20 local($., $@, $!, $^E, $?);
389 20 $self->cleanup();
390 }
391  
392 5 1;
393  
394 # vim: ts=2 sw=2 et:
« CBuilder/Platform/os2.pm ↑ Summary CBuilder/Platform/Windows/BCC.pm »