line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
12
|
|
|
12
|
|
14789
|
use v5.10; |
|
12
|
|
|
|
|
48
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Distribution::Guess::BuildSystem; |
4
|
12
|
|
|
12
|
|
72
|
use strict; |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
317
|
|
5
|
|
|
|
|
|
|
|
6
|
12
|
|
|
12
|
|
65
|
use warnings; |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
471
|
|
7
|
12
|
|
|
12
|
|
72
|
no warnings; |
|
12
|
|
|
|
|
42
|
|
|
12
|
|
|
|
|
614
|
|
8
|
|
|
|
|
|
|
|
9
|
12
|
|
|
12
|
|
71
|
use Carp qw(carp); |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
783
|
|
10
|
12
|
|
|
12
|
|
79
|
use Config qw(%Config); |
|
12
|
|
|
|
|
27
|
|
|
12
|
|
|
|
|
570
|
|
11
|
12
|
|
|
12
|
|
84
|
use Cwd qw(cwd); |
|
12
|
|
|
|
|
49
|
|
|
12
|
|
|
|
|
772
|
|
12
|
12
|
|
|
12
|
|
5623
|
use File::Spec::Functions qw(catfile); |
|
12
|
|
|
|
|
8858
|
|
|
12
|
|
|
|
|
741
|
|
13
|
|
|
|
|
|
|
|
14
|
12
|
|
|
12
|
|
6010
|
use Module::Extract::VERSION; |
|
12
|
|
|
|
|
26461
|
|
|
12
|
|
|
|
|
25583
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '1.003'; |
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 and C. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item * Module::Build |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Uses F and C, although it might have a F that is |
66
|
|
|
|
|
|
|
a wrapper. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * Module::Install |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Uses F and calls to an embedded C. It might |
71
|
|
|
|
|
|
|
use C to call C 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
|
|
|
|
|
|
|
sub new { |
105
|
17
|
|
|
17
|
1
|
72366
|
my %defaults = ( |
106
|
|
|
|
|
|
|
dist_dir => cwd(), |
107
|
|
|
|
|
|
|
prefer_module_build => 1, |
108
|
|
|
|
|
|
|
prefer_makemaker => 0, |
109
|
|
|
|
|
|
|
perl_binary => $^X, |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
|
112
|
17
|
|
|
|
|
548
|
my( $class, %args ) = @_; |
113
|
|
|
|
|
|
|
|
114
|
17
|
|
|
|
|
936
|
bless { %defaults, %args }, $class; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item dist_dir( [ DIR ] ) |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Returns or sets the distribution directory. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub dist_dir { |
124
|
581
|
|
|
581
|
1
|
1157
|
my( $self ) = shift; |
125
|
581
|
|
|
|
|
1374
|
$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
|
|
|
|
|
|
|
sub perl_binary { |
137
|
4
|
|
|
4
|
1
|
11
|
my( $self ) = shift; |
138
|
4
|
|
|
|
|
19
|
$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 and C are true, then |
147
|
|
|
|
|
|
|
MakeMaker wins. |
148
|
|
|
|
|
|
|
=cut |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub prefer_makemaker { |
151
|
8
|
|
|
8
|
1
|
24
|
my( $self ) = shift; |
152
|
8
|
|
|
|
|
27
|
$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 and C are true, then |
161
|
|
|
|
|
|
|
MakeMaker wins. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub prefer_module_build { |
166
|
17
|
|
|
17
|
1
|
45
|
my( $self ) = shift; |
167
|
17
|
|
|
|
|
44
|
$self->_setting( 'prefer_module_build', @_ ); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub _setting { |
171
|
613
|
|
|
613
|
|
1388
|
my( $self, $key, $value ) = @_; |
172
|
|
|
|
|
|
|
|
173
|
613
|
100
|
|
|
|
1621
|
if( @_ == 3 ) { |
174
|
3
|
|
|
|
|
10
|
$self->{$key} = $value; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
613
|
|
|
|
|
5670
|
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
|
|
|
|
|
|
|
my @files = ( |
195
|
|
|
|
|
|
|
[ qw( has_makefile_pl makefile_pl ) ], |
196
|
|
|
|
|
|
|
[ qw( has_build_pl build_pl ) ], |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
); |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub build_files { |
201
|
20
|
|
|
20
|
1
|
12284
|
my %found; |
202
|
|
|
|
|
|
|
|
203
|
20
|
|
|
|
|
143
|
foreach my $pairs ( @files ) { |
204
|
40
|
|
|
|
|
220
|
my( $check, $file ) = @$pairs; |
205
|
40
|
100
|
|
|
|
253
|
$found{ $_[0]->$file() } = $_[0]->$file() if $_[0]->$check() |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
20
|
|
|
|
|
146
|
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 or |
220
|
|
|
|
|
|
|
C, use that. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
3. If there is no preference (both are false), prefer C. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
4. If no of those work, return nothing. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=cut |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub preferred_build_file { |
229
|
|
|
|
|
|
|
# preference doesn't matter in single build system cases |
230
|
32
|
100
|
|
32
|
1
|
6317
|
return $_[0]->makefile_pl if $_[0]->uses_makemaker_only; |
231
|
19
|
100
|
|
|
|
78
|
return $_[0]->build_pl if $_[0]->uses_module_build_only; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# preference now matter |
234
|
13
|
100
|
100
|
|
|
51
|
return $_[0]->build_pl if( |
235
|
|
|
|
|
|
|
$_[0]->prefer_module_build and $_[0]->uses_module_build ); |
236
|
8
|
100
|
100
|
|
|
30
|
return $_[0]->makefile_pl if( |
237
|
|
|
|
|
|
|
$_[0]->prefer_makemaker and $_[0]->uses_makemaker ); |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# absence of preference |
240
|
6
|
100
|
|
|
|
23
|
return $_[0]->build_pl if $_[0]->uses_module_build; |
241
|
5
|
100
|
|
|
|
28
|
return $_[0]->makefile_pl if $_[0]->uses_makemaker; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
# no build system? |
244
|
2
|
|
|
|
|
11
|
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. It returns the result of either C |
251
|
|
|
|
|
|
|
or C. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=cut |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub preferred_build_command { |
256
|
17
|
100
|
|
17
|
1
|
112
|
return $_[0]->build_command if $_[0]->preferred_build_file eq $_[0]->build_pl; |
257
|
8
|
100
|
|
|
|
29
|
return $_[0]->make_command if $_[0]->preferred_build_file eq $_[0]->makefile_pl; |
258
|
1
|
|
|
|
|
11
|
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 and the return value of |
265
|
|
|
|
|
|
|
C. The keys are the file names and the values are |
266
|
|
|
|
|
|
|
the paths. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=cut |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
sub build_file_paths { |
271
|
10
|
|
|
10
|
1
|
16465
|
my %paths; |
272
|
|
|
|
|
|
|
|
273
|
10
|
|
|
|
|
38
|
foreach my $file ( keys %{ $_[0]->build_files } ) { |
|
10
|
|
|
|
|
60
|
|
274
|
12
|
|
|
|
|
66
|
$paths{$file} = File::Spec->catfile( $_[0]->dist_dir, $file ); |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
|
277
|
10
|
|
|
|
|
53
|
return \%paths; |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=item makefile_pl_path |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=cut |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
sub makefile_pl_path { |
285
|
59
|
100
|
|
59
|
1
|
48491
|
return unless $_[0]->has_makefile_pl; |
286
|
|
|
|
|
|
|
|
287
|
58
|
|
|
|
|
227
|
File::Spec->catfile( $_[0]->dist_dir, $_[0]->makefile_pl ); |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=item build_pl_path |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=cut |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
sub build_pl_path { |
295
|
37
|
100
|
|
37
|
1
|
684
|
return unless $_[0]->has_build_pl; |
296
|
|
|
|
|
|
|
|
297
|
34
|
|
|
|
|
128
|
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. |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=cut |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
sub _has_file { |
307
|
473
|
|
|
473
|
|
1049
|
my( $self, $file ) = @_; |
308
|
|
|
|
|
|
|
|
309
|
473
|
|
|
|
|
1232
|
my $path = File::Spec->catfile( |
310
|
|
|
|
|
|
|
$self->dist_dir, $file |
311
|
|
|
|
|
|
|
); |
312
|
|
|
|
|
|
|
|
313
|
473
|
100
|
|
|
|
8876
|
$self->{has}{$file} = $path if -e $path; |
314
|
473
|
|
|
|
|
4879
|
$self->{has}{$file}; |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
217
|
|
|
217
|
1
|
9357
|
sub has_build_pl { $_[0]->_has_file( $_[0]->build_pl ) } |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=item has_makefile_pl |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
Has the file name returned by C. |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=cut |
324
|
|
|
|
|
|
|
|
325
|
256
|
|
|
256
|
1
|
6434
|
sub has_makefile_pl { $_[0]->_has_file( $_[0]->makefile_pl ) } |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=item has_build_and_makefile |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
Has both the files returned by C and C. |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=cut |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub has_build_and_makefile { |
334
|
10
|
100
|
|
10
|
1
|
2900
|
$_[0]->has_build_pl |
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 variant to build the distribution. |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
=cut |
345
|
|
|
|
|
|
|
|
346
|
29
|
100
|
|
29
|
1
|
2100
|
sub make_command { $_[0]->has_makefile_pl ? $Config{make} : () } |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
=item build_command |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
Returns C<./Build>, the script that F should have created, if |
351
|
|
|
|
|
|
|
the distribution has a F. Otherwise it returns nothing. |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=cut |
354
|
|
|
|
|
|
|
|
355
|
18
|
50
|
|
18
|
1
|
65
|
sub build_command { $_[0]->has_build_pl ? './Build' : () } |
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 or F. |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
=cut |
363
|
|
|
|
|
|
|
|
364
|
7
|
100
|
|
7
|
1
|
26
|
sub perl_command { $_[0]->has_build_pl ? $_[0]->perl_binary : () } |
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 or C. |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=cut |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
sub build_commands { |
375
|
10
|
|
|
10
|
1
|
1131
|
my %commands; |
376
|
|
|
|
|
|
|
|
377
|
10
|
100
|
|
|
|
41
|
$commands{ $_[0]->make_command } = 1 |
378
|
|
|
|
|
|
|
if $_[0]->has_makefile_pl; |
379
|
|
|
|
|
|
|
|
380
|
10
|
100
|
|
|
|
53
|
$commands{ $_[0]->perl_command . " " . $_[0]->build_pl } = 1 |
381
|
|
|
|
|
|
|
if $_[0]->has_build_pl; |
382
|
|
|
|
|
|
|
|
383
|
10
|
|
|
|
|
88
|
return \%commands; |
384
|
|
|
|
|
|
|
} |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
=item uses_makemaker |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
Returns true if the distro uses C. |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
=cut |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
sub _get_modules { |
393
|
68
|
|
|
68
|
|
237
|
my( $self, $path ) = @_; |
394
|
68
|
|
|
|
|
278
|
my $extractor = $self->module_extractor_class->new; |
395
|
68
|
|
|
|
|
1409
|
$extractor->get_modules( $path ); |
396
|
|
|
|
|
|
|
} |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
sub uses_makemaker { |
399
|
30
|
100
|
|
30
|
1
|
51800
|
return unless $_[0]->has_makefile_pl; |
400
|
|
|
|
|
|
|
|
401
|
22
|
|
|
|
|
114
|
scalar grep { $_ eq $_[0]->makemaker_name } |
|
46
|
|
|
|
|
876913
|
|
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
|
|
|
|
|
|
|
sub uses_makemaker_only { |
414
|
36
|
100
|
|
36
|
1
|
783
|
return unless $_[0]->has_makefile_pl; |
415
|
27
|
100
|
|
|
|
104
|
return if $_[0]->has_build_pl; |
416
|
|
|
|
|
|
|
|
417
|
15
|
|
|
|
|
89
|
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
|
|
|
|
|
|
|
sub makemaker_version { |
427
|
5
|
100
|
|
5
|
1
|
595
|
return unless $_[0]->uses_makemaker; |
428
|
|
|
|
|
|
|
|
429
|
1
|
|
|
|
|
4
|
my $version = $_[0]->_get_version( $_[0]->makemaker_name ); |
430
|
|
|
|
|
|
|
} |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
sub _get_version { |
433
|
3
|
|
|
3
|
|
59
|
require Module::Extract::VERSION; |
434
|
|
|
|
|
|
|
|
435
|
3
|
|
|
|
|
18
|
my( $self, $module, @dirs ) = @_; |
436
|
|
|
|
|
|
|
|
437
|
3
|
100
|
|
|
|
53
|
@dirs = @INC unless @dirs; |
438
|
|
|
|
|
|
|
|
439
|
3
|
|
|
|
|
36
|
my $file = catfile( split /::/, $module ) . ".pm"; |
440
|
|
|
|
|
|
|
|
441
|
3
|
|
|
|
|
10
|
my $found_module = 0; |
442
|
3
|
|
|
|
|
21
|
foreach my $dir ( @dirs ) { |
443
|
19
|
|
|
|
|
103
|
my $module = catfile( $dir, $file ); |
444
|
19
|
100
|
|
|
|
350
|
next unless -e $module; |
445
|
|
|
|
|
|
|
|
446
|
3
|
|
|
|
|
13
|
$found_module = 1; |
447
|
3
|
|
|
|
|
38
|
return Module::Extract::VERSION->parse_version_safely( $module ); |
448
|
|
|
|
|
|
|
} |
449
|
|
|
|
|
|
|
|
450
|
0
|
0
|
|
|
|
0
|
return '$module not installed' unless $found_module; |
451
|
0
|
|
|
|
|
0
|
return; |
452
|
|
|
|
|
|
|
} |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
=item uses_module_build |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
Returns true if this distribution uses C. This means that it |
457
|
|
|
|
|
|
|
has a F and that the F actually uses C. |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
=cut |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
sub uses_module_build { |
462
|
37
|
100
|
|
37
|
1
|
1251
|
return unless $_[0]->has_build_pl; |
463
|
|
|
|
|
|
|
|
464
|
25
|
|
|
|
|
141
|
scalar grep { $_ eq $_[0]->module_build_name } |
|
25
|
|
|
|
|
708351
|
|
465
|
|
|
|
|
|
|
$_[0]->_get_modules( $_[0]->build_pl_path ); |
466
|
|
|
|
|
|
|
} |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
=item uses_module_build_only |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
Returns true if C 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
|
|
|
|
|
|
|
sub uses_module_build_only { |
477
|
25
|
100
|
|
25
|
1
|
49011
|
return unless $_[0]->has_build_pl; |
478
|
22
|
100
|
|
|
|
77
|
return if $_[0]->has_makefile_pl; |
479
|
|
|
|
|
|
|
|
480
|
9
|
|
|
|
|
48
|
return 1; |
481
|
|
|
|
|
|
|
} |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
=item module_build_version |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
Returns the version of C install for perl running this code. |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
=cut |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
sub module_build_version { |
490
|
5
|
100
|
|
5
|
1
|
891
|
return unless $_[0]->uses_module_build; |
491
|
|
|
|
|
|
|
|
492
|
1
|
|
|
|
|
4
|
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. |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
=cut |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
sub uses_module_install { |
502
|
24
|
100
|
|
24
|
1
|
2376
|
return unless $_[0]->has_makefile_pl; |
503
|
|
|
|
|
|
|
|
504
|
21
|
|
|
|
|
120
|
scalar grep { $_ eq $_[0]->module_install_name } |
|
57
|
|
|
|
|
1022701
|
|
505
|
|
|
|
|
|
|
$_[0]->_get_modules( $_[0]->makefile_pl_path ) |
506
|
|
|
|
|
|
|
} |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
=item uses_auto_install |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
Returns true if this distribution uses C 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 in the build file, it returns true. |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
=cut |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
sub uses_auto_install { |
519
|
10
|
100
|
100
|
10
|
1
|
2443
|
return unless $_[0]->has_makefile_pl && $_[0]->uses_module_install; |
520
|
|
|
|
|
|
|
|
521
|
2
|
|
|
|
|
12
|
$_[0]->_file_has_string( $_[0]->makefile_pl_path, 'auto_install' ); |
522
|
|
|
|
|
|
|
} |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=item module_install_version |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
Returns the version of C. |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
=cut |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
sub module_install_version { |
531
|
6
|
100
|
|
6
|
1
|
1134
|
return unless $_[0]->uses_module_install; |
532
|
|
|
|
|
|
|
|
533
|
1
|
|
|
|
|
5
|
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 and will |
541
|
|
|
|
|
|
|
use the C feature. |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
This is a very simple test right now. If it finds the string |
544
|
|
|
|
|
|
|
C in the build file, it returns true. |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
=cut |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
sub uses_module_build_compat { |
549
|
10
|
100
|
100
|
10
|
1
|
3769
|
return unless $_[0]->has_build_pl && $_[0]->uses_module_build; |
550
|
|
|
|
|
|
|
|
551
|
3
|
|
|
|
|
25
|
$_[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 is a wrapper around C. |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
=cut |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
sub build_pl_wraps_makefile_pl { |
561
|
5
|
100
|
100
|
5
|
1
|
594
|
return unless $_[0]->has_build_pl && $_[0]->has_makefile_pl; |
562
|
|
|
|
|
|
|
|
563
|
1
|
|
|
|
|
6
|
$_[0]->_file_has_string( $_[0]->build_pl_path, |
564
|
|
|
|
|
|
|
"Makefile.PL" ); |
565
|
|
|
|
|
|
|
} |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
sub _file_has_string { |
568
|
13
|
|
|
13
|
|
6102
|
my $fh; |
569
|
13
|
100
|
|
|
|
582
|
unless( open $fh, "<", $_[1] ) { |
570
|
1
|
|
|
|
|
252
|
carp "Could not open $_[1]: $!"; |
571
|
1
|
|
|
|
|
10
|
return; |
572
|
|
|
|
|
|
|
} |
573
|
|
|
|
|
|
|
|
574
|
12
|
100
|
|
|
|
339
|
while( <$fh> ) { return 1 if /\Q$_[2]/ } |
|
128
|
|
|
|
|
834
|
|
575
|
|
|
|
|
|
|
|
576
|
6
|
|
|
|
|
115
|
return; |
577
|
|
|
|
|
|
|
} |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=item just_give_me_a_hash |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
=cut |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
{ |
584
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub just_give_me_a_hash { |
608
|
3
|
|
|
3
|
1
|
5256
|
my %hash = (); |
609
|
|
|
|
|
|
|
|
610
|
3
|
|
|
|
|
19
|
foreach my $method ( @methods ) { |
611
|
60
|
|
|
|
|
310
|
$hash{ $method } = $_[0]->$method(); |
612
|
|
|
|
|
|
|
} |
613
|
|
|
|
|
|
|
|
614
|
3
|
|
|
|
|
20
|
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
|
|
|
385
|
1
|
6624
|
sub makefile_pl { 'Makefile.PL' } |
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
|
|
|
308
|
1
|
3215
|
sub build_pl { 'Build.PL' } |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
=item makemaker_name |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
Returns the module name of Makemaker, which is C. |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
=cut |
651
|
|
|
|
|
|
|
|
652
|
47
|
|
|
47
|
1
|
389
|
sub makemaker_name { 'ExtUtils::MakeMaker' } |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
=item module_build_name |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
Return the string representing the name for Module::Build. |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
=cut |
659
|
|
|
|
|
|
|
|
660
|
26
|
|
|
26
|
1
|
359
|
sub module_build_name { 'Module::Build' } |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
=item module_install_name |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
Return the string representing the name for Module::Install. By default |
665
|
|
|
|
|
|
|
this is C. |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
=cut |
668
|
|
|
|
|
|
|
|
669
|
58
|
|
|
58
|
1
|
327
|
sub module_install_name { 'inc::Module::Install' } |
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. |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
=cut |
677
|
|
|
|
|
|
|
|
678
|
1
|
|
|
1
|
1
|
4
|
sub module_install_dir { $_[0]->dist_dir } |
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
|
|
|
68
|
1
|
682
|
sub module_extractor_class { 'Module::Extract::Use' } |
688
|
12
|
|
|
12
|
|
6120
|
BEGIN { require Module::Extract::Use } |
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<< >> |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
Copyright © 2008-2021, brian d foy . All rights reserved. |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
You may redistribute this under the terms of the Artistic License 2.0. |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
=cut |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
1; |