line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::MakeMaker::Awesome; # git description: v0.47-10-gbdb5d98 |
2
|
|
|
|
|
|
|
# ABSTRACT: A more awesome MakeMaker plugin for L<Dist::Zilla> |
3
|
|
|
|
|
|
|
# KEYWORDS: plugin installer MakeMaker Makefile.PL toolchain customize override |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.48'; |
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
27109150
|
use Moose; |
|
11
|
|
|
|
|
460590
|
|
|
11
|
|
|
|
|
93
|
|
8
|
11
|
|
|
11
|
|
73453
|
use MooseX::Types::Moose qw< Str ArrayRef HashRef >; |
|
11
|
|
|
|
|
127609
|
|
|
11
|
|
|
|
|
133
|
|
9
|
11
|
|
|
11
|
|
60377
|
use MooseX::Types::Stringlike 'Stringlike'; |
|
11
|
|
|
|
|
456987
|
|
|
11
|
|
|
|
|
89
|
|
10
|
11
|
|
|
11
|
|
18129
|
use namespace::autoclean; |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
108
|
|
11
|
11
|
|
|
11
|
|
2354
|
use CPAN::Meta::Requirements 2.121; # requirements_for_module |
|
11
|
|
|
|
|
14396
|
|
|
11
|
|
|
|
|
404
|
|
12
|
11
|
|
|
11
|
|
77
|
use List::Util 1.29 qw(first pairs pairgrep); |
|
11
|
|
|
|
|
169
|
|
|
11
|
|
|
|
|
976
|
|
13
|
11
|
|
|
11
|
|
77
|
use version; |
|
11
|
|
|
|
|
26
|
|
|
11
|
|
|
|
|
70
|
|
14
|
11
|
|
|
11
|
|
872
|
use Path::Tiny; |
|
11
|
|
|
|
|
26
|
|
|
11
|
|
|
|
|
30591
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
extends 'Dist::Zilla::Plugin::MakeMaker' => { -version => 5.001 }; |
17
|
|
|
|
|
|
|
# avoid wiping out the method modifications to dump_config done by superclass |
18
|
|
|
|
|
|
|
with |
19
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileGatherer' => { -excludes => 'dump_config' }, |
20
|
|
|
|
|
|
|
'Dist::Zilla::Role::BeforeBuild' => { -excludes => 'dump_config' }; |
21
|
|
|
|
|
|
|
|
22
|
16
|
|
|
16
|
0
|
4613813
|
sub mvp_multivalue_args { qw(WriteMakefile_arg_strs test_files exe_files header_strs footer_strs) } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub mvp_aliases { |
25
|
|
|
|
|
|
|
+{ |
26
|
16
|
|
|
16
|
0
|
2355
|
WriteMakefile_arg => 'WriteMakefile_arg_strs', |
27
|
|
|
|
|
|
|
test_file => 'test_files', |
28
|
|
|
|
|
|
|
exe_file => 'exe_files', |
29
|
|
|
|
|
|
|
header => 'header_strs', |
30
|
|
|
|
|
|
|
footer => 'footer_strs', |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has MakeFile_PL_template => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => Stringlike, |
37
|
|
|
|
|
|
|
coerce => 1, |
38
|
|
|
|
|
|
|
lazy => 1, |
39
|
|
|
|
|
|
|
builder => '_build_MakeFile_PL_template', |
40
|
|
|
|
|
|
|
documentation => "The Text::Template used to construct the ExtUtils::MakeMaker Makefile.PL", |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _build_MakeFile_PL_template { |
44
|
14
|
|
|
14
|
|
118
|
my ($self) = @_; |
45
|
|
|
|
|
|
|
|
46
|
14
|
|
|
|
|
39
|
my $template = <<'TEMPLATE'; |
47
|
|
|
|
|
|
|
# This Makefile.PL for {{ $dist->name }} was generated by |
48
|
|
|
|
|
|
|
# {{ ref $plugin }} {{ ($plugin->VERSION || '<self>') |
49
|
|
|
|
|
|
|
. (ref $plugin ne 'Dist::Zilla::Plugin::MakeMaker::Awesome' |
50
|
|
|
|
|
|
|
? "\n" . '# and Dist::Zilla::Plugin::MakeMaker::Awesome ' |
51
|
|
|
|
|
|
|
. Dist::Zilla::Plugin::MakeMaker::Awesome->VERSION |
52
|
|
|
|
|
|
|
: '') }}. |
53
|
|
|
|
|
|
|
# Don't edit it but the dist.ini and plugins used to construct it. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
use strict; |
56
|
|
|
|
|
|
|
use warnings; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
{{ $perl_prereq ? qq[use $perl_prereq;] : ''; }} |
59
|
|
|
|
|
|
|
use ExtUtils::MakeMaker{{ |
60
|
|
|
|
|
|
|
0+$eumm_version |
61
|
|
|
|
|
|
|
? ' ' . (0+$eumm_version eq $eumm_version ? $eumm_version : "'" . $eumm_version . "'") |
62
|
|
|
|
|
|
|
: '' }}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
{{ $header }} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
{{ $share_dir_block[0] }} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my {{ $WriteMakefileArgs }} |
69
|
|
|
|
|
|
|
{{ |
70
|
|
|
|
|
|
|
@$extra_args ? "%WriteMakefileArgs = (\n" |
71
|
|
|
|
|
|
|
. join('', map " $_,\n", '%WriteMakefileArgs', @$extra_args) |
72
|
|
|
|
|
|
|
. ");\n" |
73
|
|
|
|
|
|
|
: ''; |
74
|
|
|
|
|
|
|
}} |
75
|
|
|
|
|
|
|
my {{ $fallback_prereqs }} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
unless ( eval { ExtUtils::MakeMaker->VERSION('6.63_03') } ) { |
78
|
|
|
|
|
|
|
delete $WriteMakefileArgs{TEST_REQUIRES}; |
79
|
|
|
|
|
|
|
delete $WriteMakefileArgs{BUILD_REQUIRES}; |
80
|
|
|
|
|
|
|
$WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
delete $WriteMakefileArgs{CONFIGURE_REQUIRES} |
84
|
|
|
|
|
|
|
unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
WriteMakefile(%WriteMakefileArgs); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
{{ $share_dir_block[1] }} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
{{ $footer }} |
91
|
|
|
|
|
|
|
TEMPLATE |
92
|
|
|
|
|
|
|
|
93
|
14
|
|
|
|
|
502
|
return $template; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
around BUILDARGS => sub |
97
|
|
|
|
|
|
|
{ |
98
|
|
|
|
|
|
|
my $orig = shift; |
99
|
|
|
|
|
|
|
my $class = shift; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $args = $class->$orig(@_); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my $delimiter = delete $args->{delimiter}; |
104
|
|
|
|
|
|
|
if (defined $delimiter and length($delimiter)) |
105
|
|
|
|
|
|
|
{ |
106
|
|
|
|
|
|
|
foreach my $arg (grep exists $args->{$_}, qw(WriteMakefile_arg_strs header_strs footer_strs)) |
107
|
|
|
|
|
|
|
{ |
108
|
|
|
|
|
|
|
s/^\Q$delimiter\E// foreach @{$args->{$arg}}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
return $args; |
113
|
|
|
|
|
|
|
}; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
around dump_config => sub |
116
|
|
|
|
|
|
|
{ |
117
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
118
|
|
|
|
|
|
|
my $config = $self->$orig; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my $data = { |
121
|
|
|
|
|
|
|
blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (), |
122
|
|
|
|
|
|
|
}; |
123
|
|
|
|
|
|
|
$config->{+__PACKAGE__} = $data if keys %$data; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$config->{'Dist::Zilla::Plugin::MakeMaker'}{make_path} ||= $self->make_path; |
126
|
|
|
|
|
|
|
$config->{'Dist::Zilla::Plugin::MakeMaker'}{version} ||= Dist::Zilla::Plugin::MakeMaker->VERSION; |
127
|
|
|
|
|
|
|
$config->{'Dist::Zilla::Role::TestRunner'}{version} ||= Dist::Zilla::Role::TestRunner->VERSION; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
return $config; |
130
|
|
|
|
|
|
|
}; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
has WriteMakefile_arg_strs => ( |
133
|
|
|
|
|
|
|
is => 'ro', isa => ArrayRef[Str], |
134
|
|
|
|
|
|
|
traits => ['Array'], |
135
|
|
|
|
|
|
|
lazy => 1, |
136
|
|
|
|
|
|
|
default => sub { [] }, |
137
|
|
|
|
|
|
|
documentation => "Additional arguments passed to ExtUtils::MakeMaker's WriteMakefile()", |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
has WriteMakefile_args => ( |
141
|
|
|
|
|
|
|
isa => HashRef, |
142
|
|
|
|
|
|
|
traits => ['Hash'], |
143
|
|
|
|
|
|
|
handles => { |
144
|
|
|
|
|
|
|
WriteMakefile_args => 'elements', |
145
|
|
|
|
|
|
|
delete_WriteMakefile_arg => 'delete', |
146
|
|
|
|
|
|
|
WriteMakefile_arg => 'get', |
147
|
|
|
|
|
|
|
}, |
148
|
|
|
|
|
|
|
lazy => 1, |
149
|
|
|
|
|
|
|
builder => '_build_WriteMakefile_args', |
150
|
|
|
|
|
|
|
documentation => "The arguments passed to ExtUtils::MakeMaker's WriteMakefile()", |
151
|
|
|
|
|
|
|
); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub _build_WriteMakefile_args { |
154
|
14
|
|
|
14
|
|
66
|
my ($self) = @_; |
155
|
|
|
|
|
|
|
|
156
|
14
|
|
|
|
|
406
|
(my $name = $self->zilla->name) =~ s/-/::/g; |
157
|
14
|
|
|
|
|
1042
|
my $test_files = $self->test_files; |
158
|
|
|
|
|
|
|
|
159
|
14
|
|
|
|
|
560
|
my $perl_prereq = $self->min_perl_version; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
my $prereqs_dump = sub { |
162
|
56
|
|
|
56
|
|
9307
|
$self->zilla->prereqs->requirements_for(@_) |
163
|
|
|
|
|
|
|
->clone |
164
|
|
|
|
|
|
|
->clear_requirement('perl') |
165
|
|
|
|
|
|
|
->as_string_hash; |
166
|
14
|
|
|
|
|
99
|
}; |
167
|
|
|
|
|
|
|
|
168
|
14
|
|
|
|
|
74
|
my %require_prereqs = map |
169
|
|
|
|
|
|
|
+($_ => $prereqs_dump->($_, 'requires')), |
170
|
|
|
|
|
|
|
qw(configure build test runtime); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# EUMM may soon be able to support this, but until we decide to inject a |
173
|
|
|
|
|
|
|
# higher configure-requires version, we should at least warn the user |
174
|
|
|
|
|
|
|
# https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker/issues/215 |
175
|
14
|
|
|
|
|
2274
|
foreach my $phase (qw(configure build test runtime)) { |
176
|
56
|
50
|
100
|
19
|
|
705
|
if (my @version_ranges = pairgrep { defined $b && !version::is_lax($b) } %{ $require_prereqs{$phase} } |
|
19
|
100
|
|
|
|
151
|
|
|
56
|
|
|
|
|
352
|
|
177
|
|
|
|
|
|
|
and $self->eumm_version < '7.1101') { |
178
|
|
|
|
|
|
|
$self->log_fatal([ |
179
|
|
|
|
|
|
|
'found version range in %s prerequisites, which ExtUtils::MakeMaker cannot parse (must specify eumm_version of at least 7.1101): %s %s', |
180
|
|
|
|
|
|
|
$phase, $_->[0], $_->[1] |
181
|
1
|
|
|
|
|
32
|
]) foreach pairs @version_ranges; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
13
|
50
|
|
|
|
51
|
my @authors = eval { Dist::Zilla->VERSION('7.000') } ? $self->zilla->authors : @{ $self->zilla->authors }; |
|
13
|
|
|
|
|
341
|
|
|
13
|
|
|
|
|
438
|
|
186
|
13
|
|
|
|
|
870
|
my $exe_files = $self->exe_files; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
my %WriteMakefile = ( |
189
|
|
|
|
|
|
|
DISTNAME => $self->zilla->name, |
190
|
|
|
|
|
|
|
NAME => $name, |
191
|
|
|
|
|
|
|
( AUTHOR => @authors > 1 && ($self->eumm_version >= 6.5702 || $perl_prereq >= 5.013005) |
192
|
|
|
|
|
|
|
? \@authors |
193
|
|
|
|
|
|
|
: join(q{, }, @authors) ), |
194
|
|
|
|
|
|
|
ABSTRACT => $self->zilla->abstract, |
195
|
|
|
|
|
|
|
VERSION => $self->zilla->version, |
196
|
|
|
|
|
|
|
LICENSE => $self->zilla->license->meta_yml_name, |
197
|
|
|
|
|
|
|
@$exe_files ? ( EXE_FILES => [ sort @$exe_files ] ) : (), |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
CONFIGURE_REQUIRES => $require_prereqs{configure}, |
200
|
13
|
|
|
|
|
2596
|
keys %{ $require_prereqs{build} } ? ( BUILD_REQUIRES => $require_prereqs{build} ) : (), |
201
|
13
|
|
|
|
|
265
|
keys %{ $require_prereqs{test} } ? ( TEST_REQUIRES => $require_prereqs{test} ) : (), |
202
|
|
|
|
|
|
|
PREREQ_PM => $require_prereqs{runtime}, |
203
|
|
|
|
|
|
|
|
204
|
13
|
100
|
100
|
|
|
356
|
test => { TESTS => join q{ }, sort @$test_files }, |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
$perl_prereq ? ( MIN_PERL_VERSION => $perl_prereq ) : (), |
207
|
|
|
|
|
|
|
); |
208
|
|
|
|
|
|
|
|
209
|
13
|
|
|
|
|
709
|
return \%WriteMakefile; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# overrides parent version |
213
|
|
|
|
|
|
|
has eumm_version => ( |
214
|
|
|
|
|
|
|
isa => 'Str', |
215
|
|
|
|
|
|
|
is => 'rw', |
216
|
|
|
|
|
|
|
lazy => 1, |
217
|
|
|
|
|
|
|
default => sub { |
218
|
|
|
|
|
|
|
my $self = shift; |
219
|
|
|
|
|
|
|
# do not unnecessarily raise the version just for listref AUTHOR |
220
|
|
|
|
|
|
|
return 0 if not $self->min_perl_version >= 5.013005; |
221
|
|
|
|
|
|
|
( eval { Dist::Zilla->VERSION('7.000') } ? ()= $self->zilla->authors : @{ $self->zilla->authors } ) > 1 |
222
|
|
|
|
|
|
|
? '6.5702' : 0; |
223
|
|
|
|
|
|
|
}, |
224
|
|
|
|
|
|
|
); |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
has min_perl_version => ( |
227
|
|
|
|
|
|
|
isa => 'Str', |
228
|
|
|
|
|
|
|
is => 'rw', |
229
|
|
|
|
|
|
|
lazy => 1, |
230
|
|
|
|
|
|
|
builder => '_build_min_perl_version', |
231
|
|
|
|
|
|
|
); |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub _build_min_perl_version |
234
|
|
|
|
|
|
|
{ |
235
|
14
|
|
|
14
|
|
48
|
my $self = shift; |
236
|
|
|
|
|
|
|
|
237
|
14
|
|
|
|
|
392
|
my $prereqs = $self->zilla->prereqs; |
238
|
|
|
|
|
|
|
my $perl_prereq = $prereqs->requirements_for(qw(runtime requires)) |
239
|
|
|
|
|
|
|
->clone |
240
|
|
|
|
|
|
|
->add_requirements($prereqs->requirements_for(qw(configure requires))) |
241
|
|
|
|
|
|
|
->add_requirements($prereqs->requirements_for(qw(build requires))) |
242
|
|
|
|
|
|
|
->add_requirements($prereqs->requirements_for(qw(test requires))) |
243
|
14
|
|
|
|
|
1801
|
->as_string_hash->{perl}; |
244
|
|
|
|
|
|
|
|
245
|
14
|
100
|
|
|
|
7910
|
$perl_prereq |
246
|
|
|
|
|
|
|
? version->parse($perl_prereq)->numify |
247
|
|
|
|
|
|
|
: 0; |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
has WriteMakefile_dump => ( |
251
|
|
|
|
|
|
|
is => 'ro', |
252
|
|
|
|
|
|
|
isa => Stringlike, |
253
|
|
|
|
|
|
|
coerce => 1, |
254
|
|
|
|
|
|
|
lazy => 1, |
255
|
|
|
|
|
|
|
builder => '_build_WriteMakefile_dump', |
256
|
|
|
|
|
|
|
documentation => "A Data::Dumper Str for using WriteMakefile_args used by MakeFile_PL_template" |
257
|
|
|
|
|
|
|
); |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
sub _build_WriteMakefile_dump { |
260
|
12
|
|
|
12
|
|
65
|
my ($self) = @_; |
261
|
|
|
|
|
|
|
# Get arguments for WriteMakefile |
262
|
12
|
|
|
|
|
579
|
my %write_makefile_args = $self->WriteMakefile_args; |
263
|
|
|
|
|
|
|
|
264
|
12
|
|
|
|
|
75
|
return $self->_dump_as(\%write_makefile_args, '*WriteMakefileArgs'); |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
has test_files => ( |
268
|
|
|
|
|
|
|
is => 'ro', |
269
|
|
|
|
|
|
|
isa => ArrayRef[Str], |
270
|
|
|
|
|
|
|
lazy => 1, |
271
|
|
|
|
|
|
|
builder => '_build_test_files', |
272
|
|
|
|
|
|
|
documentation => "The glob paths given to the C<< test => { TESTS => ... } >> parameter for ExtUtils::MakeMaker's WriteMakefile() (in munged form)", |
273
|
|
|
|
|
|
|
); |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
sub _build_test_files { |
276
|
13
|
|
|
13
|
|
55
|
my ($self) = @_; |
277
|
|
|
|
|
|
|
|
278
|
13
|
|
|
|
|
30
|
my %test_files; |
279
|
13
|
|
|
|
|
32
|
for my $file (@{ $self->zilla->files }) { |
|
13
|
|
|
|
|
372
|
|
280
|
38
|
100
|
|
|
|
1821
|
next unless $file->name =~ m{\At/.+\.t\z}; |
281
|
3
|
|
|
|
|
135
|
(my $pattern = $file->name) =~ s{/[^/]+\.t\z}{/*.t}g; |
282
|
|
|
|
|
|
|
|
283
|
3
|
|
|
|
|
134
|
$test_files{$pattern} = 1; |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
|
286
|
13
|
|
|
|
|
1056
|
return [ keys %test_files ]; |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
has exe_files => ( |
290
|
|
|
|
|
|
|
is => 'ro', |
291
|
|
|
|
|
|
|
isa => ArrayRef[Str], |
292
|
|
|
|
|
|
|
lazy => 1, |
293
|
|
|
|
|
|
|
builder => '_build_exe_files', |
294
|
|
|
|
|
|
|
documentation => "The list of filenames given to ExtUtils::MakeMaker's EXE_FILES (in munged form)", |
295
|
|
|
|
|
|
|
); |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub _build_exe_files { |
298
|
13
|
|
|
13
|
|
62
|
my ($self) = @_; |
299
|
|
|
|
|
|
|
|
300
|
13
|
|
|
|
|
57
|
my @exe_files = map $_->name, @{ $self->zilla->find_files(':ExecFiles') }; |
|
13
|
|
|
|
|
402
|
|
301
|
|
|
|
|
|
|
|
302
|
13
|
|
|
|
|
14286
|
return \@exe_files; |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
has share_dir_block => ( |
306
|
|
|
|
|
|
|
is => 'ro', |
307
|
|
|
|
|
|
|
isa => ArrayRef[Str], |
308
|
|
|
|
|
|
|
auto_deref => 1, |
309
|
|
|
|
|
|
|
lazy => 1, |
310
|
|
|
|
|
|
|
builder => '_build_share_dir_block', |
311
|
|
|
|
|
|
|
documentation => "The share dir block used in `MakeFile_PL_template'", |
312
|
|
|
|
|
|
|
); |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
sub _build_share_dir_block { |
315
|
12
|
|
|
12
|
|
41
|
my ($self) = @_; |
316
|
|
|
|
|
|
|
|
317
|
12
|
|
|
|
|
49
|
my @share_dir_block = (q{}, q{}); |
318
|
|
|
|
|
|
|
|
319
|
12
|
|
|
|
|
412
|
my $share_dir_map = $self->zilla->_share_dir_map; |
320
|
12
|
50
|
|
|
|
541
|
if ( keys %$share_dir_map ) { |
321
|
|
|
|
|
|
|
# split in two to foil CPANTS prereq_matches_use |
322
|
0
|
|
|
|
|
0
|
my $preamble = qq{use File::Shar}.qq{eDir::Install;\n}; |
323
|
0
|
|
|
|
|
0
|
$preamble .= qq{\$File::ShareDir::Install::INCLUDE_DOTFILES = 1;\n}; |
324
|
0
|
|
|
|
|
0
|
$preamble .= qq{\$File::ShareDir::Install::INCLUDE_DOTDIRS = 1;\n}; |
325
|
0
|
0
|
|
|
|
0
|
if ( my $dist_share_dir = $share_dir_map->{dist} ) { |
326
|
0
|
|
|
|
|
0
|
$dist_share_dir = quotemeta $dist_share_dir; |
327
|
0
|
|
|
|
|
0
|
$preamble .= qq{install_share dist => "$dist_share_dir";\n}; |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
|
330
|
0
|
0
|
|
|
|
0
|
if ( my $mod_map = $share_dir_map->{module} ) { |
331
|
0
|
|
|
|
|
0
|
for my $mod ( keys %$mod_map ) { |
332
|
0
|
|
|
|
|
0
|
my $mod_share_dir = quotemeta $mod_map->{$mod}; |
333
|
0
|
|
|
|
|
0
|
$preamble .= qq{install_share module => "$mod", "$mod_share_dir";\n}; |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
} |
336
|
|
|
|
|
|
|
@share_dir_block = ( |
337
|
0
|
|
|
|
|
0
|
$preamble, |
338
|
|
|
|
|
|
|
qq{\{\npackage\nMY;\nuse File::ShareDir::Install qw(postamble);\n\}\n}, |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
); |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
12
|
|
|
|
|
429
|
return \@share_dir_block; |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
has header_strs => ( |
347
|
|
|
|
|
|
|
is => 'ro', isa => ArrayRef[Str], |
348
|
|
|
|
|
|
|
traits => ['Array'], |
349
|
|
|
|
|
|
|
lazy => 1, |
350
|
|
|
|
|
|
|
default => sub { [] }, |
351
|
|
|
|
|
|
|
documentation => "Additional code lines to include at the beginning of Makefile.PL", |
352
|
|
|
|
|
|
|
); |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
has header_file => ( |
355
|
|
|
|
|
|
|
is => 'ro', isa => Str, |
356
|
|
|
|
|
|
|
documentation => 'Additional header content to include from a file', |
357
|
|
|
|
|
|
|
); |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
has header => ( |
360
|
|
|
|
|
|
|
is => 'ro', |
361
|
|
|
|
|
|
|
isa => Str, |
362
|
|
|
|
|
|
|
lazy => 1, |
363
|
|
|
|
|
|
|
builder => '_build_header', |
364
|
|
|
|
|
|
|
documentation => "A string included at the beginning of Makefile.PL", |
365
|
|
|
|
|
|
|
); |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
sub _build_header { |
368
|
12
|
|
|
12
|
|
36
|
my $self = shift; |
369
|
|
|
|
|
|
|
join "\n", |
370
|
12
|
|
|
|
|
471
|
@{$self->header_strs}, |
371
|
|
|
|
|
|
|
( $self->header_file |
372
|
12
|
100
|
|
|
|
29
|
? do { |
373
|
1
|
|
|
|
|
24
|
my $abs_file = path($self->zilla->root, $self->header_file); |
374
|
1
|
50
|
|
|
|
59
|
$self->log_fatal([ 'header_file %s does not exist!', $self->header_file ]) |
375
|
|
|
|
|
|
|
if not $abs_file->exists; |
376
|
1
|
|
|
|
|
30
|
$abs_file->slurp_utf8 |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
: () ); |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
has footer_strs => ( |
382
|
|
|
|
|
|
|
is => 'ro', isa => ArrayRef[Str], |
383
|
|
|
|
|
|
|
traits => ['Array'], |
384
|
|
|
|
|
|
|
lazy => 1, |
385
|
|
|
|
|
|
|
default => sub { [] }, |
386
|
|
|
|
|
|
|
documentation => "Additional code lines to include at the end of Makefile.PL", |
387
|
|
|
|
|
|
|
); |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
has footer_file => ( |
390
|
|
|
|
|
|
|
is => 'ro', isa => Str, |
391
|
|
|
|
|
|
|
documentation => 'Additional footer content to include from a file', |
392
|
|
|
|
|
|
|
); |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
has footer => ( |
395
|
|
|
|
|
|
|
is => 'ro', |
396
|
|
|
|
|
|
|
isa => Str, |
397
|
|
|
|
|
|
|
lazy => 1, |
398
|
|
|
|
|
|
|
builder => '_build_footer', |
399
|
|
|
|
|
|
|
documentation => "A string included at the end of Makefile.PL", |
400
|
|
|
|
|
|
|
); |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
sub _build_footer { |
403
|
12
|
|
|
12
|
|
43
|
my $self = shift; |
404
|
|
|
|
|
|
|
join "\n", |
405
|
12
|
|
|
|
|
483
|
@{$self->footer_strs}, |
406
|
|
|
|
|
|
|
( $self->footer_file |
407
|
12
|
100
|
|
|
|
31
|
? do { |
408
|
1
|
|
|
|
|
23
|
my $abs_file = path($self->zilla->root, $self->footer_file); |
409
|
1
|
50
|
|
|
|
40
|
$self->log_fatal([ 'footer_file %s does not exist!', $self->footer_file ]) |
410
|
|
|
|
|
|
|
if not $abs_file->exists; |
411
|
1
|
|
|
|
|
23
|
$abs_file->slurp_utf8 |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
: () ); |
414
|
|
|
|
|
|
|
} |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
sub register_prereqs { |
417
|
14
|
|
|
14
|
1
|
54317
|
my ($self) = @_; |
418
|
|
|
|
|
|
|
|
419
|
14
|
|
100
|
|
|
536
|
$self->zilla->register_prereqs( |
420
|
|
|
|
|
|
|
{ phase => 'configure' }, |
421
|
|
|
|
|
|
|
'ExtUtils::MakeMaker' => $self->eumm_version || 0, |
422
|
|
|
|
|
|
|
); |
423
|
|
|
|
|
|
|
|
424
|
14
|
50
|
|
|
|
6653
|
return unless keys %{ $self->zilla->_share_dir_map }; |
|
14
|
|
|
|
|
467
|
|
425
|
|
|
|
|
|
|
|
426
|
0
|
|
|
|
|
0
|
$self->zilla->register_prereqs( |
427
|
|
|
|
|
|
|
{ phase => 'configure', type => 'requires' }, |
428
|
|
|
|
|
|
|
'File::ShareDir::Install' => 0.06, |
429
|
|
|
|
|
|
|
); |
430
|
|
|
|
|
|
|
|
431
|
0
|
|
|
|
|
0
|
return {}; |
432
|
|
|
|
|
|
|
} |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
sub gather_files |
435
|
|
|
|
|
|
|
{ |
436
|
14
|
|
|
14
|
1
|
142112
|
my $self = shift; |
437
|
|
|
|
|
|
|
|
438
|
14
|
|
|
|
|
130
|
require Dist::Zilla::File::InMemory; |
439
|
14
|
|
|
|
|
631
|
my $file = Dist::Zilla::File::InMemory->new({ |
440
|
|
|
|
|
|
|
name => 'Makefile.PL', |
441
|
|
|
|
|
|
|
content => $self->MakeFile_PL_template, # template evaluated later |
442
|
|
|
|
|
|
|
}); |
443
|
|
|
|
|
|
|
|
444
|
14
|
|
|
|
|
5219
|
$self->add_file($file); |
445
|
14
|
|
|
|
|
8737
|
return; |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
sub setup_installer |
449
|
|
|
|
|
|
|
{ |
450
|
14
|
|
|
14
|
1
|
301602
|
my $self = shift; |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
## Sanity checks |
453
|
|
|
|
|
|
|
$self->log_fatal("can't install files with whitespace in their names") |
454
|
14
|
50
|
|
|
|
45
|
if grep /\s/, @{$self->exe_files}; |
|
14
|
|
|
|
|
603
|
|
455
|
|
|
|
|
|
|
|
456
|
14
|
|
|
|
|
673
|
my $perl_prereq = $self->WriteMakefile_arg('MIN_PERL_VERSION'); |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
# file was already created; find it and fill in the content |
459
|
13
|
|
|
40
|
|
72
|
my $file = first { $_->name eq 'Makefile.PL' } @{$self->zilla->files}; |
|
40
|
|
|
|
|
1667
|
|
|
13
|
|
|
|
|
394
|
|
460
|
13
|
|
|
|
|
698
|
$self->log_debug([ 'updating contents of Makefile.PL in memory' ]); |
461
|
|
|
|
|
|
|
|
462
|
13
|
100
|
|
|
|
5586
|
$self->log_fatal('Makefile.PL has vanished from the distribution! Did you [PruneFiles] the file after it was gathered?' |
463
|
|
|
|
|
|
|
. "\n" . '(instead, try [GatherDir] exclude_filename = Makefile.PL)') |
464
|
|
|
|
|
|
|
if not $file; |
465
|
|
|
|
|
|
|
|
466
|
12
|
|
|
|
|
90
|
my $content = $self->fill_in_string( |
467
|
|
|
|
|
|
|
$file->content, |
468
|
|
|
|
|
|
|
{ |
469
|
|
|
|
|
|
|
dist => \($self->zilla), |
470
|
|
|
|
|
|
|
plugin => \$self, |
471
|
|
|
|
|
|
|
eumm_version => \($self->eumm_version), |
472
|
|
|
|
|
|
|
perl_prereq => \$perl_prereq, |
473
|
|
|
|
|
|
|
share_dir_block => [ $self->share_dir_block ], |
474
|
|
|
|
|
|
|
fallback_prereqs => \($self->fallback_prereq_pm), |
475
|
|
|
|
|
|
|
WriteMakefileArgs => \($self->WriteMakefile_dump), |
476
|
|
|
|
|
|
|
extra_args => \($self->WriteMakefile_arg_strs), |
477
|
|
|
|
|
|
|
header => \$self->header, |
478
|
|
|
|
|
|
|
footer => \$self->footer, |
479
|
|
|
|
|
|
|
}, |
480
|
|
|
|
|
|
|
); |
481
|
|
|
|
|
|
|
|
482
|
12
|
|
|
|
|
35590
|
$content =~ s/\n{3,}/\n\n/g; |
483
|
12
|
|
|
|
|
232
|
$content =~ s/\n+\z/\n/; |
484
|
|
|
|
|
|
|
|
485
|
12
|
|
|
|
|
90
|
$file->content($content); |
486
|
12
|
|
|
|
|
3737
|
return; |
487
|
|
|
|
|
|
|
} |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
sub before_build |
490
|
|
|
|
|
|
|
{ |
491
|
16
|
|
|
16
|
0
|
876841
|
my $self = shift; |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
my @makemaker_plugins = |
494
|
|
|
|
|
|
|
grep $_->isa('Dist::Zilla::Plugin::MakeMaker'), |
495
|
16
|
50
|
|
|
|
53
|
eval { Dist::Zilla->VERSION('7.000') } ? $self->zilla->plugins : @{ $self->zilla->plugins }; |
|
16
|
|
|
|
|
490
|
|
|
16
|
|
|
|
|
581
|
|
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
my @plugin_classes = map { |
498
|
16
|
|
|
|
|
799
|
my $class = blessed($_); |
|
19
|
|
|
|
|
91
|
|
499
|
19
|
100
|
|
|
|
161
|
($class =~ s/^Dist::Zilla::Plugin:://) ? "[$class]" : $class; |
500
|
|
|
|
|
|
|
} @makemaker_plugins; |
501
|
|
|
|
|
|
|
|
502
|
16
|
100
|
|
|
|
113
|
my $classes = join(' and ', |
503
|
|
|
|
|
|
|
(@plugin_classes > 2 ? join(', ', @plugin_classes[0 .. $#plugin_classes-1]) : $plugin_classes[0]), |
504
|
|
|
|
|
|
|
$plugin_classes[-1], |
505
|
|
|
|
|
|
|
); |
506
|
|
|
|
|
|
|
|
507
|
16
|
100
|
|
|
|
206
|
$self->log_fatal([ 'You can\'t use %s at the same time!', $classes ]) |
508
|
|
|
|
|
|
|
if @makemaker_plugins > 1; |
509
|
|
|
|
|
|
|
} |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
__END__ |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
=pod |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
=encoding UTF-8 |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
=head1 NAME |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
Dist::Zilla::Plugin::MakeMaker::Awesome - A more awesome MakeMaker plugin for L<Dist::Zilla> |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
=head1 VERSION |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
version 0.48 |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
=head1 SYNOPSIS |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
In your F<dist.ini>: |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
[MakeMaker::Awesome] |
532
|
|
|
|
|
|
|
WriteMakefile_arg = CCFLAGS => `pkg-config --cflags libpng` |
533
|
|
|
|
|
|
|
WriteMakefile_arg = LIBS => [ `pkg-config --libs libpng` ] |
534
|
|
|
|
|
|
|
header = die 'Unsupported OS' if $^O eq 'MSWin32'; |
535
|
|
|
|
|
|
|
delimiter = | |
536
|
|
|
|
|
|
|
footer = |package MY; |
537
|
|
|
|
|
|
|
footer = |sub postamble { |
538
|
|
|
|
|
|
|
footer = | my $self = shift; |
539
|
|
|
|
|
|
|
footer = | return $self->SUPER::postamble . "\n\nfoo: bar\n\t$(CP) bar foo\n"; |
540
|
|
|
|
|
|
|
footer = |} |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
or: |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
;; Replace [MakeMaker] |
545
|
|
|
|
|
|
|
;[MakeMaker] |
546
|
|
|
|
|
|
|
[=inc::MyMakeMaker] |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
=head1 DESCRIPTION |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
L<Dist::Zilla>'s L<MakeMaker|Dist::Zilla::Plugin::MakeMaker> plugin is |
551
|
|
|
|
|
|
|
limited, if you want to stray from the marked path and do something |
552
|
|
|
|
|
|
|
that would normally be done in a C<package MY> section or otherwise |
553
|
|
|
|
|
|
|
run custom code in your F<Makefile.PL> you're out of luck. |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
This plugin is 100% compatible with L<Dist::Zilla::Plugin::MakeMaker> -- we |
556
|
|
|
|
|
|
|
add additional customization hooks by subclassing it. |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
=head1 CONFIGURATION OPTIONS |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
Many features can be accessed directly via F<dist.ini>, by setting options. |
561
|
|
|
|
|
|
|
For options where you expect a multi-line string to be inserted into |
562
|
|
|
|
|
|
|
F<Makefile.PL>, use the config option more than once, setting each line |
563
|
|
|
|
|
|
|
separately. |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=head2 WriteMakefile_arg |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
A string, which evaluates to an even-numbered list, which will be included in the call to |
568
|
|
|
|
|
|
|
C<WriteMakefile>. Any code is legal that can be inserted into a list of other |
569
|
|
|
|
|
|
|
key-value pairs, for example: |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
[MakeMaker::Awesome] |
572
|
|
|
|
|
|
|
WriteMakefile_arg = ( $^O eq 'solaris' ? ( CCFLAGS => '-Wall' ) : ()) |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
Can be used more than once. |
575
|
|
|
|
|
|
|
Available since version 0.21. |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
=for stopwords DynamicPrereqs |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
Note: you (intentionally) cannot use this mechanism for specifying dynamic |
580
|
|
|
|
|
|
|
prerequisites, as previous occurrences of a top-level key will be overwritten |
581
|
|
|
|
|
|
|
(additionally, you cannot set the fallback prereqs from here). You should take |
582
|
|
|
|
|
|
|
a look at L<[DynamicPrereqs]|Dist::Zilla::Plugin::DynamicPrereqs> for this. |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
=head2 header |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
A line of code which is included near the top of F<Makefile.PL>. Can be used more than once. |
587
|
|
|
|
|
|
|
Available since version 0.26. |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
=head2 header_file |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
The name of a file in the source tree (does not need to be gathered in the |
592
|
|
|
|
|
|
|
build) whose content is inserted near the top of F<Makefile.PL>. |
593
|
|
|
|
|
|
|
Available since version 0.35. |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=head2 footer |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
A line of code which is included at the bottom of F<Makefile.PL>. Can be used more than once. |
598
|
|
|
|
|
|
|
Available since version 0.26. |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
=head2 footer_file |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
The name of a file in the source tree (does not need to be gathered in the |
603
|
|
|
|
|
|
|
build) whose content is inserted at the bottom of F<Makefile.PL>. |
604
|
|
|
|
|
|
|
Available since version 0.35. |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
=head2 delimiter |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
A string, usually a single character, which is stripped from the beginning of |
609
|
|
|
|
|
|
|
all C<WriteMakefile_arg>, C<header>, and C<footer> lines. This is because the |
610
|
|
|
|
|
|
|
INI file format strips all leading whitespace from option values, so including |
611
|
|
|
|
|
|
|
this character at the front allows you to use leading whitespace in an option |
612
|
|
|
|
|
|
|
string. This is crucial for the formatting of F<Makefile>s, but a nice thing |
613
|
|
|
|
|
|
|
to have when inserting any block of code. |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
Available since version 0.27. |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
=head2 test_file |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
A glob path given to the C<< test => { TESTS => ... } >> parameter for |
620
|
|
|
|
|
|
|
L<ExtUtils::MakeMaker/WriteMakefile>. Can be used more than once. |
621
|
|
|
|
|
|
|
Defaults to F<.t> files under F<t/>. B<NOT> a directory name, despite the name. |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
Available since version 0.21. |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
=head2 exe_file |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
The file given to the C<EXE_FILES> parameter for |
628
|
|
|
|
|
|
|
L<ExtUtils::MakeMaker/WriteMakefile>. Can be used more than once. |
629
|
|
|
|
|
|
|
Defaults to using data from C<:ExecDir> plugins. |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
Available since version 0.21. |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
=head1 SUBCLASSING |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
You can further customize the content of F<Makefile.PL> by subclassing this plugin, |
636
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::MakeMaker::Awesome>. |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
As an example, adding a C<package MY> section to your |
639
|
|
|
|
|
|
|
F<Makefile.PL>: |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
In your F<dist.ini>: |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
[=inc::MyDistMakeMaker / MyDistMakeMaker] |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
Then in your F<inc/MyDistMakeMaker.pm>, real example from L<Hailo> |
646
|
|
|
|
|
|
|
(which has C<[=inc::HailoMakeMaker / HailoMakeMaker]> in its |
647
|
|
|
|
|
|
|
F<dist.ini>): |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
package inc::HailoMakeMaker; |
650
|
|
|
|
|
|
|
use Moose; |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
extends 'Dist::Zilla::Plugin::MakeMaker::Awesome'; |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
override _build_MakeFile_PL_template => sub { |
655
|
|
|
|
|
|
|
my ($self) = @_; |
656
|
|
|
|
|
|
|
my $template = super(); |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
$template .= <<'TEMPLATE'; |
659
|
|
|
|
|
|
|
package MY; |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
sub test { |
662
|
|
|
|
|
|
|
my $inherited = shift->SUPER::test(@_); |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
# Run tests with Moose and Mouse |
665
|
|
|
|
|
|
|
$inherited =~ s/^test_dynamic :: pure_all\n\t(.*?)\n/test_dynamic :: pure_all\n\tANY_MOOSE=Mouse $1\n\tANY_MOOSE=Moose $1\n/m; |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
return $inherited; |
668
|
|
|
|
|
|
|
} |
669
|
|
|
|
|
|
|
TEMPLATE |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
return $template; |
672
|
|
|
|
|
|
|
}; |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
=for stopwords distro |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
Or maybe you're writing an XS distro and want to pass custom arguments |
679
|
|
|
|
|
|
|
to C<WriteMakefile()>, here's an example of adding a C<LIBS> argument |
680
|
|
|
|
|
|
|
in L<re::engine::PCRE> (note that you can also achieve this without |
681
|
|
|
|
|
|
|
subclassing, by passing the L</WriteMakefile_arg> option): |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
package inc::PCREMakeMaker; |
684
|
|
|
|
|
|
|
use Moose; |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
extends 'Dist::Zilla::Plugin::MakeMaker::Awesome'; |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
override _build_WriteMakefile_args => sub { +{ |
689
|
|
|
|
|
|
|
# Add LIBS => to WriteMakefile() args |
690
|
|
|
|
|
|
|
%{ super() }, |
691
|
|
|
|
|
|
|
LIBS => [ '-lpcre' ], |
692
|
|
|
|
|
|
|
} }; |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
And another example from L<re::engine::Plan9>, which determines the arguments |
697
|
|
|
|
|
|
|
dynamically at build time: |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
package inc::Plan9MakeMaker; |
700
|
|
|
|
|
|
|
use Moose; |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
extends 'Dist::Zilla::Plugin::MakeMaker::Awesome'; |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
override _build_WriteMakefile_args => sub { |
705
|
|
|
|
|
|
|
my ($self) = @_; |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
our @DIR = qw(libutf libfmt libregexp); |
708
|
|
|
|
|
|
|
our @OBJ = map { s/\.c$/.o/; $_ } |
709
|
|
|
|
|
|
|
grep { ! /test/ } |
710
|
|
|
|
|
|
|
glob "lib*/*.c"; |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
return +{ |
713
|
|
|
|
|
|
|
%{ super() }, |
714
|
|
|
|
|
|
|
DIR => [ @DIR ], |
715
|
|
|
|
|
|
|
INC => join(' ', map "-I$_", @DIR), |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
# This used to be '-shared lib*/*.o' but that doesn't work on Win32 |
718
|
|
|
|
|
|
|
LDDLFLAGS => "-shared @OBJ", |
719
|
|
|
|
|
|
|
}; |
720
|
|
|
|
|
|
|
}; |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
If you have custom code in your L<ExtUtils::MakeMaker>-based |
725
|
|
|
|
|
|
|
F<Makefile.PL> that L<Dist::Zilla> can't replace via its default |
726
|
|
|
|
|
|
|
facilities you'll be able to replace it by using this module. |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
Even if your F<Makefile.PL> isn't L<ExtUtils::MakeMaker>-based you |
729
|
|
|
|
|
|
|
should be able to override it. You'll just have to provide a new |
730
|
|
|
|
|
|
|
L</"_build_MakeFile_PL_template">. |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=for stopwords overridable |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
=head2 OVERRIDABLE METHODS |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
These are the methods you can currently C<override> or method-modify in your |
737
|
|
|
|
|
|
|
custom F<inc/> module. The work that this module does is entirely done in |
738
|
|
|
|
|
|
|
small modular methods that can be overridden in your subclass. Here are |
739
|
|
|
|
|
|
|
some of the highlights: |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
=for Pod::Coverage mvp_multivalue_args mvp_aliases before_build |
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
=head3 _build_MakeFile_PL_template |
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
Returns a L<Text::Template> string used to construct the F<Makefile.PL>. |
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
If you need to insert some additional code to the beginning or end of |
748
|
|
|
|
|
|
|
F<Makefile.PL> (without modifying the existing content, you should use an |
749
|
|
|
|
|
|
|
C<around> method modifier, something like this: |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
around _build_MakeFile_PL_template => sub { |
752
|
|
|
|
|
|
|
my $orig = shift; |
753
|
|
|
|
|
|
|
my $self = shift; |
754
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
my $NEW_CONTENT = ...; |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
# insert new content near the beginning of the file, preserving the |
758
|
|
|
|
|
|
|
# existing header content |
759
|
|
|
|
|
|
|
my $string = $self->$orig(@_); |
760
|
|
|
|
|
|
|
$string =~ m/use warnings;\n\n/g; |
761
|
|
|
|
|
|
|
return substr($string, 0, pos($string)) . $NEW_CONTENT . substr($string, pos($string)); |
762
|
|
|
|
|
|
|
}; |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
=head3 _build_WriteMakefile_args |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
A C<HashRef> of arguments that will be passed to |
767
|
|
|
|
|
|
|
L<ExtUtils::MakeMaker>'s C<WriteMakefile> function. |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
=head3 _build_WriteMakefile_dump |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
Takes the return value of L</"_build_WriteMakefile_args"> and |
772
|
|
|
|
|
|
|
constructs a L<Str> that will be included in the F<Makefile.PL> by |
773
|
|
|
|
|
|
|
L</"_build_MakeFile_PL_template">. |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
=head3 _build_header |
776
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
A C<Str> of code that will be included near the top of F<Makefile.PL>. |
778
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
=head3 _build_footer |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
A C<Str> of code that will be included at the bottom of F<Makefile.PL>. |
782
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
=head3 _build_test_files |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
The glob paths given to the C<< test => { TESTS => ... } >> parameter for |
786
|
|
|
|
|
|
|
L<ExtUtils::MakeMaker/WriteMakefile>. Defaults to F<.t> files under F<t/>. |
787
|
|
|
|
|
|
|
B<NOT> directories, despite the name. |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
=head3 _build_exe_files |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
The files given to the C<EXE_FILES> parameter for |
792
|
|
|
|
|
|
|
L<ExtUtils::MakeMaker/WriteMakefile>. |
793
|
|
|
|
|
|
|
Defaults to using data from C<:ExecDir> plugins. |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
=head3 _build_min_perl_version |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
Extracts from the distribution prerequisite object the minimum version of perl |
798
|
|
|
|
|
|
|
required; used for the C<MIN_PERL_VERSION> parameter for |
799
|
|
|
|
|
|
|
L<ExtUtils::MakeMaker/WriteMakefile>. |
800
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
=head3 register_prereqs |
802
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
=head3 gather_files |
804
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
=head3 setup_installer |
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
=for stopwords dirs |
808
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
The test/bin/share dirs and exe_files. These will all be passed to |
810
|
|
|
|
|
|
|
F</"_build_WriteMakefile_args"> later. |
811
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
=head3 _build_share_dir_block |
813
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
=for stopwords sharedir |
815
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
An C<ArrayRef[Str]> with two elements to be used by |
817
|
|
|
|
|
|
|
L</"_build_MakeFile_PL_template">. The first will declare your |
818
|
|
|
|
|
|
|
L<sharedir|File::ShareDir::Install> and the second will add a magic |
819
|
|
|
|
|
|
|
C<package MY> section to install it. Deep magic. |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
=head2 OTHER |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
The main entry point is C<setup_installer> via the |
824
|
|
|
|
|
|
|
L<Dist::Zilla::Role::InstallTool> role. There are also other magic |
825
|
|
|
|
|
|
|
Dist::Zilla roles, check the source for more info. |
826
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
=over |
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
=item attempt to add F<Makefile.PL> multiple times |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
This error from L<Dist::Zilla> means that you've used both |
834
|
|
|
|
|
|
|
C<[MakeMaker]> and C<[MakeMaker::Awesome]>. You've either included |
835
|
|
|
|
|
|
|
C<MakeMaker> directly in F<dist.ini>, or you have plugin bundle that |
836
|
|
|
|
|
|
|
includes it. See L<@Filter|Dist::Zilla::PluginBundle::Filter> for how |
837
|
|
|
|
|
|
|
to filter it out. |
838
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
=back |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
=head1 LIMITATIONS |
842
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
=for stopwords INI |
844
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
This plugin would suck less if L<Dist::Zilla> didn't use a INI-based |
846
|
|
|
|
|
|
|
config system so you could add stuff like this in your main |
847
|
|
|
|
|
|
|
configuration file like you can with L<Module::Install>. |
848
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
The F<.ini> file format can only support key-value pairs whereas any |
850
|
|
|
|
|
|
|
complex use of L<ExtUtils::MakeMaker> requires running custom Perl |
851
|
|
|
|
|
|
|
code and passing complex data structures to C<WriteMakefile>. |
852
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
=head1 AFTERWORD |
854
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
________________________ |
856
|
|
|
|
|
|
|
< everything is AWESOME! > |
857
|
|
|
|
|
|
|
------------------------ |
858
|
|
|
|
|
|
|
\ ___-------___ |
859
|
|
|
|
|
|
|
\ _-~~ ~~-_ |
860
|
|
|
|
|
|
|
\ _-~ /~-_ |
861
|
|
|
|
|
|
|
/^\__/^\ /~ \ / \ |
862
|
|
|
|
|
|
|
/| O|| O| / \_______________/ \ |
863
|
|
|
|
|
|
|
| |___||__| / / \ \ |
864
|
|
|
|
|
|
|
| \ / / \ \ |
865
|
|
|
|
|
|
|
| (_______) /______/ \_________ \ |
866
|
|
|
|
|
|
|
| / / \ / \ |
867
|
|
|
|
|
|
|
\ \^\\ \ / \ / |
868
|
|
|
|
|
|
|
\ || \______________/ _-_ //\__// |
869
|
|
|
|
|
|
|
\ ||------_-~~-_ ------------- \ --/~ ~\ || __/ |
870
|
|
|
|
|
|
|
~-----||====/~ |==================| |/~~~~~ |
871
|
|
|
|
|
|
|
(_(__/ ./ / \_\ \. |
872
|
|
|
|
|
|
|
(_(___/ \_____)_) |
873
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
=head1 SUPPORT |
875
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-MakeMaker-Awesome> |
877
|
|
|
|
|
|
|
(or L<bug-Dist-Zilla-Plugin-MakeMaker-Awesome@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-MakeMaker-Awesome@rt.cpan.org>). |
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
880
|
|
|
|
|
|
|
L<http://dzil.org/#mailing-list>. |
881
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
883
|
|
|
|
|
|
|
L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>. |
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
=head1 AUTHORS |
886
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
=over 4 |
888
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
=item * |
890
|
|
|
|
|
|
|
|
891
|
|
|
|
|
|
|
Ãvar Arnfjörð Bjarmason <avar@cpan.org> |
892
|
|
|
|
|
|
|
|
893
|
|
|
|
|
|
|
=item * |
894
|
|
|
|
|
|
|
|
895
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
896
|
|
|
|
|
|
|
|
897
|
|
|
|
|
|
|
=back |
898
|
|
|
|
|
|
|
|
899
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
900
|
|
|
|
|
|
|
|
901
|
|
|
|
|
|
|
=for stopwords Jesse Luehrs Robin Smidsrød Tabulo Vladimir Timofeev |
902
|
|
|
|
|
|
|
|
903
|
|
|
|
|
|
|
=over 4 |
904
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
=item * |
906
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
Jesse Luehrs <doy@tozt.net> |
908
|
|
|
|
|
|
|
|
909
|
|
|
|
|
|
|
=item * |
910
|
|
|
|
|
|
|
|
911
|
|
|
|
|
|
|
Robin Smidsrød <robin@smidsrod.no> |
912
|
|
|
|
|
|
|
|
913
|
|
|
|
|
|
|
=item * |
914
|
|
|
|
|
|
|
|
915
|
|
|
|
|
|
|
Tabulo <dev@tabulo.net> |
916
|
|
|
|
|
|
|
|
917
|
|
|
|
|
|
|
=item * |
918
|
|
|
|
|
|
|
|
919
|
|
|
|
|
|
|
Vladimir Timofeev <vovkasm@gmail.com> |
920
|
|
|
|
|
|
|
|
921
|
|
|
|
|
|
|
=back |
922
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
924
|
|
|
|
|
|
|
|
925
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Ãvar Arnfjörð Bjarmason. |
926
|
|
|
|
|
|
|
|
927
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
928
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
929
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
=cut |