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