line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Starter::BuilderSet; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
94489
|
use strict; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
87
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
90
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
15
|
use Carp qw( carp ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2343
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Module::Starter::BuilderSet - determine builder metadata |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
version 1.77 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '1.77'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Module::Starter::BuilderSet; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $builder_set = Module::Starter::BuilderSet->new; |
25
|
|
|
|
|
|
|
my @supported_builders = $builder_set->supported_builders(); |
26
|
|
|
|
|
|
|
my $default_builder = $builder_set->default_builder(); |
27
|
|
|
|
|
|
|
my $output_file = $builder_set->file_for_builder($default_builder); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $create_method = $builder_set->method_for_builder($default_builder); |
30
|
|
|
|
|
|
|
Module::Starter::Simple->$create_method($default_builder); # eeew. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my @build_commands = $builder_set->instructions_for_builder($default_builder); |
33
|
|
|
|
|
|
|
my @builder_dependencies = $builder_set->deps_for_builder($default_builder); |
34
|
|
|
|
|
|
|
my @compatible_builders = $builder_set->check_compatibility(@builder_list); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $ms_simple = Module::Starter::Simple->new(); |
37
|
|
|
|
|
|
|
my $build_method = $builder_set->manifest_method($builder); |
38
|
|
|
|
|
|
|
$ms_simple->$build_method(); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 DESCRIPTION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Module::Starter::BuilderSet is a collection of utility methods used to |
43
|
|
|
|
|
|
|
provide metadata about builders supported by Module::Starter. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 CLASS METHODS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 C<< new() >> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This method initializes and returns an object representing the set of |
50
|
|
|
|
|
|
|
Builders supported by Module::Starter |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub new { |
55
|
89
|
|
|
89
|
1
|
754
|
my $class = shift; |
56
|
|
|
|
|
|
|
|
57
|
89
|
|
|
|
|
1710
|
my $self = |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
'Module::Build' => |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
file => "Build.PL", |
62
|
|
|
|
|
|
|
build_method => "create_Build_PL", |
63
|
|
|
|
|
|
|
build_deps => [], |
64
|
|
|
|
|
|
|
build_manifest => 'create_MB_MANIFEST', |
65
|
|
|
|
|
|
|
instructions => [ 'perl Build.PL', |
66
|
|
|
|
|
|
|
'./Build', |
67
|
|
|
|
|
|
|
'./Build test', |
68
|
|
|
|
|
|
|
'./Build install', |
69
|
|
|
|
|
|
|
], |
70
|
|
|
|
|
|
|
}, |
71
|
|
|
|
|
|
|
'Module::Install' => |
72
|
|
|
|
|
|
|
{ |
73
|
|
|
|
|
|
|
file => "Makefile.PL", |
74
|
|
|
|
|
|
|
build_method => "create_MI_Makefile_PL", |
75
|
|
|
|
|
|
|
build_deps => [], |
76
|
|
|
|
|
|
|
build_manifest => 'create_MI_MANIFEST', |
77
|
|
|
|
|
|
|
instructions => [ 'perl Makefile.PL', |
78
|
|
|
|
|
|
|
'make', |
79
|
|
|
|
|
|
|
'make test', |
80
|
|
|
|
|
|
|
'make install', |
81
|
|
|
|
|
|
|
], |
82
|
|
|
|
|
|
|
}, |
83
|
|
|
|
|
|
|
'ExtUtils::MakeMaker' => |
84
|
|
|
|
|
|
|
{ |
85
|
|
|
|
|
|
|
file => "Makefile.PL", |
86
|
|
|
|
|
|
|
build_method => "create_Makefile_PL", |
87
|
|
|
|
|
|
|
build_manifest => 'create_EUMM_MANIFEST', |
88
|
|
|
|
|
|
|
build_deps => [ { command => 'make', |
89
|
|
|
|
|
|
|
aliases => [ 'make', 'gmake' ], |
90
|
|
|
|
|
|
|
}, |
91
|
|
|
|
|
|
|
{ command => 'chmod', |
92
|
|
|
|
|
|
|
aliases => [ 'chmod' ], |
93
|
|
|
|
|
|
|
}, |
94
|
|
|
|
|
|
|
], |
95
|
|
|
|
|
|
|
instructions => [ 'perl Makefile.PL', |
96
|
|
|
|
|
|
|
'make', |
97
|
|
|
|
|
|
|
'make test', |
98
|
|
|
|
|
|
|
'make install', |
99
|
|
|
|
|
|
|
], |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
|
103
|
89
|
|
|
|
|
340
|
return bless $self, $class; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _builder { |
107
|
347
|
|
|
347
|
|
477
|
my $self = shift; |
108
|
347
|
|
|
|
|
485
|
my $builder = shift; |
109
|
|
|
|
|
|
|
|
110
|
347
|
50
|
|
|
|
711
|
$builder = $self->default_builder unless $builder; |
111
|
|
|
|
|
|
|
|
112
|
347
|
100
|
|
|
|
732
|
unless (exists $self->{$builder}) { |
113
|
4
|
|
|
|
|
491
|
carp("Don't know anything about builder '$builder'."); |
114
|
4
|
|
|
|
|
270
|
return undef; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
343
|
|
|
|
|
1192
|
return $self->{$builder}; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 C<< supported_builders() >> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This method returns a list of builders supported by Module::Starter |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub supported_builders { |
127
|
5
|
|
|
5
|
1
|
2058
|
my $self = shift; |
128
|
|
|
|
|
|
|
|
129
|
5
|
|
|
|
|
22
|
return keys %$self; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 C<< file_for_builder($builder) >> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This method returns the name of the file generated by Module::Starter |
135
|
|
|
|
|
|
|
that will be used to build the generated module |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub file_for_builder { |
140
|
148
|
|
|
148
|
1
|
245
|
my $self = shift; |
141
|
148
|
|
|
|
|
219
|
my $builder = shift; |
142
|
|
|
|
|
|
|
|
143
|
148
|
|
|
|
|
329
|
return $self->_builder($builder)->{file}; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 C<< method_for_builder($builder) >> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This method returns the name of the method in the |
149
|
|
|
|
|
|
|
C package that is called to create the file |
150
|
|
|
|
|
|
|
returned by C |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub method_for_builder { |
155
|
47
|
|
|
47
|
1
|
103
|
my $self = shift; |
156
|
47
|
|
|
|
|
95
|
my $builder = shift; |
157
|
|
|
|
|
|
|
|
158
|
47
|
|
|
|
|
100
|
return $self->_builder($builder)->{build_method}; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 C<< instructions_for_builder($builder) >> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This method returns a list of commands that, when run from the command |
164
|
|
|
|
|
|
|
line (or with C), will cause the generated module to be |
165
|
|
|
|
|
|
|
built, tested and installed. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub instructions_for_builder { |
170
|
47
|
|
|
47
|
1
|
110
|
my $self = shift; |
171
|
47
|
|
|
|
|
114
|
my $builder = shift; |
172
|
|
|
|
|
|
|
|
173
|
47
|
|
|
|
|
98
|
return @{ $self->_builder($builder)->{instructions} }; |
|
47
|
|
|
|
|
101
|
|
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 C<< deps_for_builder($builder) >> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This method returns a list of dependencies in the following format: |
179
|
|
|
|
|
|
|
C<< |
180
|
|
|
|
|
|
|
( { command => "make", |
181
|
|
|
|
|
|
|
aliases => [ 'make', 'gmake' ], |
182
|
|
|
|
|
|
|
}, |
183
|
|
|
|
|
|
|
{ command => "another_command", |
184
|
|
|
|
|
|
|
aliases => [ 'alias0', 'alias1', '...' ], |
185
|
|
|
|
|
|
|
}, |
186
|
|
|
|
|
|
|
) |
187
|
|
|
|
|
|
|
>> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub deps_for_builder { |
192
|
3
|
|
|
3
|
1
|
11
|
my $self = shift; |
193
|
3
|
|
|
|
|
4
|
my $builder = shift; |
194
|
|
|
|
|
|
|
|
195
|
3
|
|
|
|
|
6
|
return @{ $self->_builder($builder)->{build_deps} }; |
|
3
|
|
|
|
|
5
|
|
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 C<< manifest_method($builder) >> |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This method returns the command to run to create the manifest according to the |
201
|
|
|
|
|
|
|
builder asked. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub manifest_method { |
206
|
44
|
|
|
44
|
1
|
181
|
my ( $self, $builder ) = @_; |
207
|
|
|
|
|
|
|
|
208
|
44
|
|
|
|
|
101
|
return $self->_builder($builder)->{'build_manifest'}; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head2 C<< check_compatibility(@builders) >> |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This method accepts a list of builders and filters out the ones that |
214
|
|
|
|
|
|
|
are unsupported or mutually exclusive, returning the builders that |
215
|
|
|
|
|
|
|
passed the filter. If none pass the filter, the default builder is |
216
|
|
|
|
|
|
|
returned. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub check_compatibility { |
221
|
51
|
|
|
51
|
1
|
693
|
my $self = shift; |
222
|
51
|
|
|
|
|
161
|
my @builders = @_; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# if we're passed an array reference (or even a list of array |
225
|
|
|
|
|
|
|
# references), de-reference the first one passed and assign |
226
|
|
|
|
|
|
|
# @builders its contents |
227
|
|
|
|
|
|
|
|
228
|
51
|
50
|
66
|
|
|
377
|
@builders = @{$builders[0]} if(@builders && ref $builders[0] eq 'ARRAY'); |
|
0
|
|
|
|
|
0
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
# remove empty and unsupported builders |
231
|
51
|
|
|
|
|
157
|
@builders = grep { $self->_builder($_) } @builders; |
|
58
|
|
|
|
|
164
|
|
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# if we stripped all of them, use the default |
234
|
51
|
100
|
|
|
|
184
|
push(@builders, $self->default_builder) unless int( @builders ) > 0; |
235
|
|
|
|
|
|
|
|
236
|
51
|
|
|
|
|
123
|
my %uniq; |
237
|
|
|
|
|
|
|
my @good; |
238
|
51
|
|
|
|
|
128
|
foreach my $builder (@builders) { |
239
|
|
|
|
|
|
|
# Builders that generate the same build file are mutually exclusive |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# If given a list of builder modules that includes mutually |
242
|
|
|
|
|
|
|
# exclusive modules, we'll use the first in the list |
243
|
|
|
|
|
|
|
|
244
|
57
|
|
|
|
|
224
|
my $file = $self->file_for_builder($builder); |
245
|
57
|
100
|
|
|
|
181
|
if (exists $uniq{$file}) { |
246
|
|
|
|
|
|
|
# don't print a warning if the same builder was listed twice. |
247
|
|
|
|
|
|
|
# Otherwise, inform the caller that these builders are mutually |
248
|
|
|
|
|
|
|
# exclusive |
249
|
|
|
|
|
|
|
carp("Builders '$builder' and '$uniq{$file}' are mutually exclusive.". |
250
|
|
|
|
|
|
|
" Using '$uniq{$file}'." |
251
|
4
|
100
|
|
|
|
235
|
) unless $builder eq $uniq{$file}; |
252
|
|
|
|
|
|
|
} else { |
253
|
53
|
|
|
|
|
160
|
$uniq{$file} = $builder; |
254
|
53
|
|
|
|
|
160
|
push(@good, $uniq{$file}); |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
51
|
|
|
|
|
359
|
return( @good ); |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head2 C<< default_builder() >> |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
This method returns the module name of the default builder. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=cut |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub default_builder { |
268
|
8
|
|
|
8
|
1
|
26
|
my $self = shift; |
269
|
|
|
|
|
|
|
|
270
|
8
|
|
|
|
|
42
|
return 'ExtUtils::MakeMaker'; |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head1 BUGS |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Please report any bugs or feature requests to the bugtracker for this project |
276
|
|
|
|
|
|
|
on GitHub at: L. I will be |
277
|
|
|
|
|
|
|
notified, and then you'll automatically be notified of progress on your bug |
278
|
|
|
|
|
|
|
as I make changes. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head1 AUTHOR |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
C.J. Adams-Collier, C<< >> |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head1 Copyright & License |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Copyright 2007 C.J. Adams-Collier, All Rights Reserved. |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
289
|
|
|
|
|
|
|
under the same terms as Perl itself. |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
Please note that these modules are not products of or supported by the |
292
|
|
|
|
|
|
|
employers of the various contributors to the code. |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=cut |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
1; |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
# vi:et:sw=4 ts=4 |