line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::ModuleBuildTiny; |
2
|
|
|
|
|
|
|
$Dist::Zilla::Plugin::ModuleBuildTiny::VERSION = '0.014'; |
3
|
4
|
|
|
4
|
|
2524089
|
use Moose; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
47
|
|
4
|
|
|
|
|
|
|
with qw/ |
5
|
|
|
|
|
|
|
Dist::Zilla::Role::BuildPL |
6
|
|
|
|
|
|
|
Dist::Zilla::Role::TextTemplate |
7
|
|
|
|
|
|
|
Dist::Zilla::Role::PrereqSource |
8
|
|
|
|
|
|
|
Dist::Zilla::Role::FileGatherer |
9
|
|
|
|
|
|
|
Dist::Zilla::Role::MetaProvider |
10
|
|
|
|
|
|
|
/; |
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
25387
|
use Dist::Zilla 4.300039; |
|
4
|
|
|
|
|
145
|
|
|
4
|
|
|
|
|
133
|
|
13
|
4
|
|
|
4
|
|
1643
|
use Module::Metadata; |
|
4
|
|
|
|
|
11900
|
|
|
4
|
|
|
|
|
151
|
|
14
|
4
|
|
|
4
|
|
26
|
use Moose::Util::TypeConstraints 'enum'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
43
|
|
15
|
4
|
|
|
4
|
|
1789
|
use MooseX::Types::Perl qw/StrictVersionStr/; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
51
|
|
16
|
4
|
|
|
4
|
|
11912
|
use List::Util 1.33 qw/first any/; |
|
4
|
|
|
|
|
124
|
|
|
4
|
|
|
|
|
4064
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has version_method => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => enum(['installed', 'conservative']), |
21
|
|
|
|
|
|
|
default => 'conservative', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has has_pl => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
isa => 'Bool', |
27
|
|
|
|
|
|
|
lazy => 1, |
28
|
|
|
|
|
|
|
default => sub { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
return any { $_->name =~ /^lib\/.*\.PL$/ } @{ $self->zilla->files }; |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has has_xs => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => 'Bool', |
37
|
|
|
|
|
|
|
lazy => 1, |
38
|
|
|
|
|
|
|
default => sub { |
39
|
|
|
|
|
|
|
my $self = shift; |
40
|
|
|
|
|
|
|
return any { $_->name =~ /^lib\/.*\.xs$/ } @{ $self->zilla->files }; |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has static => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
isa => enum([qw/no yes auto/]), |
47
|
|
|
|
|
|
|
default => 'no', |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has version => ( |
51
|
|
|
|
|
|
|
is => 'ro', |
52
|
|
|
|
|
|
|
lazy => 1, |
53
|
|
|
|
|
|
|
isa => StrictVersionStr, |
54
|
|
|
|
|
|
|
default => sub { |
55
|
|
|
|
|
|
|
my $self = shift; |
56
|
|
|
|
|
|
|
if ($self->version_method eq 'installed') { |
57
|
|
|
|
|
|
|
return Module::Metadata->new_from_module('Module::Build::Tiny')->version->stringify; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
elsif ($self->has_pl) { |
60
|
|
|
|
|
|
|
return '0.039'; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif ($self->has_xs) { |
63
|
|
|
|
|
|
|
return '0.036'; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
return '0.034'; # _build_params format |
66
|
|
|
|
|
|
|
}, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has minimum_perl => ( |
70
|
|
|
|
|
|
|
is => 'ro', |
71
|
|
|
|
|
|
|
isa => StrictVersionStr, |
72
|
|
|
|
|
|
|
lazy => 1, |
73
|
|
|
|
|
|
|
default => sub { |
74
|
|
|
|
|
|
|
my $self = shift; |
75
|
|
|
|
|
|
|
my $prereqs = $self->zilla->prereqs->cpan_meta_prereqs; |
76
|
|
|
|
|
|
|
my $reqs = $prereqs->merged_requirements([ qw/configure build test runtime/ ], ['requires']); |
77
|
|
|
|
|
|
|
return $reqs->requirements_for_module('perl') || '5.006'; |
78
|
|
|
|
|
|
|
}, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $template = <<'BUILD_PL'; |
82
|
|
|
|
|
|
|
# This Build.PL for {{ $dist_name }} was generated by {{ $plugin_title }}. |
83
|
|
|
|
|
|
|
use strict; |
84
|
|
|
|
|
|
|
use warnings; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
use {{ $minimum_perl }}; |
87
|
|
|
|
|
|
|
use Module::Build::Tiny{{ $version ne 0 && " $version" }}; |
88
|
|
|
|
|
|
|
Build_PL(); |
89
|
|
|
|
|
|
|
BUILD_PL |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub register_prereqs { |
92
|
7
|
|
|
7
|
0
|
42084
|
my ($self) = @_; |
93
|
|
|
|
|
|
|
|
94
|
7
|
|
|
|
|
386
|
$self->zilla->register_prereqs({ phase => 'configure' }, 'Module::Build::Tiny' => $self->version); |
95
|
|
|
|
|
|
|
|
96
|
7
|
|
|
|
|
4420
|
return; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub can_static { |
100
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
101
|
3
|
|
33
|
|
|
157
|
return !$self->has_pl && !$self->has_xs; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub metadata { |
105
|
7
|
|
|
7
|
0
|
84239
|
my $self = shift; |
106
|
7
|
|
33
|
|
|
413
|
my $static = $self->static eq 'yes' || $self->static eq 'auto' && $self->can_static; |
107
|
7
|
100
|
|
|
|
80
|
return $static ? { x_static_install => 1 } : (); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub gather_files { |
111
|
7
|
|
|
7
|
0
|
952823
|
my ($self) = @_; |
112
|
|
|
|
|
|
|
|
113
|
7
|
50
|
|
4
|
|
42
|
if (my $file = first { $_->name eq 'Build.PL' } @{$self->zilla->files}) |
|
4
|
|
|
|
|
177
|
|
|
7
|
|
|
|
|
301
|
|
114
|
|
|
|
|
|
|
{ |
115
|
|
|
|
|
|
|
# if it's another type, some other plugin added it, so it's better to |
116
|
|
|
|
|
|
|
# error out and let the developer sort out what went wrong. |
117
|
0
|
0
|
|
|
|
0
|
if ($file->isa('Dist::Zilla::File::OnDisk')) |
118
|
|
|
|
|
|
|
{ |
119
|
0
|
|
|
|
|
0
|
$self->log('replacing existing Build.PL found in repository'); |
120
|
0
|
|
|
|
|
0
|
$self->zilla->prune_file($file); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
7
|
|
|
|
|
5689
|
require Dist::Zilla::File::InMemory; |
125
|
7
|
|
|
|
|
373079
|
my $file = Dist::Zilla::File::InMemory->new({ |
126
|
|
|
|
|
|
|
name => 'Build.PL', |
127
|
|
|
|
|
|
|
content => $template, # template evaluated later |
128
|
|
|
|
|
|
|
}); |
129
|
|
|
|
|
|
|
|
130
|
7
|
|
|
|
|
2304
|
$self->add_file($file); |
131
|
7
|
|
|
|
|
3037
|
return; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub setup_installer { |
135
|
7
|
|
|
7
|
0
|
92485
|
my ($self, $arg) = @_; |
136
|
|
|
|
|
|
|
|
137
|
7
|
50
|
|
|
|
326
|
confess 'Module::Build::Tiny is currently incompatible with dynamic_config' if $self->zilla->distmeta->{dynamic_config}; |
138
|
|
|
|
|
|
|
|
139
|
7
|
|
|
|
|
376
|
for my $map (map { $_->share_dir_map } @{$self->zilla->plugins_with(-ShareDir)}) { |
|
2
|
|
|
|
|
1221
|
|
|
7
|
|
|
|
|
282
|
|
140
|
2
|
100
|
|
|
|
475
|
$self->log_fatal('Unsupported use of a module sharedir') if exists $map->{module}; |
141
|
1
|
50
|
33
|
|
|
21
|
$self->log_fatal('Sharedir location must be share/') if defined $map->{dist} and $map->{dist} ne 'share'; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
5
|
|
|
5
|
|
2446
|
my $file = first { $_->name eq 'Build.PL' } @{$self->zilla->files}; |
|
5
|
|
|
|
|
261
|
|
|
5
|
|
|
|
|
220
|
|
145
|
5
|
|
|
|
|
343
|
my $content = $file->content; |
146
|
|
|
|
|
|
|
|
147
|
5
|
|
50
|
|
|
680
|
$content = $self->fill_in_string($content, { |
148
|
|
|
|
|
|
|
version => $self->version, |
149
|
|
|
|
|
|
|
minimum_perl => $self->minimum_perl, |
150
|
|
|
|
|
|
|
dist_name => $self->zilla->name, |
151
|
|
|
|
|
|
|
plugin_title => ref($self) . ' ' . ($self->VERSION || '<self>'), |
152
|
|
|
|
|
|
|
}); |
153
|
|
|
|
|
|
|
|
154
|
5
|
|
|
|
|
6190
|
$self->log_debug([ 'updating contents of Build.PL in memory' ]); |
155
|
5
|
|
|
|
|
1024
|
$file->content($content); |
156
|
|
|
|
|
|
|
|
157
|
5
|
|
|
|
|
1409
|
return; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
161
|
4
|
|
|
4
|
|
27
|
no Moose::Util::TypeConstraints; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
26
|
|
162
|
4
|
|
|
4
|
|
572
|
no Moose; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
26
|
|
163
|
|
|
|
|
|
|
1; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# ABSTRACT: Build a Build.PL that uses Module::Build::Tiny |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# vim: set ts=4 sw=4 noet nolist : |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
__END__ |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=pod |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=encoding UTF-8 |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 NAME |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Dist::Zilla::Plugin::ModuleBuildTiny - Build a Build.PL that uses Module::Build::Tiny |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 VERSION |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
version 0.014 |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 DESCRIPTION |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This plugin will create a F<Build.PL> for installing the dist using L<Module::Build::Tiny|Module::Build::Tiny>. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head2 version |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
B<Optional:> Specify the minimum version of L<Module::Build::Tiny|Module::Build::Tiny> to depend on. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Defaults to the version determined by C<version_method>. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 version_method |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This attribute determines how the default minimum perl is detected. It has two possible values: |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=over 4 |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item * installed |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This will give the version installed on the author's perl installation. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item * conservative |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
This will return a heuristically determined minimum version of MBT. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=back |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 minimum_perl |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
B<Optional:> Specify the minimum version of perl to require in the F<Build.PL>. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
This is normally taken from dzil's prereq metadata. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head2 static |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
This is an option to set the B<HIGHLY EXPERIMENTAL> C<x_static_install> |
221
|
|
|
|
|
|
|
metadata field. B<DO NOT USE THIS OPTION> if you are not involved in its |
222
|
|
|
|
|
|
|
testing with the Perl Toolchain Gang. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
It has three possible values: |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=over 4 |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item * no |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
No extra metadata is added. This is the default setting. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * yes |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Sets C<x_static_install = 1> in metadata. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item * auto |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Sets C<x_static_install = 1> in metadata if the distribution appears to be |
239
|
|
|
|
|
|
|
compatible - presently only the existence of F<.PL> and F<.xs> files are |
240
|
|
|
|
|
|
|
checked. |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=back |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head1 AUTHOR |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Leon Timmermans <fawaka@gmail.com> |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Leon Timmermans. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
253
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |