line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Prereq; |
2
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
47
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
62
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=encoding utf8 |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 The build file for Test::Prereq |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This build file is a modulino; it works as both a build script and |
10
|
|
|
|
|
|
|
a module. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
To build the distribution, run this file normally: |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
% perl Makefile.PL |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
But, it's more interesting than that. You can load it with C |
17
|
|
|
|
|
|
|
and call C to get the data structure it passes to |
18
|
|
|
|
|
|
|
C: |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $package = require '/path/to/Makefile.PL'; |
21
|
|
|
|
|
|
|
my $arguments = $package->arguments; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Note that C-ing a file makes an entry in C<%INC> for exactly |
24
|
|
|
|
|
|
|
that name. If you try to C another file with the same name, |
25
|
|
|
|
|
|
|
even from a different path, C thinks it has already loaded |
26
|
|
|
|
|
|
|
the file. As such, I recommend you always require the full path to the |
27
|
|
|
|
|
|
|
file. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The return value of the C is a package name (in this case, |
30
|
|
|
|
|
|
|
the name of the main module. Use that to call the C method. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Even if this distribution needs a higher version of Perl, this bit |
33
|
|
|
|
|
|
|
only needs v5.8. You can play with the data structure with a primitive |
34
|
|
|
|
|
|
|
Perl. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
2
|
|
856
|
use File::Spec::Functions qw(catfile); |
|
2
|
|
|
|
|
1075
|
|
|
2
|
|
|
|
|
680
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $module = __PACKAGE__; |
41
|
|
|
|
|
|
|
( my $dist = $module ) =~ s/::/-/g; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $github = 'https://github.com/briandfoy/test-prereq'; |
44
|
|
|
|
|
|
|
my $main_file = catfile( 'lib', split /::/, "$module.pm" ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my %WriteMakefile = ( |
47
|
|
|
|
|
|
|
'MIN_PERL_VERSION' => '5.022', |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
'NAME' => $module, |
50
|
|
|
|
|
|
|
'ABSTRACT_FROM' => $main_file, |
51
|
|
|
|
|
|
|
'VERSION_FROM' => $main_file, |
52
|
|
|
|
|
|
|
'LICENSE' => 'artistic2', |
53
|
|
|
|
|
|
|
'AUTHOR' => 'brian d foy ', |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
'CONFIGURE_REQUIRES' => { |
56
|
|
|
|
|
|
|
'ExtUtils::MakeMaker' => '6.64', |
57
|
|
|
|
|
|
|
'File::Spec::Functions' => '0', |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
'BUILD_REQUIRES' => { |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
'TEST_REQUIRES' => { |
64
|
|
|
|
|
|
|
'Test::Builder::Tester' => '0', |
65
|
|
|
|
|
|
|
'Test::More' => '0.95', |
66
|
|
|
|
|
|
|
}, |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
'PREREQ_PM' => { |
69
|
|
|
|
|
|
|
'Module::Extract::Use' => '0', |
70
|
|
|
|
|
|
|
'Carp' => '0', |
71
|
|
|
|
|
|
|
'Cwd' => '0', |
72
|
|
|
|
|
|
|
'File::Find' => '0', |
73
|
|
|
|
|
|
|
'Module::Build' => '0', |
74
|
|
|
|
|
|
|
'Test::Builder::Module' => '0', |
75
|
|
|
|
|
|
|
'feature' => '0', |
76
|
|
|
|
|
|
|
'lib' => '0', |
77
|
|
|
|
|
|
|
'parent' => '0', |
78
|
|
|
|
|
|
|
'strict' => '0', |
79
|
|
|
|
|
|
|
'utf8' => '0', |
80
|
|
|
|
|
|
|
'vars' => '0', |
81
|
|
|
|
|
|
|
'warnings' => '0', |
82
|
|
|
|
|
|
|
}, |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
'META_MERGE' => { |
85
|
|
|
|
|
|
|
'meta-spec' => { version => 2 }, |
86
|
|
|
|
|
|
|
resources => { |
87
|
|
|
|
|
|
|
repository => { |
88
|
|
|
|
|
|
|
type => 'git', |
89
|
|
|
|
|
|
|
url => "$github.git", |
90
|
|
|
|
|
|
|
web => $github, |
91
|
|
|
|
|
|
|
}, |
92
|
|
|
|
|
|
|
bugtracker => { |
93
|
|
|
|
|
|
|
web => "$github/issues", |
94
|
|
|
|
|
|
|
}, |
95
|
|
|
|
|
|
|
homepage => $github, |
96
|
|
|
|
|
|
|
}, |
97
|
|
|
|
|
|
|
}, |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
'NORECURS' => 1, |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
'clean' => { FILES => "$dist-*" }, |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
2
|
0
|
4
|
sub arguments { \%WriteMakefile } |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Normally I'd just bail out if there is a caller, but this particular |
107
|
|
|
|
|
|
|
# module loads the file then expects to run WriteMakefile(). If |
108
|
|
|
|
|
|
|
my @caller = caller(1); |
109
|
|
|
|
|
|
|
do_it() unless( caller and $caller[3] !~ /::_get_prereqs\z/ ); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub do_it { |
112
|
2
|
|
|
2
|
0
|
8
|
require File::Spec; |
113
|
2
|
|
|
|
|
2
|
my $MM ='ExtUtils::MakeMaker'; |
114
|
|
|
|
|
|
|
my $MM_version = |
115
|
2
|
|
33
|
|
|
2
|
eval{ "$MM " . $WriteMakefile{'CONFIGURE_REQUIRES'}{'ExtUtils::MakeMaker'} } |
116
|
|
|
|
|
|
|
|| |
117
|
|
|
|
|
|
|
"$MM 6.64"; |
118
|
2
|
50
|
|
2
|
|
7
|
eval "use $MM_version; 1" or die "Could not load $MM_version: $@"; |
|
2
|
|
|
|
|
49
|
|
|
2
|
|
|
|
|
188
|
|
|
2
|
|
|
|
|
95
|
|
119
|
2
|
50
|
|
2
|
|
317
|
eval "use Test::Manifest 1.21" |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
122
|
|
120
|
|
|
|
|
|
|
if -e File::Spec->catfile( qw(t test_manifest) ); |
121
|
|
|
|
|
|
|
|
122
|
2
|
|
|
|
|
5
|
my $arguments = arguments(); |
123
|
2
|
|
50
|
|
|
7
|
my $minimum_perl = $arguments->{MIN_PERL_VERSION} || '5.008'; |
124
|
2
|
50
|
|
|
|
57
|
eval "require $minimum_perl;" or die $@; |
125
|
|
|
|
|
|
|
|
126
|
2
|
|
|
|
|
15
|
WriteMakefile( %$arguments ); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
2
|
|
|
2
|
|
8
|
no warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
97
|
|
130
|
|
|
|
|
|
|
__PACKAGE__; |