blib/lib/Distribution/Guess/BuildSystem.pm

filter: Statementstmt 98.6% 144 / 146 Branchbran 96.0% 73 / 76 Conditioncond 100% 15 / 15 MC/DCmcdc 100% 10 / 10 Subroutinesub 100% 52 / 52 Podpod 100% 37 / 37 totaltotal 98.5% 331 / 336 CC 48 SCAR 10.6
CC
48
Cov
98%
preferred_build_file
9.0
_get_version
5.3
_file_has_string
4.0
CRAP 2.9
↑ Summary
1 13 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package Distribution::Guess::BuildSystem;
4 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 13 ▶use Carp qw(carp);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 13 ▶use Config qw(%Config);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use Cwd qw(cwd);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 13 ▶use File::Spec::Functions qw(catfile);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 13 ▶use Module::Extract::VERSION;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 13 our $VERSION = '1.007';
17  
18 =encoding utf8
19  
20 =head1 NAME
21  
22 Distribution::Guess::BuildSystem - Guess what this distribution uses to build itself
23  
24 =head1 SYNOPSIS
25  
26 use Distribution::Guess::BuildSystem;
27  
28 chdir $dist_dir;
29  
30 my $guesser = Distribution::Guess::BuildSystem->new(
31 dist_dir => $dir
32 );
33  
34 my $build_files = $guesser->build_files; # Hash ref
35  
36 my $build_pl = $guesser->has_build_pl;
37 my $makefile_pl = $guesser->has_makefile_pl;
38  
39 my $both = $guesser->has_build_and_makefile;
40  
41 my $build_command = $guesser->build_commands; # Hash ref
42  
43 if( $guesser->uses_module_install ) {
44 my $version = $guesser->module_install_version;
45 my $pita = $guesser->uses_auto_install;
46 }
47  
48 if( $guesser->uses_makemaker ) {
49 my $version = $guesser->makemaker_version;
50 my $make = $guesser->make_command;
51 }
52  
53 =head1 DESCRIPTION
54  
55 There are three major build system for Perl distributions:
56  
57 =over 4
58  
59 =item * ExtUtils::MakeMaker
60  
61 Uses F<Makefile.PL> and C<make>.
62  
63 =item * Module::Build
64  
65 Uses F<Build.PL> and C<perl>, although it might have a F<Makefile.PL> that is
66 a wrapper.
67  
68 =item * Module::Install
69  
70 Uses F<Makefile.PL> and calls to an embedded C<Module::Install>. It might
71 use C<auto_install> to call C<CPAN.pm> at build time.
72  
73 =back
74  
75 The trick is to figure out which one you are supposed to use. This module has
76 several methods to look at a distribution and guess what its build system is.
77 The main object is simply some settings. Every time you want to ask a
78 question about the distribution, the object looks at the distribution. That is,
79 it doesn't capture the information when you create the object.
80  
81 =head2 Methods
82  
83 =over 4
84  
85 =item new
86  
87 Creates a new guesser object. You can set:
88  
89 dist_dir - the distribution directory (where the build file is)
90 perl_binary - the path to the perl you want to use
91 prefer_module_build - some methods will return the preferred builder
92 prefer_makemaker - some methods will return the preferred builder
93  
94 If you prefer
95 The defaults are:
96  
97 dist_dir - current working directory
98 perl_binary - $^X (may be relative and no longer in path!)
99 prefer_module_build - true
100 prefer_makemaker - false
101  
102 =cut
103  
104 17 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
105 17 my %defaults = (
106 dist_dir => cwd(),
107 prefer_module_build => 1,
108 prefer_makemaker => 0,
109 perl_binary => $^X,
110 );
111  
112 17 my( $class, %args ) = @_;
113  
114 17 bless { %defaults, %args }, $class;
115 }
116  
117 =item dist_dir( [ DIR ] )
118  
119 Returns or sets the distribution directory.
120  
121 =cut
122  
123 581 ▶sub dist_dir {
Subroutine dist_dir: called CC=1 SCAR=0.0
Pod documented
124 581 my( $self ) = shift;
125 581 $self->_setting( 'dist_dir', @_ );
126 }
127  
128 =item perl_binary( [PERL] )
129  
130 Returns or sets the perl binary path. This is either the one that you set
131 or the value of C<$^X>. There's no check to verify that this is actually
132 a perl binary.
133  
134 =cut
135  
136 4 ▶sub perl_binary {
Subroutine perl_binary: called CC=1 SCAR=0.0
Pod documented
137 4 my( $self ) = shift;
138 4 $self->_setting( 'perl_binary', @_ );
139 }
140  
141 =item prefer_makemaker( [TRUE|FALSE] )
142  
143 Returns or sets the Module::Build preference. If this is true, some of
144 the methods preferentially return answers for Module::Build over
145 MakeMaker when a distribution can use both systems. If both
146 C<prefer_makemaker> and C<prefer_module_build> are true, then
147 MakeMaker wins.
148 =cut
149  
150 8 ▶sub prefer_makemaker {
Subroutine prefer_makemaker: called CC=1 SCAR=0.0
Pod documented
151 8 my( $self ) = shift;
152 8 $self->_setting( 'prefer_makemaker', @_ );
153 }
154  
155 =item prefer_module_build( [TRUE|FALSE] )
156  
157 Returns or sets the Module::Build preference. If this is true, some of
158 the methods preferentially return answers for Module::Build over
159 MakeMaker when a distribution can use both systems. If both
160 C<prefer_makemaker> and C<prefer_module_build> are true, then
161 MakeMaker wins.
162  
163 =cut
164  
165 17 ▶sub prefer_module_build {
Subroutine prefer_module_build: called CC=1 SCAR=0.0
Pod documented
166 17 my( $self ) = shift;
167 17 $self->_setting( 'prefer_module_build', @_ );
168 }
169  
170 613 ▶sub _setting {
Subroutine _setting: called CC=2 SCAR=6.9
171 613 my( $self, $key, $value ) = @_;
172  
173 613 ▶ if( @_ == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) 3 610 613
174 3 $self->{$key} = $value;
175 }
176  
177 613 return $self->{$key};
178 }
179  
180 =back
181  
182 =head2 Questions about the distribution
183  
184 =over 4
185  
186 =item build_files
187  
188 Returns an hash reference of build files found in the distribution. The
189 keys are the filenames of the build files. The values
190  
191 =cut
192  
193 {
194 13 my @files = (
195 [ qw( has_makefile_pl makefile_pl ) ],
196 [ qw( has_build_pl build_pl ) ],
197  
198 );
199  
200 20 ▶sub build_files {
Subroutine build_files: called CC=3 SCAR=11.0
Pod documented
201 20 my %found;
202  
203 20 foreach my $pairs ( @files ) {
204 40 my( $check, $file ) = @$pairs;
205 40 ▶ $found{ $_[0]->$file() } = $_[0]->$file() if $_[0]->$check()
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->$check 24 16 40
206 }
207  
208 20 return \%found;
209 }
210 }
211  
212 =item preferred_build_file
213  
214 Returns the build file that you should use, even if there is more than
215 one. Right now this is simple:
216  
217 1. In the single build file distributions, return that build file
218  
219 2. If you've specified a preference with C<prefer_module_build> or
220 C<prefer_makemaker>, use that.
221  
222 3. If there is no preference (both are false), prefer C<Module::Build>.
223  
224 4. If no of those work, return nothing.
225  
226 =cut
227  
228 13 ▶sub preferred_build_file {
Subroutine preferred_build_file: called CC=9 SCAR=22.0
Pod documented
229 # preference doesn't matter in single build system cases
230 32 ▶ return $_[0]->makefile_pl if $_[0]->uses_makemaker_only;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->uses_makemaker_only 13 19 32
231 19 ▶ return $_[0]->build_pl if $_[0]->uses_module_build_only;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->uses_module_build_only 6 13 19
232  
233 # preference now matter
234 13 ▶ return $_[0]->build_pl if(
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->prefer_module_build and $_[0]->uses_module_build 5 8 13
Condition100%3/3
$_[0]->prefer_module_build and $_[0]->uses_module_build
!ll&&!rl&&r
355
MC/DC100%2/2
$_[0]->prefer_module_build and $_[0]->uses_module_build
$_[0]->prefer_module_build $_[0]->uses_module_build
Truth table100%3/3
A and B
A= $_[0]->prefer_module_buildB= $_[0]->uses_module_build
ABresult
0X0
100
111
235 $_[0]->prefer_module_build and $_[0]->uses_module_build );
236 8 ▶ return $_[0]->makefile_pl if(
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->prefer_makemaker and $_[0]->uses_makemaker 2 6 8
Condition100%3/3
$_[0]->prefer_makemaker and $_[0]->uses_makemaker
!ll&&!rl&&r
422
MC/DC100%2/2
$_[0]->prefer_makemaker and $_[0]->uses_makemaker
$_[0]->prefer_makemaker $_[0]->uses_makemaker
Truth table100%3/3
A and B
A= $_[0]->prefer_makemakerB= $_[0]->uses_makemaker
ABresult
0X0
100
111
237 $_[0]->prefer_makemaker and $_[0]->uses_makemaker );
238  
239 # absence of preference
240 6 ▶ return $_[0]->build_pl if $_[0]->uses_module_build;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->uses_module_build 1 5 6
241 5 ▶ return $_[0]->makefile_pl if $_[0]->uses_makemaker;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->uses_makemaker 3 2 5
242  
243 # no build system?
244 2 return;
245 }
246  
247 =item preferred_build_command
248  
249 Returns the build command that you should use. This uses the logic of
250 C<preferred_build_file>. It returns the result of either C<perl_command>
251 or C<make_command>.
252  
253 =cut
254  
255 17 ▶sub preferred_build_command {
Subroutine preferred_build_command: called CC=3 SCAR=11.0
Pod documented
256 17 ▶ return $_[0]->build_command if $_[0]->preferred_build_file eq $_[0]->build_pl;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->preferred_build_file eq $_[0]->build_pl 9 8 17
257 8 ▶ return $_[0]->make_command if $_[0]->preferred_build_file eq $_[0]->makefile_pl;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->preferred_build_file eq $_[0]->makefile_pl 7 1 8
258 1 return;
259 }
260  
261 =item build_file_paths
262  
263 Returns an anonymous hash to the paths to the build files, based on
264 the dist_dir argument to C<new> and the return value of
265 C<build_files>. The keys are the file names and the values are
266 the paths.
267  
268 =cut
269  
270 10 ▶sub build_file_paths {
Subroutine build_file_paths: called CC=2 SCAR=6.9
Pod documented
271 10 my %paths;
272  
273 10 foreach my $file ( keys %{ $_[0]->build_files } ) {
274 12 $paths{$file} = File::Spec->catfile( $_[0]->dist_dir, $file );
275 }
276  
277 10 return \%paths;
278 }
279  
280 =item makefile_pl_path
281  
282 =cut
283  
284 59 ▶sub makefile_pl_path {
Subroutine makefile_pl_path: called CC=2 SCAR=6.9
Pod documented
285 59 ▶ return unless $_[0]->has_makefile_pl;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->has_makefile_pl 1 58 59
286  
287 58 File::Spec->catfile( $_[0]->dist_dir, $_[0]->makefile_pl );
288 }
289  
290 =item build_pl_path
291  
292 =cut
293  
294 37 ▶sub build_pl_path {
Subroutine build_pl_path: called CC=2 SCAR=6.9
Pod documented
295 37 ▶ return unless $_[0]->has_build_pl;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->has_build_pl 3 34 37
296  
297 34 File::Spec->catfile( $_[0]->dist_dir, $_[0]->build_pl );
298 }
299  
300 =item has_build_pl
301  
302 Has the file name returned by C<build_pl>.
303  
304 =cut
305  
306 473 ▶sub _has_file {
Subroutine _has_file: called CC=2 SCAR=6.9
307 473 my( $self, $file ) = @_;
308  
309 473 my $path = File::Spec->catfile(
310 $self->dist_dir, $file
311 );
312  
313 473 ▶ $self->{has}{$file} = $path if -e $path;
Branch: 1 branch
BranchTrueFalseTotal
if -e $path 354 119 473
314 473 $self->{has}{$file};
315 }
316  
317 217 ▶sub has_build_pl { $_[0]->_has_file( $_[0]->build_pl ) }
Subroutine has_build_pl: called CC=1 SCAR=0.0
Pod documented
318  
319 =item has_makefile_pl
320  
321 Has the file name returned by C<makefile_pl>.
322  
323 =cut
324  
325 256 ▶sub has_makefile_pl { $_[0]->_has_file( $_[0]->makefile_pl ) }
Subroutine has_makefile_pl: called CC=1 SCAR=0.0
Pod documented
326  
327 =item has_build_and_makefile
328  
329 Has both the files returned by C<makefile_pl> and C<build_pl>.
330  
331 =cut
332  
333 10 ▶sub has_build_and_makefile {
Subroutine has_build_and_makefile: called CC=2 SCAR=6.9
Pod documented
334 10 ▶ $_[0]->has_build_pl
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->has_build_pl and $_[0]->has_makefile_pl 4 6 10
335 &&
336 $_[0]->has_makefile_pl
337 }
338  
339 =item make_command
340  
341 Looks in %Config to see what perl discovered when someone built it if you
342 can use a C<make> variant to build the distribution.
343  
344 =cut
345  
346 29 ▶sub make_command { $_[0]->has_makefile_pl ? $Config{make} : () }
Subroutine make_command: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->has_makefile_pl ? : 28 1 29
347  
348 =item build_command
349  
350 Returns C<./Build>, the script that F<Build.PL> should have created, if
351 the distribution has a F<Build.PL>. Otherwise it returns nothing.
352  
353 =cut
354  
355 18 ▶sub build_command { $_[0]->has_build_pl ? './Build' : () }
Subroutine build_command: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->has_build_pl ? : 18 0 18
356  
357 =item perl_command
358  
359 Returns the perl currently running. This is the perl that you would use
360 to run the F<Makefile.PL> or F<Build.PL>.
361  
362 =cut
363  
364 7 ▶sub perl_command { $_[0]->has_build_pl ? $_[0]->perl_binary : () }
Subroutine perl_command: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->has_build_pl ? : 4 3 7
365  
366 =item build_commands
367  
368 Returns a hash reference of the commands you can use to build the
369 distribution. The keys are the commands, such as C<make> or C<perl Build.PL>.
370  
371 =cut
372  
373  
374 10 ▶sub build_commands {
Subroutine build_commands: called CC=3 SCAR=11.0
Pod documented
375 10 my %commands;
376  
377 10 ▶ $commands{ $_[0]->make_command } = 1
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->has_makefile_pl 8 2 10
378 if $_[0]->has_makefile_pl;
379  
380 10 ▶ $commands{ $_[0]->perl_command . " " . $_[0]->build_pl } = 1
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->has_build_pl 4 6 10
381 if $_[0]->has_build_pl;
382  
383 10 return \%commands;
384 }
385  
386 =item uses_makemaker
387  
388 Returns true if the distro uses C<ExtUtils::Makemaker>.
389  
390 =cut
391  
392 68 ▶sub _get_modules {
Subroutine _get_modules: called CC=1 SCAR=0.0
393 68 my( $self, $path ) = @_;
394 68 my $extractor = $self->module_extractor_class->new;
395 68 $extractor->get_modules( $path );
396 }
397  
398 30 ▶sub uses_makemaker {
Subroutine uses_makemaker: called CC=2 SCAR=6.9
Pod documented
399 30 ▶ return unless $_[0]->has_makefile_pl;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->has_makefile_pl 8 22 30
400  
401 22 scalar grep { $_ eq $_[0]->makemaker_name }
402 $_[0]->_get_modules( $_[0]->makefile_pl_path )
403 }
404  
405 =item uses_makemaker_only
406  
407 Returns true if MakeMaker is the only build system. Knowing that can cut
408 down on the logic quite a bit since you don't have to choose between
409 possibilities or preferences.
410  
411 =cut
412  
413 36 ▶sub uses_makemaker_only {
Subroutine uses_makemaker_only: called CC=3 SCAR=11.0
Pod documented
414 36 ▶ return unless $_[0]->has_makefile_pl;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->has_makefile_pl 9 27 36
415 27 ▶ return if $_[0]->has_build_pl;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->has_build_pl 12 15 27
416  
417 15 return 1;
418 }
419  
420 =item makemaker_version
421  
422 Returns the version of Makemaker installed for the perl running this code.
423  
424 =cut
425  
426 5 ▶sub makemaker_version {
Subroutine makemaker_version: called CC=2 SCAR=6.9
Pod documented
427 5 ▶ return unless $_[0]->uses_makemaker;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->uses_makemaker 4 1 5
428  
429 1 my $version = $_[0]->_get_version( $_[0]->makemaker_name );
430 }
431  
432 3 ▶sub _get_version {
Subroutine _get_version: called CC=5 SCAR=16.6
433 3 require Module::Extract::VERSION;
434  
435 3 my( $self, $module, @dirs ) = @_;
436  
437 3 ▶ @dirs = @INC unless @dirs;
Branch: 1 branch
BranchTrueFalseTotal
unless @dirs 2 1 3
438  
439 3 my $file = catfile( split /::/, $module ) . ".pm";
440  
441 3 my $found_module = 0;
442 3 foreach my $dir ( @dirs ) {
443 13 my $module = catfile( $dir, $file );
444 13 ▶ next unless -e $module;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $module 10 3 13
445  
446 3 $found_module = 1;
447 3 return Module::Extract::VERSION->parse_version_safely( $module );
448 }
449  
450 0 ▶ return '$module not installed' unless $found_module;
Branch: 1 branch
BranchTrueFalseTotal
unless $found_module 0 0 0
451 0 return;
452 }
453  
454 =item uses_module_build
455  
456 Returns true if this distribution uses C<Module::Build>. This means that it
457 has a F<Build.PL> and that the F<Build.PL> actually uses C<Module::Build>.
458  
459 =cut
460  
461 37 ▶sub uses_module_build {
Subroutine uses_module_build: called CC=2 SCAR=6.9
Pod documented
462 37 ▶ return unless $_[0]->has_build_pl;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->has_build_pl 12 25 37
463  
464 25 scalar grep { $_ eq $_[0]->module_build_name }
465 $_[0]->_get_modules( $_[0]->build_pl_path );
466 }
467  
468 =item uses_module_build_only
469  
470 Returns true if C<Module::Build> is the only build system. Knowing that can cut
471 down on the logic quite a bit since you don't have to choose between
472 possibilities or preferences.
473  
474 =cut
475  
476 25 ▶sub uses_module_build_only {
Subroutine uses_module_build_only: called CC=3 SCAR=11.0
Pod documented
477 25 ▶ return unless $_[0]->has_build_pl;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->has_build_pl 3 22 25
478 22 ▶ return if $_[0]->has_makefile_pl;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->has_makefile_pl 13 9 22
479  
480 9 return 1;
481 }
482  
483 =item module_build_version
484  
485 Returns the version of C<Module::Build> install for perl running this code.
486  
487 =cut
488  
489 5 ▶sub module_build_version {
Subroutine module_build_version: called CC=2 SCAR=6.9
Pod documented
490 5 ▶ return unless $_[0]->uses_module_build;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->uses_module_build 4 1 5
491  
492 1 my $version = $_[0]->_get_version( $_[0]->module_build_name );
493 }
494  
495 =item uses_module_install
496  
497 Returns true if this distribution uses C<Module::Install>.
498  
499 =cut
500  
501 24 ▶sub uses_module_install {
Subroutine uses_module_install: called CC=2 SCAR=6.9
Pod documented
502 24 ▶ return unless $_[0]->has_makefile_pl;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->has_makefile_pl 3 21 24
503  
504 21 scalar grep { $_ eq $_[0]->module_install_name }
505 $_[0]->_get_modules( $_[0]->makefile_pl_path )
506 }
507  
508 =item uses_auto_install
509  
510 Returns true if this distribution uses C<Module::Install> and will
511 use the auto_install feature.
512  
513 This is a very simple test right now. If it finds the string
514 C<auto_install> in the build file, it returns true.
515  
516 =cut
517  
518 10 ▶sub uses_auto_install {
Subroutine uses_auto_install: called CC=3 SCAR=11.0
Pod documented
519 10 ▶ return unless $_[0]->has_makefile_pl && $_[0]->uses_module_install;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->has_makefile_pl and $_[0]->uses_module_install 8 2 10
Condition100%3/3
$_[0]->has_makefile_pl and $_[0]->uses_module_install
!ll&&!rl&&r
262
MC/DC100%2/2
$_[0]->has_makefile_pl and $_[0]->uses_module_install
$_[0]->has_makefile_pl $_[0]->uses_module_install
Truth table100%3/3
A and B
A= $_[0]->has_makefile_plB= $_[0]->uses_module_install
ABresult
0X0
100
111
520  
521 2 $_[0]->_file_has_string( $_[0]->makefile_pl_path, 'auto_install' );
522 }
523  
524 =item module_install_version
525  
526 Returns the version of C<Module::Install>.
527  
528 =cut
529  
530 6 ▶sub module_install_version {
Subroutine module_install_version: called CC=2 SCAR=6.9
Pod documented
531 6 ▶ return unless $_[0]->uses_module_install;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->uses_module_install 5 1 6
532  
533 1 my $version = $_[0]->_get_version(
534 $_[0]->module_install_name, $_[0]->module_install_dir
535 );
536 }
537  
538 =item uses_module_build_compat
539  
540 Returns true if this distribution uses C<Module::Install::Compat> and will
541 use the C<create_makefile_pl> feature.
542  
543 This is a very simple test right now. If it finds the string
544 C<create_makefile_pl> in the build file, it returns true.
545  
546 =cut
547  
548 10 ▶sub uses_module_build_compat {
Subroutine uses_module_build_compat: called CC=3 SCAR=11.0
Pod documented
549 10 ▶ return unless $_[0]->has_build_pl && $_[0]->uses_module_build;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->has_build_pl and $_[0]->uses_module_build 7 3 10
Condition100%3/3
$_[0]->has_build_pl and $_[0]->uses_module_build
!ll&&!rl&&r
613
MC/DC100%2/2
$_[0]->has_build_pl and $_[0]->uses_module_build
$_[0]->has_build_pl $_[0]->uses_module_build
Truth table100%3/3
A and B
A= $_[0]->has_build_plB= $_[0]->uses_module_build
ABresult
0X0
100
111
550  
551 3 $_[0]->_file_has_string( $_[0]->build_pl_path, 'create_makefile_pl' );
552 }
553  
554 =item build_pl_wraps_makefile_pl
555  
556 Returns true if C<Build.PL> is a wrapper around C<Makefile.PL>.
557  
558 =cut
559  
560 5 ▶sub build_pl_wraps_makefile_pl {
Subroutine build_pl_wraps_makefile_pl: called CC=3 SCAR=11.0
Pod documented
561 5 ▶ return unless $_[0]->has_build_pl && $_[0]->has_makefile_pl;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->has_build_pl and $_[0]->has_makefile_pl 4 1 5
Condition100%3/3
$_[0]->has_build_pl and $_[0]->has_makefile_pl
!ll&&!rl&&r
311
MC/DC100%2/2
$_[0]->has_build_pl and $_[0]->has_makefile_pl
$_[0]->has_build_pl $_[0]->has_makefile_pl
Truth table100%3/3
A and B
A= $_[0]->has_build_plB= $_[0]->has_makefile_pl
ABresult
0X0
100
111
562  
563 1 $_[0]->_file_has_string( $_[0]->build_pl_path,
564 "Makefile.PL" );
565 }
566  
567 13 ▶sub _file_has_string {
Subroutine _file_has_string: called CC=4 SCAR=13.9
568 13 my $fh;
569 13 ▶ unless( open $fh, "<", $_[1] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open $fh, "<", $_[1]) 1 12 13
570 1 carp "Could not open $_[1]: $!";
571 1 return;
572 }
573  
574 12 ▶ while( <$fh> ) { return 1 if /\Q$_[2]/ }
Branch: 2 branches
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 128 6 134
if /\Q$_[2]\E/ 6 122 128
575  
576 6 return;
577 }
578  
579 =item just_give_me_a_hash
580  
581 =cut
582  
583 {
584 13 my @methods = qw(
585 dist_dir
586 build_files
587 build_file_paths
588 makefile_pl_path
589 build_pl_path
590 has_build_pl
591 has_makefile_pl
592 has_build_and_makefile
593 make_command
594 perl_command
595 build_commands
596 uses_makemaker
597 makemaker_version
598 uses_module_build
599 module_build_version
600 uses_module_install
601 uses_auto_install
602 module_install_version
603 uses_module_build_compat
604 build_pl_wraps_makefile_pl
605 );
606  
607 3 ▶sub just_give_me_a_hash {
Subroutine just_give_me_a_hash: called CC=2 SCAR=6.9
Pod documented
608 3 my %hash = ();
609  
610 3 foreach my $method ( @methods ) {
611 60 $hash{ $method } = $_[0]->$method();
612 }
613  
614 3 return \%hash;
615 }
616 }
617  
618 =back
619  
620 =head2 Methods for strings
621  
622 You may want to override or extend these, so they are methods.
623  
624 =over 4
625  
626 =item makefile_pl
627  
628 Returns the string used for the Makefile.PL filename. Seems stupid
629 until you want to change it in a subclass, which you can do now
630 that it's a method. :)
631  
632 =cut
633  
634 385 ▶sub makefile_pl { 'Makefile.PL' }
Subroutine makefile_pl: called CC=1 SCAR=0.0
Pod documented
635  
636 =item build_pl
637  
638 Returns the string used for the Build.PL filename. Seems stupid
639 until you want to change it in a subclass, which you can do now
640 that it's a method. :)
641  
642 =cut
643  
644 308 ▶sub build_pl { 'Build.PL' }
Subroutine build_pl: called CC=1 SCAR=0.0
Pod documented
645  
646 =item makemaker_name
647  
648 Returns the module name of Makemaker, which is C<ExtUtils::MakeMaker>.
649  
650 =cut
651  
652 47 ▶sub makemaker_name { 'ExtUtils::MakeMaker' }
Subroutine makemaker_name: called CC=1 SCAR=0.0
Pod documented
653  
654 =item module_build_name
655  
656 Return the string representing the name for Module::Build.
657  
658 =cut
659  
660 19 ▶sub module_build_name { 'Module::Build' }
Subroutine module_build_name: called CC=1 SCAR=0.0
Pod documented
661  
662 =item module_install_name
663  
664 Return the string representing the name for Module::Install. By default
665 this is C<inc::Module::Install>.
666  
667 =cut
668  
669 58 ▶sub module_install_name { 'inc::Module::Install' }
Subroutine module_install_name: called CC=1 SCAR=0.0
Pod documented
670  
671 =item module_install_dir
672  
673 Returns the directory that contains Module::Install. This is the distribution
674 directory because the module name is actually C<inc::Module::Install>.
675  
676 =cut
677  
678 1 ▶sub module_install_dir { $_[0]->dist_dir }
Subroutine module_install_dir: called CC=1 SCAR=0.0
Pod documented
679  
680 =item module_extractor_class
681  
682 The name of the module that can get a list of used modules from a Perl file.
683 By default this is Module::Extract::Use.
684  
685 =cut
686  
687 68 ▶sub module_extractor_class { 'Module::Extract::Use' }
Subroutine module_extractor_class: called CC=1 SCAR=0.0
Pod documented
688 13 ▶BEGIN { require Module::Extract::Use }
Subroutine BEGIN: called CC=1 SCAR=0.0
689  
690 =back
691  
692 =head1 TO DO
693  
694  
695 =head1 SEE ALSO
696  
697  
698 =head1 SOURCE AVAILABILITY
699  
700 This source is in Github:
701  
702 https://github.com/briandfoy/distribution-guess-buildsystem.git
703  
704 =head1 AUTHOR
705  
706 brian d foy, C<< <briandfoy@pobox.com> >>
707  
708 =head1 COPYRIGHT AND LICENSE
709  
710 Copyright © 2008-2025, brian d foy <briandfoy@pobox.com>. All rights reserved.
711  
712 You may redistribute this under the terms of the Artistic License 2.0.
713  
714 =cut
715  
716 13 1;
↑ Summary