lib/ExtUtils/MM_Win32.pm

filter: Statementstmt 16.5% 40 / 242 Branchbran 3.8% 5 / 130 Conditioncond 0.0% 0 / 44 MC/DCmcdc 0.0% 0 / 27 Subroutinesub 18.6% 8 / 43 Podpod 97.0% 33 / 34 totaltotal 16.5% 86 / 520 CC 90 SCAR 37.4
CC
90
Cov
11%
init_others
182.0
perl_script
90.0
maybe_command
56.0
CRAP 42.3
« lib/ExtUtils/Command/MM.pm ↑ Summary lib/ExtUtils/MM_Any.pm »
1 package ExtUtils::MM_Win32;
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  
6 =head1 NAME
7  
8 ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker
9  
10 =head1 SYNOPSIS
11  
12 use ExtUtils::MM_Win32; # Done internally by ExtUtils::MakeMaker if needed
13  
14 =head1 DESCRIPTION
15  
16 See L<ExtUtils::MM_Unix> for a documentation of the methods provided
17 there. This package overrides the implementation of these methods, not
18 the semantics.
19  
20 =cut
21  
22 2 ▶use ExtUtils::MakeMaker::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use ExtUtils::MakeMaker qw(neatvalue _sprintf562);
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 2 require ExtUtils::MM_Any;
28 2 require ExtUtils::MM_Unix;
29 2 our @ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix );
30 2 our $VERSION = '7.78';
31 2 $VERSION =~ tr/_//d;
32  
33 2 $ENV{EMXSHELL} = 'sh'; # to run `commands`
34  
35 2 my ( $BORLAND, $GCC, $MSVC ) = _identify_compiler_environment( \%Config );
36  
37 2 ▶sub _identify_compiler_environment {
Subroutine _identify_compiler_environment: called CC=4 SCAR=14.6
38 2 my ( $config ) = @_;
39  
40 2 ▶ my $BORLAND = $config->{cc} =~ /\bbcc/i ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$config->{'cc'} =~ /\bbcc/i ? : 0 2 2
41 2 ▶ my $GCC = $config->{cc} =~ /\bgcc\b/i ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$config->{'cc'} =~ /\bgcc\b/i ? : 0 2 2
42 2 ▶ my $MSVC = $config->{cc} =~ /\b(?:cl|icl)/i ? 1 : 0; # MSVC can come as clarm.exe, icl=Intel C
Branch: 1 branch
BranchTrueFalseTotal
$config->{'cc'} =~ /\b(?:cl|icl)/i ? : 0 2 2
43  
44 2 return ( $BORLAND, $GCC, $MSVC );
45 }
46  
47  
48 =head2 Overridden methods
49  
50 =over 4
51  
52 =item B<dlsyms>
53  
54 =cut
55  
56 0 ▶sub dlsyms {
Subroutine dlsyms: not called CC=2 SCAR=17.9
Pod documented
57 0 my($self,%attribs) = @_;
58 0 ▶ return '' if $self->{SKIPHASH}{'dynamic'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"SKIPHASH"}{"dynamic"} 0 0 0
59 0 $self->xs_dlsyms_iterator(\%attribs);
60 }
61  
62 =item xs_dlsyms_ext
63  
64 On Win32, is C<.def>.
65  
66 =cut
67  
68 0 ▶sub xs_dlsyms_ext {
Subroutine xs_dlsyms_ext: not called CC=1 SCAR=6.9
Pod documented
69 0 '.def';
70 }
71  
72 =item replace_manpage_separator
73  
74 Changes the path separator with .
75  
76 =cut
77  
78 0 ▶sub replace_manpage_separator {
Subroutine replace_manpage_separator: not called CC=1 SCAR=6.9
Pod documented
79 0 my($self,$man) = @_;
80 0 $man =~ s,[/\\]+,.,g;
81 0 $man;
82 }
83  
84  
85 =item B<maybe_command>
86  
87 Since Windows has nothing as simple as an executable bit, we check the
88 file extension.
89  
90 The PATHEXT env variable will be used to get a list of extensions that
91 might indicate a command, otherwise .com, .exe, .bat and .cmd will be
92 used by default.
93  
94 =cut
95  
96 0 ▶sub maybe_command {
Subroutine maybe_command: not called CC=7 SCAR=40.3
Pod documented
97 0 my($self,$file) = @_;
98 my @e = exists($ENV{'PATHEXT'})
99 ? split(/;/, $ENV{PATHEXT})
100 0 ▶ : qw(.com .exe .bat .cmd);
Branch: 1 branch
BranchTrueFalseTotal
exists $ENV{'PATHEXT'} ? : 0 0 0
101 0 my $e = '';
102 0 for (@e) { $e .= "\Q$_\E|" }
103 0 chop $e;
104 # see if file ends in one of the known extensions
105 0 ▶ if ($file =~ /($e)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /($e)$/i) { } 0 0 0
106 0 ▶ return $file if -e $file;
Branch: 1 branch
BranchTrueFalseTotal
if -e $file 0 0 0
107 }
108 else {
109 0 for (@e) {
110 0 ▶ return "$file$_" if -e "$file$_";
Branch: 1 branch
BranchTrueFalseTotal
if -e "$file$_" 0 0 0
111 }
112 }
113 0 return;
114 }
115  
116  
117 =item B<init_DIRFILESEP>
118  
119 Using \ for Windows, except for "gmake" where it is /.
120  
121 =cut
122  
123 0 ▶sub init_DIRFILESEP {
Subroutine init_DIRFILESEP: not called CC=4 SCAR=30.0
Pod documented
124 0 my($self) = shift;
125  
126 # The ^ makes sure it's not interpreted as an escape in nmake
127 0 ▶ $self->{DIRFILESEP} = $self->is_make_type('nmake') ? '^\\' :
Branch: 3 branches
BranchTrueFalseTotal
$self->is_make_type('nmake') ? : 0 0 0
$self->is_make_type('dmake') ? : 0 0 0
$self->is_make_type('gmake') ? : 0 0 0
128 $self->is_make_type('dmake') ? '\\\\' :
129 $self->is_make_type('gmake') ? '/'
130 : '\\';
131 }
132  
133 =item init_tools
134  
135 Override some of the slower, portable commands with Windows specific ones.
136  
137 =cut
138  
139 0 ▶sub init_tools {
Subroutine init_tools: not called CC=5 SCAR=34.0
Pod documented
140 0 my ($self) = @_;
141  
142 0 ▶ $self->{NOOP} ||= 'rem';
Condition0%0/2
$self->{"NOOP"} ||= "rem"
l!l
00
MC/DC0%0/1
$self->{"NOOP"} ||= "rem"
$self->{"NOOP"}
Truth table0%0/2
A
A= $self->{"NOOP"}
Aresult
11
00
143 0 ▶ $self->{DEV_NULL} ||= '> NUL';
Condition0%0/2
$self->{"DEV_NULL"} ||= "> NUL"
l!l
00
MC/DC0%0/1
$self->{"DEV_NULL"} ||= "> NUL"
$self->{"DEV_NULL"}
Truth table0%0/2
A
A= $self->{"DEV_NULL"}
Aresult
11
00
144  
145 $self->{FIXIN} ||= $self->{PERL_CORE} ?
146 0 ▶ "\$(PERLRUN) -I$self->{PERL_SRC}\\cpan\\ExtUtils-PL2Bat\\lib $self->{PERL_SRC}\\win32\\bin\\pl2bat.pl" :
Branch: 1 branch
BranchTrueFalseTotal
$self->{'PERL_CORE'} ? : 0 0 0
Condition0%0/3
$self->{"FIXIN"} ||= $self->{"PERL_CORE"} ? qq[\$(PERLRUN) -I$self->{"PERL_SRC"}\\cpan\\ExtUtils-PL2Bat\\lib $self->{"PERL_SRC"}\\win32\\bin\\pl2bat.pl] : "pl2bat.bat"
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"FIXIN"} ||= $self->{"PERL_CORE"} ? qq[\$(PERLRUN) -I$self->{"PERL_SRC"}\\cpan\\ExtUtils-PL2Bat\\lib $self->{"PERL_SRC"}\\win32\\bin\\pl2bat.pl] : "pl2bat.bat"
$self->{"FIXIN"} $self->{"PERL_CORE"} ? qq[\$(PERLRUN) -I$self->{"PERL_SRC"}\\cpan\\ExtUtils-PL2Bat\\lib $self->{"PERL_SRC"}\\win32\\bin\\pl2bat.pl] : "pl2bat.bat"
Truth table0%0/3
A ||= B
A= $self->{"FIXIN"}B= $self->{"PERL_CORE"} ? qq[\$(PERLRUN) -I$self->{"PERL_SRC"}\\cpan\\ExtUtils-PL2Bat\\lib $self->{"PERL_SRC"}\\win32\\bin\\pl2bat.pl] : "pl2bat.bat"
ABresult
1X1
011
000
147 'pl2bat.bat';
148  
149 0 $self->SUPER::init_tools;
150  
151 # Setting SHELL from $Config{sh} can break dmake. Its ok without it.
152 0 delete $self->{SHELL};
153  
154 0 return;
155 }
156  
157  
158 =item init_others
159  
160 Override the default link and compile tools.
161  
162 LDLOADLIBS's default is changed to $Config{libs}.
163  
164 Adjustments are made for Borland's quirks needing -L to come first.
165  
166 =cut
167  
168 2 my @LIBS_VARNAMES = qw(EXTRALIBS BSLOADLIBS LDLOADLIBS LD_RUN_PATH);
169 0 ▶sub init_others {
Subroutine init_others: not called CC=13 SCAR=52.0
Pod documented
170 0 my $self = shift;
171  
172 0 ▶ $self->{LD} ||= 'link';
Condition0%0/2
$self->{"LD"} ||= "link"
l!l
00
MC/DC0%0/1
$self->{"LD"} ||= "link"
$self->{"LD"}
Truth table0%0/2
A
A= $self->{"LD"}
Aresult
11
00
173 0 ▶ $self->{AR} ||= 'lib';
Condition0%0/2
$self->{"AR"} ||= "lib"
l!l
00
MC/DC0%0/1
$self->{"AR"} ||= "lib"
$self->{"AR"}
Truth table0%0/2
A
A= $self->{"AR"}
Aresult
11
00
174  
175 0 $self->SUPER::init_others;
176 # If Config.pm defines a set of default libs,
177 # add them to EXTRALIBS, BSLOADLIBS and LDLOADLIBS, unless the user
178 # specified :nodefault or gave no LIBS
179 0 ▶ if (grep /\S/ && !/:nodefault/i, @{$self->{LIBS}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep((/\S/ && !/:nodefault/i), @{$$self{"LIBS"};})) 0 0 0
Condition0%0/3
/\S/ && !/:nodefault/i
!ll&&!rl&&r
000
MC/DC0%0/2
/\S/ && !/:nodefault/i
/\S/ !/:nodefault/i
Truth table0%0/3
A && not(B)
A= /\S/B= !/:nodefault/i
ABresult
0X0
100
111
180 0 my @libs = $self->extliblist($Config{perllibs});
181 0 for my $ind (0..$#LIBS_VARNAMES) {
182 0 ▶ next unless my $to_add = $libs[$ind];
Branch: 1 branch
BranchTrueFalseTotal
unless my $to_add = $libs[$ind] 0 0 0
183 0 my $varname = $LIBS_VARNAMES[$ind];
184 0 ▶ $self->{$varname} .= ' ' if $self->{$varname};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$varname} 0 0 0
185 0 $self->{$varname} .= $to_add;
186 }
187 }
188  
189 0 ▶ $self->{LDLOADLIBS} ||= $Config{libs};
Condition0%0/3
$self->{"LDLOADLIBS"} ||= $ExtUtils::MM_Win32::Config{"libs"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"LDLOADLIBS"} ||= $ExtUtils::MM_Win32::Config{"libs"}
$self->{"LDLOADLIBS"} $ExtUtils::MM_Win32::Config{"libs"}
Truth table0%0/3
A ||= B
A= $self->{"LDLOADLIBS"}B= $ExtUtils::MM_Win32::Config{"libs"}
ABresult
1X1
011
000
190 # -Lfoo must come first for Borland, so we put it in LDDLFLAGS
191 0 ▶ if ($BORLAND) {
Branch: 1 branch
BranchTrueFalseTotal
if ($BORLAND) 0 0 0
192 0 my $libs = $self->{LDLOADLIBS};
193 0 my $libpath = '';
194 0 ▶ while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) {
Branch: 1 branch
BranchTrueFalseTotal
if ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) 0 0 0
195 0 ▶ $libpath .= ' ' if length $libpath;
Branch: 1 branch
BranchTrueFalseTotal
if length $libpath 0 0 0
196 0 $libpath .= $1;
197 }
198 0 $self->{LDLOADLIBS} = $libs;
199 0 ▶ $self->{LDDLFLAGS} ||= $Config{lddlflags};
Condition0%0/3
$self->{"LDDLFLAGS"} ||= $ExtUtils::MM_Win32::Config{"lddlflags"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"LDDLFLAGS"} ||= $ExtUtils::MM_Win32::Config{"lddlflags"}
$self->{"LDDLFLAGS"} $ExtUtils::MM_Win32::Config{"lddlflags"}
Truth table0%0/3
A ||= B
A= $self->{"LDDLFLAGS"}B= $ExtUtils::MM_Win32::Config{"lddlflags"}
ABresult
1X1
011
000
200 0 $self->{LDDLFLAGS} .= " $libpath";
201 }
202  
203 0 return;
204 }
205  
206  
207 =item init_platform
208  
209 Add MM_Win32_VERSION.
210  
211 =item platform_constants
212  
213 =cut
214  
215 0 ▶sub init_platform {
Subroutine init_platform: not called CC=1 SCAR=6.9
Pod documented
216 0 my($self) = shift;
217  
218 0 $self->{MM_Win32_VERSION} = $VERSION;
219  
220 0 return;
221 }
222  
223 0 ▶sub platform_constants {
Subroutine platform_constants: not called CC=3 SCAR=24.8
Pod documented
224 0 my($self) = shift;
225 0 my $make_frag = '';
226  
227 0 foreach my $macro (qw(MM_Win32_VERSION))
228 {
229 0 ▶ next unless defined $self->{$macro};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{$macro} 0 0 0
230 0 $make_frag .= "$macro = $self->{$macro}\n";
231 }
232  
233 0 return $make_frag;
234 }
235  
236 =item specify_shell
237  
238 Set SHELL to $ENV{COMSPEC} only if make is type 'gmake'.
239  
240 =cut
241  
242 0 ▶sub specify_shell {
Subroutine specify_shell: not called CC=2 SCAR=17.9
Pod documented
243 0 my $self = shift;
244 0 ▶ return '' unless $self->is_make_type('gmake');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_make_type("gmake") 0 0 0
245 0 "\nSHELL = $ENV{COMSPEC}\n";
246 }
247  
248 =item constants
249  
250 Add MAXLINELENGTH for dmake before all the constants are output.
251  
252 =cut
253  
254 0 ▶sub constants {
Subroutine constants: not called CC=3 SCAR=24.8
Pod documented
255 0 my $self = shift;
256  
257 0 my $make_text = $self->SUPER::constants;
258 0 ▶ return $make_text unless $self->is_make_type('dmake');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_make_type("dmake") 0 0 0
259  
260 # dmake won't read any single "line" (even those with escaped newlines)
261 # larger than a certain size which can be as small as 8k. PM_TO_BLIB
262 # on large modules like DateTime::TimeZone can create lines over 32k.
263 # So we'll crank it up to a <ironic>WHOPPING</ironic> 64k.
264 #
265 # This has to come here before all the constants and not in
266 # platform_constants which is after constants.
267 0 ▶ my $size = $self->{MAXLINELENGTH} || 800000;
Condition0%0/2
$self->{'MAXLINELENGTH'} || 800000
l!l
00
MC/DC0%0/1
$self->{'MAXLINELENGTH'} || 800000
$self->{'MAXLINELENGTH'}
Truth table0%0/2
A
A= $self->{'MAXLINELENGTH'}
Aresult
11
00
268 0 my $prefix = qq{
269 # Get dmake to read long commands like PM_TO_BLIB
270 MAXLINELENGTH = $size
271  
272 };
273  
274 0 return $prefix . $make_text;
275 }
276  
277 =item dep_constants
278  
279 Makes dependencies that work for nmake.
280  
281 =cut
282  
283 0 ▶sub dep_constants {
Subroutine dep_constants: not called CC=6 SCAR=37.4
Pod documented
284 0 my ($self) = @_;
285 0 ▶ return $self->SUPER::dep_constants if !$self->is_make_type('nmake');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_make_type("nmake") 0 0 0
286 0 my @m = ();
287 0 for my $macro (qw(PERL_ARCHLIBDEP PERL_INCDEP)) {
288 0 ▶ next unless defined $self->{$macro};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{$macro} 0 0 0
289 # pathnames can have sharp signs in them; escape them so
290 # make doesn't think it is a comment-start character.
291 0 $self->{$macro} =~ s/#/\\#/g;
292 $self->{$macro} = $self->quote_dep($self->{$macro})
293 0 ▶ if $ExtUtils::MakeMaker::macro_dep{$macro};
Branch: 1 branch
BranchTrueFalseTotal
if $ExtUtils::MakeMaker::macro_dep{$macro} 0 0 0
294 0 push @m, "$macro = $self->{$macro}\n";
295 }
296 0 push @m, qq{
297 \n# Dependencies info
298 PERL_ARCHIVEDEP = "$self->{PERL_ARCHIVE}"
299 };
300 push @m, qq{
301 # Where is the Config information that we are using/depend on
302 CONFIGDEP = "\$(PERL_ARCHLIB)\$(DFSEP)Config.pm" "\$(PERL_INC)\$(DFSEP)config.h"
303 0 ▶} if -e $self->catfile($self->{PERL_INC}, 'config.h');
Branch: 1 branch
BranchTrueFalseTotal
if -e $self->catfile($self->{"PERL_INC"}, "config.h") 0 0 0
304 0 join '', @m;
305 }
306  
307 0 ▶sub _perl_header_files_fragment {
Subroutine _perl_header_files_fragment: not called CC=2 SCAR=17.9
308 0 my ($self, $separator) = @_;
309 0 ▶ return $self->SUPER::_perl_header_files_fragment($separator)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_make_type("nmake") 0 0 0
310 if !$self->is_make_type('nmake');
311 0 return join("\\\n",
312 "PERL_HDRS = ",
313 map sprintf(" \"\$(PERL_INC)\\%s\" ", $_),
314 $self->_perl_header_files
315 ) . "\n\n"
316 . "\$(OBJECT) : \$(PERL_HDRS)\n";
317 }
318  
319 0 ▶sub tool_xsubpp_emit {
Subroutine tool_xsubpp_emit: not called CC=2 SCAR=17.9
Pod undocumented
320 0 my ($self, $xsdir, $tmdeps, $tmargs) = @_;
321 0 ▶ return $self->SUPER::tool_xsubpp_emit($xsdir, $tmdeps, $tmargs)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_make_type("nmake") 0 0 0
322 if !$self->is_make_type('nmake');
323 0 return qq{
324 XSUBPPDIR = $xsdir
325 XSUBPP = "\$(XSUBPPDIR)\$(DFSEP)xsubpp"
326 XSUBPPRUN = \$(PERLRUN) \$(XSUBPP)
327 XSPROTOARG = $self->{XSPROTOARG}
328 XSUBPPDEPS = @$tmdeps \$(XSUBPP)
329 XSUBPPARGS = @$tmargs
330 XSUBPP_EXTRA_ARGS =
331 };
332 }
333  
334 =item special_targets
335  
336 Add .USESHELL target for dmake.
337  
338 =cut
339  
340 0 ▶sub special_targets {
Subroutine special_targets: not called CC=2 SCAR=17.9
Pod documented
341 0 my($self) = @_;
342  
343 0 my $make_frag = $self->SUPER::special_targets;
344  
345 0 ▶ $make_frag .= <<'MAKE_FRAG' if $self->is_make_type('dmake');
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_make_type("dmake") 0 0 0
346 .USESHELL :
347 MAKE_FRAG
348  
349 0 return $make_frag;
350 }
351  
352 =item static_lib_pure_cmd
353  
354 Defines how to run the archive utility
355  
356 =cut
357  
358 0 ▶sub static_lib_pure_cmd {
Subroutine static_lib_pure_cmd: not called CC=4 SCAR=30.0
Pod documented
359 0 my ($self, $from) = @_;
360 0 ▶ $from =~ s/(\$\(\w+)(\))/$1:^"+"$2/g if $BORLAND;
Branch: 1 branch
BranchTrueFalseTotal
if $BORLAND 0 0 0
361 0 ▶ sprintf qq{\t\$(AR) %s\n}, ($BORLAND ? '$@ ' . $from
Branch: 2 branches
BranchTrueFalseTotal
$BORLAND ? : 0 0 0
$GCC ? : 0 0 0
362 : ($GCC ? '-ru $@ ' . $from
363 : '-out:$@ ' . $from));
364 }
365  
366 =item dynamic_lib
367  
368 Methods are overridden here: not dynamic_lib itself, but the utility
369 ones that do the OS-specific work.
370  
371 =cut
372  
373 0 ▶sub xs_make_dynamic_lib {
Subroutine xs_make_dynamic_lib: not called CC=6 SCAR=37.4
Pod documented
374 0 my ($self, $attribs, $from, $to, $todir, $ldfrom, $exportlist) = @_;
375 0 my @m = sprintf '%s : %s $(MYEXTLIB) %s$(DFSEP).exists %s $(PERL_ARCHIVEDEP) $(INST_DYNAMIC_DEP)'."\n", $to, $from, $todir, $exportlist;
376 0 ▶ if ($GCC) {
Branch: 2 branches
BranchTrueFalseTotal
if ($GCC) { } 0 0 0
elsif ($BORLAND) { } 0 0 0
377 # per https://rt.cpan.org/Ticket/Display.html?id=78395 no longer
378 # uses dlltool - relies on post 2002 MinGW
379 # 1 2
380 0 push @m, _sprintf562 <<'EOF', $exportlist, $ldfrom;
381 $(LD) %1$s -o $@ $(LDDLFLAGS) %2$s $(OTHERLDFLAGS) $(MYEXTLIB) "$(PERL_ARCHIVE)" $(LDLOADLIBS) -Wl,--enable-auto-image-base
382 EOF
383 } elsif ($BORLAND) {
384 0 ▶ my $ldargs = $self->is_make_type('dmake')
Branch: 1 branch
BranchTrueFalseTotal
$self->is_make_type('dmake') ? : 0 0 0
385 ? q{"$(PERL_ARCHIVE:s,/,\,)" $(LDLOADLIBS:s,/,\,) $(MYEXTLIB:s,/,\,),}
386 : q{"$(subst /,\,$(PERL_ARCHIVE))" $(subst /,\,$(LDLOADLIBS)) $(subst /,\,$(MYEXTLIB)),};
387 0 my $subbed;
388 0 ▶ if ($exportlist eq '$(EXPORT_LIST)') {
Branch: 1 branch
BranchTrueFalseTotal
if ($exportlist eq '$(EXPORT_LIST)') { } 0 0 0
389 0 ▶ $subbed = $self->is_make_type('dmake')
Branch: 1 branch
BranchTrueFalseTotal
$self->is_make_type('dmake') ? : 0 0 0
390 ? q{$(EXPORT_LIST:s,/,\,)}
391 : q{$(subst /,\,$(EXPORT_LIST))};
392 } else {
393 # in XSMULTI, exportlist is per-XS, so have to sub in perl not make
394 0 ($subbed = $exportlist) =~ s#/#\\#g;
395 }
396 0 push @m, sprintf <<'EOF', $ldfrom, $ldargs . $subbed;
397 $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) %s,$@,,%s,$(RESFILES)
398 EOF
399 } else { # VC
400 0 push @m, sprintf <<'EOF', $ldfrom, $exportlist;
401 $(LD) -out:$@ $(LDDLFLAGS) %s $(OTHERLDFLAGS) $(MYEXTLIB) "$(PERL_ARCHIVE)" $(LDLOADLIBS) -def:%s
402 EOF
403 # Embed the manifest file if it exists
404 0 push(@m, q{ if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2
405 if exist $@.manifest del $@.manifest});
406 }
407 0 push @m, "\n\t\$(CHMOD) \$(PERM_RWX) \$\@\n";
408  
409 0 join '', @m;
410 }
411  
412 0 ▶sub xs_dynamic_lib_macros {
Subroutine xs_dynamic_lib_macros: not called CC=4 SCAR=30.0
Pod documented
413 0 my ($self, $attribs) = @_;
414 0 ▶ my $otherldflags = $attribs->{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
Branch: 1 branch
BranchTrueFalseTotal
$BORLAND ? : 0 0 0
Condition0%0/3
$attribs->{'OTHERLDFLAGS'} || ($BORLAND ? 'c0d32.obj' : '')
l!l&&r!l&&!r
000
MC/DC0%0/2
$attribs->{'OTHERLDFLAGS'} || ($BORLAND ? 'c0d32.obj' : '')
$attribs->{'OTHERLDFLAGS'} ($BORLAND ? 'c0d32.obj' : '')
Truth table0%0/3
A || B
A= $attribs->{'OTHERLDFLAGS'}B= ($BORLAND ? 'c0d32.obj' : '')
ABresult
1X1
011
000
415 0 ▶ my $inst_dynamic_dep = $attribs->{INST_DYNAMIC_DEP} || "";
Condition0%0/2
$attribs->{'INST_DYNAMIC_DEP'} || ''
l!l
00
MC/DC0%0/1
$attribs->{'INST_DYNAMIC_DEP'} || ''
$attribs->{'INST_DYNAMIC_DEP'}
Truth table0%0/2
A
A= $attribs->{'INST_DYNAMIC_DEP'}
Aresult
11
00
416 0 sprintf <<'EOF', $otherldflags, $inst_dynamic_dep;
417 # This section creates the dynamically loadable objects from relevant
418 # objects and possibly $(MYEXTLIB).
419 OTHERLDFLAGS = %s
420 INST_DYNAMIC_DEP = %s
421 EOF
422 }
423  
424 =item extra_clean_files
425  
426 Clean out some extra dll.{base,exp} files which might be generated by
427 gcc. Otherwise, take out all *.pdb files.
428  
429 =cut
430  
431 0 ▶sub extra_clean_files {
Subroutine extra_clean_files: not called CC=2 SCAR=17.9
Pod documented
432 0 my $self = shift;
433  
434 0 ▶ return $GCC ? (qw(dll.base dll.exp)) : ('*.pdb');
Branch: 1 branch
BranchTrueFalseTotal
$GCC ? : 0 0 0
435 }
436  
437 =item init_linker
438  
439 =cut
440  
441 0 ▶sub init_linker {
Subroutine init_linker: not called CC=1 SCAR=6.9
Pod documented
442 0 my $self = shift;
443  
444 0 $self->{PERL_ARCHIVE} = "\$(PERL_INC)\\$Config{libperl}";
445 0 $self->{PERL_ARCHIVEDEP} = "\$(PERL_INCDEP)\\$Config{libperl}";
446 0 $self->{PERL_ARCHIVE_AFTER} = '';
447 0 $self->{EXPORT_LIST} = '$(BASEEXT).def';
448 }
449  
450  
451 =item perl_script
452  
453 Checks for the perl program under several common perl extensions.
454  
455 =cut
456  
457 0 ▶sub perl_script {
Subroutine perl_script: not called CC=9 SCAR=45.0
Pod documented
458 0 my($self,$file) = @_;
459 0 ▶ return $file if -r $file && -f _;
Branch: 1 branch
BranchTrueFalseTotal
if -r $file and -f _ 0 0 0
Condition0%0/3
-r $file and -f _
!ll&&!rl&&r
000
MC/DC0%0/2
-r $file and -f _
-r $file -f _
Truth table0%0/3
A and B
A= -r $fileB= -f _
ABresult
0X0
100
111
460 0 ▶ return "$file.pl" if -r "$file.pl" && -f _;
Branch: 1 branch
BranchTrueFalseTotal
if -r "$file.pl" and -f _ 0 0 0
Condition0%0/3
-r "$file.pl" and -f _
!ll&&!rl&&r
000
MC/DC0%0/2
-r "$file.pl" and -f _
-r "$file.pl" -f _
Truth table0%0/3
A and B
A= -r "$file.pl"B= -f _
ABresult
0X0
100
111
461 0 ▶ return "$file.plx" if -r "$file.plx" && -f _;
Branch: 1 branch
BranchTrueFalseTotal
if -r "$file.plx" and -f _ 0 0 0
Condition0%0/3
-r "$file.plx" and -f _
!ll&&!rl&&r
000
MC/DC0%0/2
-r "$file.plx" and -f _
-r "$file.plx" -f _
Truth table0%0/3
A and B
A= -r "$file.plx"B= -f _
ABresult
0X0
100
111
462 0 ▶ return "$file.bat" if -r "$file.bat" && -f _;
Branch: 1 branch
BranchTrueFalseTotal
if -r "$file.bat" and -f _ 0 0 0
Condition0%0/3
-r "$file.bat" and -f _
!ll&&!rl&&r
000
MC/DC0%0/2
-r "$file.bat" and -f _
-r "$file.bat" -f _
Truth table0%0/3
A and B
A= -r "$file.bat"B= -f _
ABresult
0X0
100
111
463 0 return;
464 }
465  
466 0 ▶sub can_dep_space {
Subroutine can_dep_space: not called CC=4 SCAR=30.0
Pod documented
467 0 my ($self) = @_;
468 0 ▶ return 1 if !$self->is_make_type('dmake'); # GNU & n-make are fine
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_make_type("dmake") 0 0 0
469 0 ▶ return 0 unless $self->can_load_xs;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can_load_xs 0 0 0
470 0 require Win32;
471 0 require File::Spec;
472 0 my ($vol, $dir) = File::Spec->splitpath($INC{'ExtUtils/MakeMaker.pm'});
473 # can_dep_space via GetShortPathName, if short paths are supported
474 0 my $canary = Win32::GetShortPathName(File::Spec->catpath($vol, $dir, 'MakeMaker.pm'));
475 0 (undef, undef, my $file) = File::Spec->splitpath($canary);
476 0 ▶ return (length $file > 11) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
length $file > 11 ? : 0 0 0
477 }
478  
479 =item quote_dep
480  
481 =cut
482  
483 0 ▶sub quote_dep {
Subroutine quote_dep: not called CC=6 SCAR=37.4
Pod documented
484 0 my ($self, $arg) = @_;
485 0 ▶ return $arg if $arg !~ / /;
Branch: 1 branch
BranchTrueFalseTotal
unless $arg =~ / / 0 0 0
486 0 ▶ return $self->SUPER::quote_dep($arg) if $self->is_make_type('gmake');
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_make_type("gmake") 0 0 0
487 0 ▶ return qq{"$arg"} if $self->is_make_type('nmake');
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_make_type("nmake") 0 0 0
488 0 require Win32; # dmake, get 8.3 name
489 0 $arg = Win32::GetShortPathName($arg);
490 0 ▶ die <<EOF if not defined $arg or $arg =~ / /;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $arg or $arg =~ / / 0 0 0
Condition0%0/3
not defined $arg or $arg =~ / /
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $arg or $arg =~ / /
not defined $arg $arg =~ / /
Truth table0%0/3
not(A) or B
A= not defined $argB= $arg =~ / /
ABresult
1X1
011
000
491 Tried to use make dependency with space for dmake:
492 '$arg'
493 Fallback to short pathname failed.
494 EOF
495 0 $arg;
496 }
497  
498  
499 =item xs_obj_opt
500  
501 Override to fixup -o flags for MSVC.
502  
503 =cut
504  
505 0 ▶sub xs_obj_opt {
Subroutine xs_obj_opt: not called CC=2 SCAR=17.9
Pod documented
506 0 my ($self, $output_file) = @_;
507 0 ▶ ($MSVC ? "/Fo" : "-o ") . $output_file;
Branch: 1 branch
BranchTrueFalseTotal
$MSVC ? : 0 0 0
508 }
509  
510  
511 =item pasthru
512  
513 All we send is -nologo to nmake to prevent it from printing its damned
514 banner.
515  
516 =cut
517  
518 0 ▶sub pasthru {
Subroutine pasthru: not called CC=2 SCAR=17.9
Pod documented
519 0 my($self) = shift;
520 0 my $old = $self->SUPER::pasthru;
521 0 ▶ return $old unless $self->is_make_type('nmake');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_make_type("nmake") 0 0 0
522 0 $old =~ s/(PASTHRU\s*=\s*)/$1 -nologo /;
523 0 $old;
524 }
525  
526  
527 =item arch_check (override)
528  
529 Normalize all arguments for consistency of comparison.
530  
531 =cut
532  
533 0 ▶sub arch_check {
Subroutine arch_check: not called CC=2 SCAR=17.9
Pod documented
534 0 my $self = shift;
535  
536 # Win32 is an XS module, minperl won't have it.
537 # arch_check() is not critical, so just fake it.
538 0 ▶ return 1 unless $self->can_load_xs;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can_load_xs 0 0 0
539 0 return $self->SUPER::arch_check( map { $self->_normalize_path_name($_) } @_);
540 }
541  
542 0 ▶sub _normalize_path_name {
Subroutine _normalize_path_name: not called CC=2 SCAR=17.9
543 0 my $self = shift;
544 0 my $file = shift;
545  
546 0 require Win32;
547 0 my $short = Win32::GetShortPathName($file);
548 0 ▶ return defined $short ? lc $short : lc $file;
Branch: 1 branch
BranchTrueFalseTotal
defined $short ? : 0 0 0
549 }
550  
551  
552 =item oneliner
553  
554 These are based on what command.com does on Win98. They may be wrong
555 for other Windows shells, I don't know.
556  
557 =cut
558  
559 0 ▶sub oneliner {
Subroutine oneliner: not called CC=2 SCAR=17.9
Pod documented
560 0 my($self, $cmd, $switches) = @_;
561 0 ▶ $switches = [] unless defined $switches;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $switches 0 0 0
562  
563 # Strip leading and trailing newlines
564 0 $cmd =~ s{^\n+}{};
565 0 $cmd =~ s{\n+$}{};
566  
567 0 $cmd = $self->quote_literal($cmd);
568 0 $cmd = $self->escape_newlines($cmd);
569  
570 0 $switches = join ' ', @$switches;
571  
572 0 return qq{\$(ABSPERLRUN) $switches -e $cmd --};
573 }
574  
575  
576 0 ▶sub quote_literal {
Subroutine quote_literal: not called CC=6 SCAR=37.4
Pod documented
577 0 my($self, $text, $opts) = @_;
578 0 ▶ $opts->{allow_variables} = 1 unless defined $opts->{allow_variables};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"allow_variables"} 0 0 0
579  
580 # See: http://www.autohotkey.net/~deleyd/parameters/parameters.htm#CPP
581  
582 # Apply the Microsoft C/C++ parsing rules
583 0 $text =~ s{\\\\"}{\\\\\\\\\\"}g; # \\" -> \\\\\"
584 0 $text =~ s{(?<!\\)\\"}{\\\\\\"}g; # \" -> \\\"
585 0 $text =~ s{(?<!\\)"}{\\"}g; # " -> \"
586 0 ▶ $text = qq{"$text"} if $text =~ /[ \t#]/; # hash because gmake 4.2.1
Branch: 1 branch
BranchTrueFalseTotal
if $text =~ /[ \t#]/ 0 0 0
587  
588 # Apply the Command Prompt parsing rules (cmd.exe)
589 0 my @text = split /("[^"]*")/, $text;
590 # We should also escape parentheses, but it breaks one-liners containing
591 # $(MACRO)s in makefiles.
592 0 s{([<>|&^@!])}{^$1}g foreach grep { !/^"[^"]*"$/ } @text;
593 0 $text = join('', @text);
594  
595 # dmake expands {{ to { and }} to }.
596 0 ▶ if( $self->is_make_type('dmake') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_make_type("dmake")) 0 0 0
597 0 $text =~ s/{/{{/g;
598 0 $text =~ s/}/}}/g;
599 }
600  
601 $text = $opts->{allow_variables}
602 0 ▶ ? $self->escape_dollarsigns($text) : $self->escape_all_dollarsigns($text);
Branch: 1 branch
BranchTrueFalseTotal
$opts->{'allow_variables'} ? : 0 0 0
603  
604 0 return $text;
605 }
606  
607  
608 0 ▶sub escape_newlines {
Subroutine escape_newlines: not called CC=1 SCAR=6.9
Pod documented
609 0 my($self, $text) = @_;
610  
611 # Escape newlines
612 0 $text =~ s{\n}{\\\n}g;
613  
614 0 return $text;
615 }
616  
617  
618 =item cd
619  
620 dmake can handle Unix style cd'ing but nmake (at least 1.5) cannot. It
621 wants:
622  
623 cd dir1\dir2
624 command
625 another_command
626 cd ..\..
627  
628 =cut
629  
630 2 ▶sub cd {
Subroutine cd: called CC=2 SCAR=6.9
Pod documented
631 2 my($self, $dir, @cmds) = @_;
632  
633 2 ▶ return $self->SUPER::cd($dir, @cmds) unless $self->is_make_type('nmake');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_make_type("nmake") 1 1 2
634  
635 1 my $cmd = join "\n\t", map "$_", @cmds;
636  
637 1 my $updirs = $self->catdir(map { $self->updir } $self->splitdir($dir));
638  
639 # No leading tab and no trailing newline makes for easier embedding.
640 1 my $make_frag = sprintf <<'MAKE_FRAG', $dir, $cmd, $updirs;
641 cd %s
642 %s
643 cd %s
644 MAKE_FRAG
645  
646 1 chomp $make_frag;
647  
648 1 return $make_frag;
649 }
650  
651  
652 =item max_exec_len
653  
654 nmake 1.50 limits command length to 2048 characters.
655  
656 =cut
657  
658 0 ▶sub max_exec_len {
Subroutine max_exec_len: not called CC=2 SCAR=17.9
Pod documented
659 0 my $self = shift;
660  
661 0 ▶ return $self->{_MAX_EXEC_LEN} ||= 2 * 1024;
Condition0%0/2
$self->{"_MAX_EXEC_LEN"} ||= 2048
l!l
00
MC/DC0%0/1
$self->{"_MAX_EXEC_LEN"} ||= 2048
$self->{"_MAX_EXEC_LEN"}
Truth table0%0/2
A
A= $self->{"_MAX_EXEC_LEN"}
Aresult
11
00
662 }
663  
664  
665 =item os_flavor
666  
667 Windows is Win32.
668  
669 =cut
670  
671 0 ▶sub os_flavor {
Subroutine os_flavor: not called CC=1 SCAR=6.9
Pod documented
672 0 return('Win32');
673 }
674  
675 =item dbgoutflag
676  
677 Returns a CC flag that tells the CC to emit a separate debugging symbol file
678 when compiling an object file.
679  
680 =cut
681  
682 0 ▶sub dbgoutflag {
Subroutine dbgoutflag: not called CC=2 SCAR=17.9
Pod documented
683 0 ▶ $MSVC ? '-Fd$(*).pdb' : '';
Branch: 1 branch
BranchTrueFalseTotal
$MSVC ? : 0 0 0
684 }
685  
686 =item cflags
687  
688 Defines the PERLDLL symbol if we are configured for static building since all
689 code destined for the perl5xx.dll must be compiled with the PERLDLL symbol
690 defined.
691  
692 =cut
693  
694 0 ▶sub cflags {
Subroutine cflags: not called CC=6 SCAR=37.4
Pod documented
695 0 my($self,$libperl)=@_;
696 0 ▶ return $self->{CFLAGS} if $self->{CFLAGS};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CFLAGS"} 0 0 0
697 0 ▶ return '' unless $self->needs_linking();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->needs_linking 0 0 0
698  
699 0 my $base = $self->SUPER::cflags($libperl);
700 0 foreach (split /\n/, $base) {
701 0 ▶ /^(\S*)\s*=\s*(\S*)$/ and $self->{$1} = $2;
Branch: 1 branch
BranchTrueFalseTotal
/^(\S*)\s*=\s*(\S*)$/ and $self->{$1} = $2 0 0 0
702 };
703 0 ▶ $self->{CCFLAGS} .= " -DPERLDLL" if ($self->{LINKTYPE} eq 'static');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"LINKTYPE"} eq "static" 0 0 0
704  
705 0 return $self->{CFLAGS} = qq{
706 CCFLAGS = $self->{CCFLAGS}
707 OPTIMIZE = $self->{OPTIMIZE}
708 PERLTYPE = $self->{PERLTYPE}
709 };
710  
711 }
712  
713 =item make_type
714  
715 Returns a suitable string describing the type of makefile being written.
716  
717 =cut
718  
719 0 ▶sub make_type {
Subroutine make_type: not called CC=2 SCAR=17.9
Pod documented
720 0 my ($self) = @_;
721 0 my $make = $self->make;
722 0 $make = +( File::Spec->splitpath( $make ) )[-1];
723 0 $make =~ s!\.exe$!!i;
724 0 ▶ if ( $make =~ m![^A-Z0-9]!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($make =~ /[^A-Z0-9]/i) 0 0 0
725 0 ($make) = grep { m!make!i } split m![^A-Z0-9]!i, $make;
726 }
727 0 return "$make-style";
728 }
729  
730 2 1;
731 __END__
« lib/ExtUtils/Command/MM.pm ↑ Summary lib/ExtUtils/MM_Any.pm »