blib/lib/Module/Build/Compat.pm

filter: Statementstmt 62.9% 141 / 224 Branchbran 40.3% 42 / 104 Conditioncond 40.7% 11 / 27 MC/DCmcdc 12.5% 2 / 16 Subroutinesub 62.0% 18 / 29 Podpod 33.3% 3 / 9 totaltotal 53.0% 217 / 409 CC 72 SCAR 32.5
CC
72
Cov
55%
makefile_to_build_macros
90.0
makefile_to_build_args
72.0
fake_prereqs
30.0
CRAP 25.7
« blib/lib/Module/Build/Platform/VMS.pm ↑ Summary lib/Module/Build/Base.pm »
1 package Module::Build::Compat;
2  
3 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 our $VERSION = '0.4234';
6  
7 17 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 17 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 17 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 17 ▶use Module::Build;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 17 ▶use Module::Metadata;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 17 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 17 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 17 my %convert_installdirs = (
16 PERL => 'core',
17 SITE => 'site',
18 VENDOR => 'vendor',
19 );
20  
21 my %makefile_to_build =
22 (
23 TEST_VERBOSE => 'verbose',
24 VERBINST => 'verbose',
25 0 ▶ INC => sub { map {(extra_compiler_flags => $_)} Module::Build->split_like_shell(shift) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 ▶ POLLUTE => sub { (extra_compiler_flags => '-DPERL_POLLUTE') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 0 ▶ INSTALLDIRS => sub { (installdirs => $convert_installdirs{uc shift()}) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 0 ▶ LIB => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
29 0 my $lib = shift;
30 0 my %config = (
31 installprivlib => $lib,
32 installsitelib => $lib,
33 installarchlib => "$lib/$Config{archname}",
34 installsitearch => "$lib/$Config{archname}"
35 );
36 0 return map { (config => "$_=$config{$_}") } sort keys %config;
37 },
38  
39 # Convert INSTALLVENDORLIB and friends.
40 (
41 map {
42 306 my $name = $_;
43 0 ▶ $name => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 0 my @ret = (config => lc($name) . "=" . shift );
45 0 print STDERR "# Converted to @ret\n";
46  
47 0 return @ret;
48 }
49 306 } qw(
50 INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH
51 INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB
52 INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN
53 INSTALLSCRIPT INSTALLSITESCRIPT INSTALLVENDORSCRIPT
54 INSTALLMAN1DIR INSTALLSITEMAN1DIR INSTALLVENDORMAN1DIR
55 INSTALLMAN3DIR INSTALLSITEMAN3DIR INSTALLVENDORMAN3DIR
56 )
57 ),
58  
59 # Some names they have in common
60 17 map {$_, lc($_)} qw(DESTDIR PREFIX INSTALL_BASE UNINST),
61 );
62  
63 17 my %macro_to_build = %makefile_to_build;
64 # "LIB=foo make" is not the same as "perl Makefile.PL LIB=foo"
65 17 delete $macro_to_build{LIB};
66  
67 22 ▶sub _merge_prereq {
Subroutine _merge_prereq: called CC=11 SCAR=24.2
68 22 my ($req, $breq) = @_;
69 22 ▶ $req ||= {};
Condition50%1/2
$req ||= {}
l!l
220
MC/DC0%0/1
$req ||= {}
$req
Truth table50%1/2
A
A= $req
Aresult
11
00
70 22 ▶ $breq ||= {};
Condition50%1/2
$breq ||= {}
l!l
220
MC/DC0%0/1
$breq ||= {}
$breq
Truth table50%1/2
A
A= $breq
Aresult
11
00
71  
72 # validate formats
73 22 for my $p ( $req, $breq ) {
74 44 for my $k (sort keys %$p) {
75 33 ▶ next if $k eq 'perl';
Branch: 1 branch
BranchTrueFalseTotal
if $k eq "perl" 8 25 33
76  
77 25 my $v_obj = eval { version->new($p->{$k}) };
78 25 ▶ if ( ! defined $v_obj ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $v_obj) 0 25 25
79 0 die "A prereq of the form '$p->{$k}' for '$k' is not supported by Module::Build::Compat ( use a simpler version like '0.05' or 'v1.4.25' )\n";
80 }
81  
82 # It seems like a lot of people trip over "0.1.2" stuff, so we help them here...
83 25 ▶ if ( $v_obj->is_qv ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v_obj->is_qv) 1 24 25
84 1 my $proper_ver = $v_obj->numify;
85 1 warn "Dotted-decimal prereq '$p->{$k}' for '$k' is not portable - converting it to '$proper_ver'\n";
86 1 $p->{$k} = $proper_ver;
87 }
88 }
89 }
90 # merge
91 22 my $merge = { %$req };
92 22 for my $k ( keys %$breq ) {
93 16 ▶ my $v1 = $merge->{$k} || 0;
Condition100%2/2
$merge->{$k} || 0
l!l
88
MC/DC100%1/1
$merge->{$k} || 0
$merge->{$k}
Truth table100%2/2
A
A= $merge->{$k}
Aresult
11
00
94 16 my $v2 = $breq->{$k};
95 16 ▶ $merge->{$k} = $v1 > $v2 ? $v1 : $v2;
Branch: 1 branch
BranchTrueFalseTotal
$v1 > $v2 ? : 8 8 16
96 }
97 22 return %$merge;
98 }
99  
100  
101 98 ▶sub create_makefile_pl {
Subroutine create_makefile_pl: called CC=20 SCAR=30.8
Pod documented
102 98 my ($package, $type, $build, %args) = @_;
103  
104 98 ▶ die "Don't know how to build Makefile.PL of type '$type'"
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /^(small|passthrough|traditional)$/ 0 98 98
105 unless $type =~ /^(small|passthrough|traditional)$/;
106  
107 98 ▶ if ($type eq 'passthrough') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "passthrough") 42 56 98
108 42 $build->log_warn(<<"HERE");
109  
110 IMPORTANT NOTE: The '$type' style of Makefile.PL is deprecated and
111 may be removed in a future version of Module::Build in favor of the
112 'configure_requires' property. See Module::Build::Compat
113 documentation for details.
114  
115 HERE
116 }
117  
118 98 my $fh;
119 98 ▶ if ($args{fh}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'fh'}) { } 0 98 98
120 0 $fh = $args{fh};
121 } else {
122 98 ▶ $args{file} ||= 'Makefile.PL';
Condition50%1/2
$args{"file"} ||= "Makefile.PL"
l!l
098
MC/DC0%0/1
$args{"file"} ||= "Makefile.PL"
$args{"file"}
Truth table50%1/2
A
A= $args{"file"}
Aresult
11
00
123 98 local $build->{properties}{quiet} = 1;
124 98 $build->delete_filetree($args{file});
125 98 ▶ open($fh, '>', "$args{file}") or die "Can't write $args{file}: $!";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">", qq[$args{"file"}] or die qq[Can't write $args{"file"}: $!] 98 0 98
126 }
127  
128 98 print {$fh} "# Note: this file was auto-generated by ", __PACKAGE__, " version $VERSION\n";
129  
130 # Minimum perl version should be specified as "require 5.XXXXXX" in
131 # Makefile.PL
132 98 my $requires = $build->requires;
133 98 ▶ if ( my $minimum_perl = $requires->{perl} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $minimum_perl = $requires->{"perl"}) 27 71 98
134 27 my $min_ver = version->new($minimum_perl)->numify;
135 27 print {$fh} "require $min_ver;\n";
136 }
137  
138 # If a *bundled* custom subclass is being used, make sure we add its
139 # directory to @INC. Also, lib.pm always needs paths in Unix format.
140 98 my $subclass_load = '';
141 98 ▶ if (ref($build) ne "Module::Build") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $build ne "Module::Build") 22 76 98
142 22 my $subclass_dir = $package->subclass_dir($build);
143  
144 22 ▶ if (File::Spec->file_name_is_absolute($subclass_dir)) {
Branch: 1 branch
BranchTrueFalseTotal
if ('File::Spec'->file_name_is_absolute($subclass_dir)) { } 10 12 22
145 10 my $base_dir = $build->base_dir;
146  
147 10 ▶ if ($build->dir_contains($base_dir, $subclass_dir)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($build->dir_contains($base_dir, $subclass_dir)) 10 0 10
148 10 $subclass_dir = File::Spec->abs2rel($subclass_dir, $base_dir);
149 10 $subclass_dir = $package->unixify_dir($subclass_dir);
150 10 $subclass_load = "use lib '$subclass_dir';";
151 }
152 # Otherwise, leave it the empty string
153  
154 } else {
155 12 $subclass_dir = $package->unixify_dir($subclass_dir);
156 12 $subclass_load = "use lib '$subclass_dir';";
157 }
158 }
159  
160 98 ▶ if ($type eq 'small') {
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'small') { } 34 64 98
elsif ($type eq 'passthrough') { } 42 22 64
elsif ($type eq 'traditional') { } 22 0 22
161 34 printf {$fh} <<'EOF', $subclass_load, ref($build), ref($build);
162 use Module::Build::Compat 0.02;
163 %s
164 Module::Build::Compat->run_build_pl(args => \@ARGV);
165 require %s;
166 Module::Build::Compat->write_makefile(build_class => '%s');
167 EOF
168  
169 } elsif ($type eq 'passthrough') {
170 42 printf {$fh} <<'EOF', $subclass_load, ref($build), ref($build);
171  
172 unless (eval "use Module::Build::Compat 0.02; 1" ) {
173 print "This module requires Module::Build to install itself.\n";
174  
175 require ExtUtils::MakeMaker;
176 my $yn = ExtUtils::MakeMaker::prompt
177 (' Install Module::Build now from CPAN?', 'y');
178  
179 unless ($yn =~ /^y/i) {
180 die " *** Cannot install without Module::Build. Exiting ...\n";
181 }
182  
183 require Cwd;
184 require File::Spec;
185 require CPAN;
186  
187 # Save this 'cause CPAN will chdir all over the place.
188 my $cwd = Cwd::cwd();
189  
190 CPAN::Shell->install('Module::Build::Compat');
191 CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate
192 or die "Couldn't install Module::Build, giving up.\n";
193  
194 chdir $cwd or die "Cannot chdir() back to $cwd: $!";
195 }
196 eval "use Module::Build::Compat 0.02; 1" or die $@;
197 %s
198 Module::Build::Compat->run_build_pl(args => \@ARGV);
199 my $build_script = 'Build';
200 $build_script .= '.com' if $^O eq 'VMS';
201 exit(0) unless(-e $build_script); # cpantesters convention
202 require %s;
203 Module::Build::Compat->write_makefile(build_class => '%s');
204 EOF
205  
206 } elsif ($type eq 'traditional') {
207  
208 22 my (%MM_Args, %prereq);
209 0 ▶ if (eval "use Tie::IxHash 1.2; 1") {
Subroutine BEGIN: called CC=1 SCAR=1.2
Branch: 1 branch
BranchTrueFalseTotal
if (eval "use Tie::IxHash 1.2; 1") 0 22 22
210 0 tie %MM_Args, 'Tie::IxHash'; # Don't care if it fails here
211 0 tie %prereq, 'Tie::IxHash'; # Don't care if it fails here
212 }
213  
214 22 ▶ my %name = ($build->module_name
Branch: 1 branch
BranchTrueFalseTotal
$build->module_name ? : 22 0 22
215 ? (NAME => $build->module_name)
216 : (DISTNAME => $build->dist_name));
217  
218 22 ▶ my %version = ($build->dist_version_from
Branch: 1 branch
BranchTrueFalseTotal
$build->dist_version_from ? : 22 0 22
219 ? (VERSION_FROM => $build->dist_version_from)
220 : (VERSION => $build->dist_version)
221 );
222 22 %MM_Args = (%name, %version);
223  
224 22 %prereq = _merge_prereq( $build->requires, $build->build_requires );
225 22 %prereq = map {$_, $prereq{$_}} sort keys %prereq;
226  
227 22 delete $prereq{perl};
228 22 $MM_Args{PREREQ_PM} = \%prereq;
229  
230 22 ▶ $MM_Args{INSTALLDIRS} = $build->installdirs eq 'core' ? 'perl' : $build->installdirs;
Branch: 1 branch
BranchTrueFalseTotal
$build->installdirs eq 'core' ? : 0 22 22
231  
232 22 ▶ $MM_Args{EXE_FILES} = [ sort keys %{$build->script_files} ] if $build->script_files;
Branch: 1 branch
BranchTrueFalseTotal
if $build->script_files 22 0 22
233  
234 22 ▶ $MM_Args{PL_FILES} = $build->PL_files || {};
Condition100%2/2
$build->PL_files || {}
l!l
814
MC/DC100%1/1
$build->PL_files || {}
$build->PL_files
Truth table100%2/2
A
A= $build->PL_files
Aresult
11
00
235  
236 22 ▶ if ($build->recursive_test_files) {
Branch: 1 branch
BranchTrueFalseTotal
if ($build->recursive_test_files) 2 20 22
237 2 $MM_Args{test} = { TESTS => join q{ }, $package->_test_globs($build) };
238 }
239  
240 22 local $Data::Dumper::Terse = 1;
241 22 my $args = Data::Dumper::Dumper(\%MM_Args);
242 22 $args =~ s/\{(.*)\}/($1)/s;
243  
244 22 print $fh <<"EOF";
245 use ExtUtils::MakeMaker;
246 WriteMakefile
247 $args;
248 EOF
249 }
250 }
251  
252 2 ▶sub _test_globs {
Subroutine _test_globs: called CC=1 SCAR=0.0
253 2 my ($self, $build) = @_;
254  
255 4 return map { File::Spec->catfile($_, '*.t') }
256 2 ▶ @{$build->rscan_dir('t', sub { -d $File::Find::name })};
Subroutine __ANON__: called CC=1 SCAR=0.0
257 }
258  
259 22 ▶sub subclass_dir {
Subroutine subclass_dir: called CC=2 SCAR=7.1
Pod undocumented
260 22 my ($self, $build) = @_;
261  
262 22 ▶ return (Module::Metadata->find_module_dir_by_name(ref $build)
Condition66%2/3
'Module::Metadata'->find_module_dir_by_name(ref $build) || 'File::Spec'->catdir($build->config_dir, 'lib')
l!l&&r!l&&!r
10120
MC/DC0%0/2
'Module::Metadata'->find_module_dir_by_name(ref $build) || 'File::Spec'->catdir($build->config_dir, 'lib')
'Module::Metadata'->find_module_dir_by_name(ref $build) 'File::Spec'->catdir($build->config_dir, 'lib')
Truth table66%2/3
A || B
A= 'Module::Metadata'->find_module_dir_by_name(ref $build)B= 'File::Spec'->catdir($build->config_dir, 'lib')
ABresult
1X1
011
000
263 || File::Spec->catdir($build->config_dir, 'lib'));
264 }
265  
266 22 ▶sub unixify_dir {
Subroutine unixify_dir: called CC=1 SCAR=0.0
Pod undocumented
267 22 my ($self, $path) = @_;
268 22 return join '/', File::Spec->splitdir($path);
269 }
270  
271 0 ▶sub makefile_to_build_args {
Subroutine makefile_to_build_args: not called CC=8 SCAR=42.8
Pod undocumented
272 0 my $class = shift;
273 0 my @out;
274 0 foreach my $arg (@_) {
275 0 ▶ next if $arg eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $arg eq "" 0 0 0
276  
277 0 ▶ my ($key, $val) = ($arg =~ /^(\w+)=(.+)/ ? ($1, $2) :
Branch: 1 branch
BranchTrueFalseTotal
$arg =~ /^(\w+)=(.+)/ ? : 0 0 0
278 die "Malformed argument '$arg'");
279  
280 # Do tilde-expansion if it looks like a tilde prefixed path
281 0 ▶ ( $val ) = Module::Build->_detildefy( $val ) if $val =~ /^~/;
Branch: 1 branch
BranchTrueFalseTotal
if $val =~ /^~/ 0 0 0
282  
283 0 ▶ if (exists $makefile_to_build{$key}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $makefile_to_build{$key}) { } 0 0 0
elsif (exists $Module::Build::Compat::Config{lc $key}) { } 0 0 0
284 0 my $trans = $makefile_to_build{$key};
285 0 ▶ push @out, $class->_argvify( ref($trans) ? $trans->($val) : ($trans => $val) );
Branch: 1 branch
BranchTrueFalseTotal
ref $trans ? : 0 0 0
286 } elsif (exists $Config{lc($key)}) {
287 0 push @out, $class->_argvify( config => lc($key) . "=$val" );
288 } else {
289 # Assume M::B can handle it in lowercase form
290 0 push @out, $class->_argvify("\L$key" => $val);
291 }
292 }
293 0 return @out;
294 }
295  
296 0 ▶sub _argvify {
Subroutine _argvify: not called CC=2 SCAR=17.9
297 0 my ($self, @pairs) = @_;
298 0 my @out;
299 0 ▶ while (@pairs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@pairs) 0 0 0
300 0 my ($k, $v) = splice @pairs, 0, 2;
301 0 push @out, ("--$k", $v);
302 }
303 0 return @out;
304 }
305  
306 0 ▶sub makefile_to_build_macros {
Subroutine makefile_to_build_macros: not called CC=9 SCAR=45.0
Pod undocumented
307 0 my @out;
308 my %config; # must accumulate and return as a hashref
309 0 foreach my $macro (sort keys %macro_to_build) {
310 0 my $trans = $macro_to_build{$macro};
311 # On some platforms (e.g. Cygwin with 'make'), the mere presence
312 # of "EXPORT: FOO" in the Makefile will make $ENV{FOO} defined.
313 # Therefore we check length() too.
314 0 ▶ next unless exists $ENV{$macro} && length $ENV{$macro};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ENV{$macro} and length $ENV{$macro} 0 0 0
Condition0%0/3
exists $ENV{$macro} and length $ENV{$macro}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ENV{$macro} and length $ENV{$macro}
exists $ENV{$macro} length $ENV{$macro}
Truth table0%0/3
A and B
A= exists $ENV{$macro}B= length $ENV{$macro}
ABresult
0X0
100
111
315 0 my $val = $ENV{$macro};
316 0 ▶ my @args = ref($trans) ? $trans->($val) : ($trans => $val);
Branch: 1 branch
BranchTrueFalseTotal
ref $trans ? : 0 0 0
317 0 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 0 0
318 0 my ($k, $v) = splice(@args, 0, 2);
319 0 ▶ if ( $k eq 'config' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k eq 'config') { } 0 0 0
320 0 ▶ if ( $v =~ /^([^=]+)=(.*)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /^([^=]+)=(.*)$/) { } 0 0 0
321 0 $config{$1} = $2;
322 }
323 else {
324 0 warn "Couldn't parse config '$v'\n";
325 }
326 }
327 else {
328 0 push @out, ($k => $v);
329 }
330 }
331 }
332 0 ▶ push @out, (config => \%config) if %config;
Branch: 1 branch
BranchTrueFalseTotal
if %config 0 0 0
333 0 return @out;
334 }
335  
336 0 ▶sub run_build_pl {
Subroutine run_build_pl: not called CC=4 SCAR=30.0
Pod documented
337 0 my ($pack, %in) = @_;
338 0 ▶ $in{script} ||= 'Build.PL';
Condition0%0/2
$in{"script"} ||= "Build.PL"
l!l
00
MC/DC0%0/1
$in{"script"} ||= "Build.PL"
$in{"script"}
Truth table0%0/2
A
A= $in{"script"}
Aresult
11
00
339 0 ▶ my @args = $in{args} ? $pack->makefile_to_build_args(@{$in{args}}) : ();
Branch: 1 branch
BranchTrueFalseTotal
$in{'args'} ? : 0 0 0
340 0 print "# running $in{script} @args\n";
341 0 ▶ Module::Build->run_perl_script($in{script}, [], \@args) or die "Couldn't run $in{script}: $!";
Branch: 1 branch
BranchTrueFalseTotal
"Module::Build"->run_perl_script($in{"script"}, [], \@args) or die qq[Couldn't run $in{"script"}: $!] 0 0 0
342 }
343  
344 7 ▶sub fake_makefile {
Subroutine fake_makefile: called CC=14 SCAR=29.8
Pod undocumented
345 7 my ($self, %args) = @_;
346 7 ▶ unless (exists $args{build_class}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"build_class"}) 7 0 7
347 7 warn "Unknown 'build_class', defaulting to 'Module::Build'\n";
348 7 $args{build_class} = 'Module::Build';
349 }
350 7 my $class = $args{build_class};
351  
352 7 my $perl = $class->find_perl_interpreter;
353  
354 # VMS MMS/MMK need to use MCR to run the Perl image.
355 7 ▶ $perl = 'MCR ' . $perl if $self->_is_vms_mms;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_vms_mms 0 7 7
356  
357 7 ▶ my $noop = ($class->is_windowsish ? 'rem>nul' :
Branch: 2 branches
BranchTrueFalseTotal
$class->is_windowsish ? : 0 7 7
$self->_is_vms_mms ? : 0 7 7
358 $self->_is_vms_mms ? 'Continue' :
359 'true');
360  
361 7 ▶ my $filetype = $class->is_vmsish ? '.COM' : '';
Branch: 1 branch
BranchTrueFalseTotal
$class->is_vmsish ? : 0 7 7
362  
363 7 my $Build = 'Build' . $filetype . ' --makefile_env_macros 1';
364 7 my $unlink = $class->oneliner('1 while unlink $ARGV[0]', [], [$args{makefile}]);
365 7 ▶ $unlink =~ s/\$/\$\$/g unless $class->is_vmsish;
Branch: 1 branch
BranchTrueFalseTotal
unless $class->is_vmsish 7 0 7
366  
367 7 my $maketext = join '', map { "$_=\n" } sort keys %macro_to_build;
368  
369 $maketext .= ($^O eq 'os2' ? "SHELL = sh\n\n"
370 7 ▶ : $^O eq 'MSWin32' && $Config{make} =~ /gmake/
Branch: 2 branches
BranchTrueFalseTotal
$^O eq 'os2' ? : 0 7 7
$^O eq 'MSWin32' && $Module::Build::Compat::Config{'make'} =~ /gmake/ ? : 0 7 7
Condition33%1/3
$^O eq "MSWin32" and $Module::Build::Compat::Config{"make"} =~ /gmake/
!ll&&!rl&&r
700
MC/DC0%0/2
$^O eq "MSWin32" and $Module::Build::Compat::Config{"make"} =~ /gmake/
$^O eq "MSWin32" $Module::Build::Compat::Config{"make"} =~ /gmake/
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= $Module::Build::Compat::Config{"make"} =~ /gmake/
ABresult
0X0
100
111
371 ? "SHELL = $ENV{COMSPEC}\n\n" : "\n\n");
372  
373 7 $maketext .= <<"EOF";
374 all : force_do_it
375 $perl $Build
376 realclean : force_do_it
377 $perl $Build realclean
378 $unlink
379 distclean : force_do_it
380 $perl $Build distclean
381 $unlink
382  
383  
384 force_do_it :
385 @ $noop
386 EOF
387  
388 7 foreach my $action ($class->known_actions) {
389 266 ▶ next if $action =~ /^(all|distclean|realclean|force_do_it)$/; # Don't double-define
Branch: 1 branch
BranchTrueFalseTotal
if $action =~ /^(all|distclean|realclean|force_do_it)$/ 14 252 266
390 252 $maketext .= <<"EOF";
391 $action : force_do_it
392 $perl $Build $action
393 EOF
394 }
395  
396 7 ▶ if ($self->_is_vms_mms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_vms_mms) { } 0 7 7
397 # Roll our own .EXPORT as MMS/MMK don't honor that directive.
398 0 $maketext .= "\n.FIRST\n\t\@ $noop\n";
399 0 for my $macro (sort keys %macro_to_build) {
400 0 $maketext .= ".IFDEF $macro\n\tDEFINE $macro \"\$($macro)\"\n.ENDIF\n";
401 }
402 0 $maketext .= "\n";
403 }
404 else {
405 7 $maketext .= "\n.EXPORT : " . join(' ', sort keys %macro_to_build) . "\n\n";
406 }
407  
408 7 return $maketext;
409 }
410  
411 0 ▶sub fake_prereqs {
Subroutine fake_prereqs: not called CC=5 SCAR=34.0
Pod undocumented
412 0 my $file = File::Spec->catfile('_build', 'prereqs');
413 0 ▶ open(my $fh, '<', "$file") or die "Can't read $file: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", "$file" or die "Can't read ${file}: $!" 0 0 0
414 0 my $prereqs = eval do {local $/; <$fh>};
415 0 close $fh;
416  
417 0 my %merged = _merge_prereq( $prereqs->{requires}, $prereqs->{build_requires} );
418 0 my @prereq;
419 0 foreach (sort keys %merged) {
420 0 ▶ next if $_ eq 'perl';
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "perl" 0 0 0
421 0 push @prereq, "$_=>q[$merged{$_}]";
422 }
423 0 ▶ return unless @prereq;
Branch: 1 branch
BranchTrueFalseTotal
unless @prereq 0 0 0
424 0 return "# PREREQ_PM => { " . join(", ", @prereq) . " }\n\n";
425 }
426  
427  
428 0 ▶sub write_makefile {
Subroutine write_makefile: not called CC=5 SCAR=34.0
Pod documented
429 0 my ($pack, %in) = @_;
430  
431 0 ▶ unless (exists $in{build_class}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $in{"build_class"}) 0 0 0
432 0 warn "Unknown 'build_class', defaulting to 'Module::Build'\n";
433 0 $in{build_class} = 'Module::Build';
434 }
435 0 my $class = $in{build_class};
436 0 ▶ $in{makefile} ||= $pack->_is_vms_mms ? 'Descrip.MMS' : 'Makefile';
Branch: 1 branch
BranchTrueFalseTotal
$pack->_is_vms_mms ? : 0 0 0
Condition0%0/3
$in{"makefile"} ||= $pack->_is_vms_mms ? "Descrip.MMS" : "Makefile"
l!l&&r!l&&!r
000
MC/DC0%0/2
$in{"makefile"} ||= $pack->_is_vms_mms ? "Descrip.MMS" : "Makefile"
$in{"makefile"} $pack->_is_vms_mms ? "Descrip.MMS" : "Makefile"
Truth table0%0/3
A ||= B
A= $in{"makefile"}B= $pack->_is_vms_mms ? "Descrip.MMS" : "Makefile"
ABresult
1X1
011
000
437  
438 0 ▶ open MAKE, "> $in{makefile}" or die "Cannot write $in{makefile}: $!";
Branch: 1 branch
BranchTrueFalseTotal
open MAKE, qq[> $in{"makefile"}] or die qq[Cannot write $in{"makefile"}: $!] 0 0 0
439 0 print MAKE $pack->fake_prereqs;
440 0 print MAKE $pack->fake_makefile(%in);
441 0 close MAKE;
442 }
443  
444 21 ▶sub _is_vms_mms {
Subroutine _is_vms_mms: called CC=2 SCAR=9.2
445 21 ▶ return Module::Build->is_vmsish && ($Config{make} =~ m/MM[SK]/i);
Condition33%1/3
'Module::Build'->is_vmsish && $Module::Build::Compat::Config{'make'} =~ /MM[SK]/i
!ll&&!rl&&r
2100
MC/DC0%0/2
'Module::Build'->is_vmsish && $Module::Build::Compat::Config{'make'} =~ /MM[SK]/i
'Module::Build'->is_vmsish $Module::Build::Compat::Config{'make'} =~ /MM[SK]/i
Truth table33%1/3
A && B
A= 'Module::Build'->is_vmsishB= $Module::Build::Compat::Config{'make'} =~ /MM[SK]/i
ABresult
0X0
100
111
446 }
447  
448 17 1;
449 __END__
« blib/lib/Module/Build/Platform/VMS.pm ↑ Summary lib/Module/Build/Base.pm »